Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
146 lines (136 loc) · 5.1 KB
/
Copy pathsetup.py
File metadata and controls
146 lines (136 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
from pathlib import Path
import tomllib
from setuptools import find_namespace_packages, find_packages, setup
from pybind11.setup_helpers import Pybind11Extension, build_ext
ROOT = Path(__file__).resolve().parent
def sibling_dependencies(sibling: str, *, extra: str) -> list[str]:
"""Read a sibling's extra without installing its core distribution."""
sibling_path = ROOT.parent / sibling
pyproject = sibling_path / "pyproject.toml"
if not pyproject.is_file():
return [f"{sibling}[{extra}]"]
with pyproject.open("rb") as handle:
project = tomllib.load(handle)["project"]
dependencies = list(project.get("dependencies", []))
dependencies.extend(project.get("optional-dependencies", {}).get(extra, []))
# Lasagna imports only vesuvius.models. The bootstrap owns the machine-
# specific torch build; VC and cuCIM are unrelated to this model builder.
excluded = ("volume-cartographer", "torch", "cucim-cu13")
return [
dependency
for dependency in dependencies
if not dependency.startswith(excluded)
]
# Lasagna predates its packaging metadata and its modules intentionally use
# top-level imports (for example ``import fit_data``). Install those modules
# as-is so editable and regular installs behave like running from this folder.
py_modules = sorted(
path.stem
for path in ROOT.glob("*.py")
if path.name != "setup.py"
)
packages = find_packages(
include=("lasagna3d", "lasagna3d.*", "snap_surf", "snap_surf.*", "scripts")
)
# Also expose the legacy root modules through their canonical ``lasagna.*``
# imports. They remain top-level ``py_modules`` for backwards compatibility.
packages.append("lasagna")
# Preserve the programmatic import already used by callers and tests while the
# legacy internal imports continue to use the top-level ``scripts`` package.
packages.append("lasagna.scripts")
packages.append("lasagna.manager")
# Managed Fiber inference is part of the supported Lasagna runtime. Package
# the sibling source directly so both editable installs and wheels made from
# the monorepo work without an ambient PYTHONPATH. ``neural_tracing`` is a
# namespace package, hence find_namespace_packages rather than find_packages.
VESUVIUS_SOURCE = ROOT.parent / "vesuvius" / "src"
if not VESUVIUS_SOURCE.is_dir():
raise RuntimeError(
"the Lasagna build requires the sibling vesuvius/src tree; "
"build from the villa monorepo checkout"
)
packages.extend(find_namespace_packages(
where=str(VESUVIUS_SOURCE),
include=("vesuvius", "vesuvius.*", "vc3d_fiber_format", "vc3d_fiber_format.*"),
))
fit_service_requires = [
"numpy>=1.24",
"opencv-python-headless>=4.8",
"scikit-image>=0.21",
"scipy>=1.10",
# snap_surf fixtures store N-D tensors with its shaped metadata.
"tifffile>=2023.7.10",
"torch>=2.1",
# Monorepo-only: surfaces and fit artifacts are exchanged through the object
# store; scripts/bootstrap_venv.py installs the sibling vc_object_store.
"vc-object-store",
# Monorepo-only until published: Zarr, TIFF and S3.
"vc-reader",
]
downloader_requires = ["vc-reader"]
preprocess_requires = [
"numpy>=1.24",
"opencv-python-headless>=4.8",
"torch>=2.1",
"threadpoolctl>=3.1",
"vc-reader",
]
preprocess_3d_requires = [
*preprocess_requires,
*downloader_requires,
"edt>=3.0",
"numba>=0.58",
"tensorboard>=2.14",
*sibling_dependencies("vesuvius", extra="models"),
]
all_requires = sorted(set(
fit_service_requires + downloader_requires + preprocess_3d_requires
))
ext_modules = [
Pybind11Extension(
"monotone_norm",
["monotone_norm.cpp"],
),
Pybind11Extension(
"accumulator_add",
["accumulator_add.cpp"],
cxx_std=17,
),
]
setup(
name="vesuvius-lasagna",
version="0.0.1",
description="Surface fitting and OME-Zarr preprocessing tools",
long_description=(ROOT / "README.md").read_text(encoding="utf-8"),
long_description_content_type="text/markdown",
python_requires=">=3.14,<3.15",
py_modules=py_modules,
packages=packages,
package_dir={
"lasagna": ".",
"lasagna.scripts": "scripts",
"lasagna.manager": "manager",
"vesuvius": "../vesuvius/src/vesuvius",
"vc3d_fiber_format": "../vesuvius/src/vc3d_fiber_format",
},
package_data={"vesuvius": ["**/*.json", "**/*.yaml", "**/*.yml"]},
install_requires=all_requires,
ext_modules=ext_modules,
cmdclass={"build_ext": build_ext},
extras_require={
"test": ["pytest>=7"],
"qualzz": ["dynamic-network-architectures"],
},
entry_points={
"console_scripts": [
"lasagna-fit-service=fit_service:main",
"lasagna-download=lasagna.scripts.download_omezarr:main",
"lasagna-download-list=lasagna.scripts.download_volume_list:main",
"lasagna-bootstrap=lasagna.scripts.bootstrap_venv:main",
"lasagna-preprocess=preprocess_cos_omezarr:cli_main",
"las_manager=lasagna.manager.cli:main",
"lasagna-predict3d-holescan=predict3d_holescan:main",
],
},
zip_safe=False,
)