Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ClearMap3pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: ClearMap3pip
channels:
- conda-forge
dependencies:
- python=3.11
- pip
- graph-tool<=2.45
- mkl<2024.1
variables:
PYTHONNOUSERSITE: 1
TMPDIR: /data/tmp
66 changes: 66 additions & 0 deletions build_ext_custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# build_ext_custom.py
from setuptools.command.build_ext import build_ext as _build_ext
from setuptools.extension import Extension
from Cython.Build import cythonize
import numpy as np
import os
import subprocess
from pathlib import Path
import platform

os_name = platform.system().lower()

DEFAULT_COMPILE_ARGS = []
DEFAULT_LIBRARIES = []
DEFAULT_LINK_ARGS = []

if not os_name.startswith('windows'):
DEFAULT_COMPILE_ARGS += ['-w', '-O3']
DEFAULT_LIBRARIES += ['m']

if os_name.startswith('linux'):
try:
out = subprocess.check_output(['gcc', '--help=common']).decode('utf-8')
if '-flarge-source-files' in out:
DEFAULT_COMPILE_ARGS += ['-flarge-source-files']
except Exception:
pass

USE_OPENMP = True
if os_name.startswith('darwin'):
try:
cpp_version = subprocess.check_output(['c++', '--version']).decode('ascii')
USE_OPENMP = 'g++' in cpp_version
except Exception:
USE_OPENMP = False

extra_args = ['-fopenmp'] if USE_OPENMP else []
if os_name.startswith('windows'):
extra_args = [arg.replace('-f', '/') for arg in extra_args]
DEFAULT_COMPILE_ARGS = [arg.replace('-m', '/') for arg in DEFAULT_COMPILE_ARGS]
DEFAULT_LINK_ARGS = [arg.replace('-m', '/') for arg in DEFAULT_LINK_ARGS]

extra_link_args = extra_args
compile_args = DEFAULT_COMPILE_ARGS + extra_args
link_args = DEFAULT_LINK_ARGS + extra_link_args


extension_paths = [str(p) for p in Path('ClearMap').rglob('*.pyx')
if not any(excl in str(p) for excl in ['_Old', '_Todo', 'StatisticsPointListCode', 'flow', 'OrientationCode'])]

extensions = [
Extension(
name=os.path.splitext(p)[0].replace(os.sep, '.'),
sources=[p],
libraries=DEFAULT_LIBRARIES,
language='c++',
include_dirs=[np.get_include(), os.path.dirname(os.path.abspath(p))],
extra_compile_args=compile_args,
extra_link_args=link_args
) for p in extension_paths
]

ext_modules = cythonize(extensions, quiet=True)

class build_ext(_build_ext):
pass
103 changes: 103 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# pyproject.toml for ClearMap using setuptools and PEP 621

[build-system]
requires = [
"setuptools>=61",
"wheel",
"cython",
"numpy"
]
build-backend = "setuptools.build_meta"

[project]
name = "ClearMap"
version = "3.0.0"
description = "3D cell counting and vasculature analysis for lightsheet microscopy"
license = "MIT"
license-files = ["LICENSE", "LICENSE.txt"]
authors = [
{name = "Christoph Kirst"},
{name = "Sophie Skriabine"},
{name = "Charly Rousseau"},
{name = "Etienne Doumazane"},
{name = "Gael Cousin"},
]
dependencies = [
"cython",
"ipython",
"jupyter",
"ipywidgets",
"numpy",
"scipy",
"pandas<2",
"pyarrow",
"scikit-image",
"scikit-learn",
"opencv-python",
"configobj",
"natsort",
"tqdm",
"matplotlib",
"seaborn",
"tifffile",
"pyqt5<6",
"pyqtwebengine",
"qtpy",
"pyqtgraph==0.12.*",
"pygments",
"qdarkstyle",
"vispy",
"pyvista",
"vtk",
"PyOpenGL",
"napari",
"python-igraph",
"torch<=2.2",
"xmltodict",
"psutil",
"mpld3",
"lxml<5.2",
"itk-elastix",
]
requires-python = ">=3.8"

[project.urls]
Homepage = "https://github.com/ClearAnatomics/ClearMap"

[project.optional-dependencies]
# Define extras if needed later

[project.scripts]
cell_map = "ClearMap.Scripts.cell_map_new_api:main"
clearmap-utils = "ClearMap.Scripts.clearmap_utils:main"

[project.gui-scripts]
clearmap-ui = "ClearMap.gui.run_gui:entry_point"

[tool.setuptools]
packages = ["ClearMap"]

[tool.setuptools.package-data]
"ClearMap.config" = ["*.cfg"]
"ClearMap.gui" = [
"creator/*.ui",
"creator/*.qrc",
"creator/graphics_resources/*.png",
"creator/graphics_resources/*.jpg",
"creator/graphics_resources/*.svg",
"creator/icons/*.png",
"creator/icons/*.jpg",
"creator/icons/*.svg"
]

[tool.setuptools.data-files]
"" = ["start_gui.sh"]
"ClearMap/External/elastix" = []
"ClearMap/External/geodesic_distance" = []
"ClearMap/Resources" = []
"ClearMap/ImageProcessing/Skeletonization" = []
"ClearMap/ImageProcessing/Binary" = []
"ClearMap/ImageProcessing/machine_learning/vessel_filling/resources" = []

[tool.setuptools.cmdclass]
build_ext = "build_ext_custom.build_ext"