diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 30c2c1741..4413211c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,23 +15,22 @@ repos: hooks: - id: isort files: ^python/cucim/src/.* - args: ["--settings-path=python/cucim/pyproject_.toml"] + args: ["--settings-path=python/cucim/pyproject.toml"] - repo: https://github.com/psf/black rev: 23.3.0 hooks: - id: black files: (python|legate)/.* - args: ["--config", "python/cucim/pyproject_.toml"] + args: ["--config", "python/cucim/pyproject.toml"] - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.0.278 hooks: - id: ruff files: python/.*$ - args: ["--exclude", "__init__.py"] - repo: https://github.com/codespell-project/codespell rev: v2.2.4 hooks: - id: codespell - args: ["--toml", "python/cucim/pyproject_.toml"] + args: ["--toml", "python/cucim/pyproject.toml"] additional_dependencies: - tomli diff --git a/conda/recipes/cucim/build.sh b/conda/recipes/cucim/build.sh index 28b1112c2..cd484ce48 100644 --- a/conda/recipes/cucim/build.sh +++ b/conda/recipes/cucim/build.sh @@ -18,6 +18,6 @@ cp -P python/install/lib/* python/cucim/src/cucim/clara/ pushd python/cucim echo "PYTHON: ${PYTHON}" -$PYTHON setup.py install +$PYTHON -m pip install . popd diff --git a/python/cucim/pyproject.toml b/python/cucim/pyproject.toml new file mode 100644 index 000000000..6534906ba --- /dev/null +++ b/python/cucim/pyproject.toml @@ -0,0 +1,241 @@ +# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. +# See file LICENSE for terms. + +[build-system] +build-backend = "setuptools.build_meta" +# TODO: generate this list with `rapids-dependency-file-generator` +requires = [ + "setuptools>=24.2.0", + "wheel", +] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. + +[project] +name = "cucim" +version = "23.12.00" +description = "cuCIM - an extensible toolkit designed to provide GPU accelerated I/O, computer vision & image processing primitives for N-Dimensional images with a focus on biomedical imaging." +# TODO: tried also adding CHANGELOG.md as in setup.py's long_description, but ruff complained about it +readme = { file = "README.md", content-type = "text/markdown" } +# readme = [ +# { file = "README.md", content-type = "text/markdown" }, +# { file = "CHANGELOG.md", content-type = "text/markdown" }, +# ] +authors = [ + { name = "NVIDIA Corporation" }, +] +license = { text = "Apache 2.0" } +requires-python = ">=3.8" +#TODO: add dependencies.yaml and generate this by `rapids-dependency-file-generator` instead +dependencies = [ + "click", + "numpy", + "lazy_loader>=0.1", +] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "Intended Audience :: Healthcare Industry", + "Topic :: Scientific/Engineering", + "Operating System :: POSIX :: Linux", + "Environment :: Console", + "Environment :: GPU :: NVIDIA CUDA :: 11.0", + "Environment :: GPU :: NVIDIA CUDA :: 12.0", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: C++", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] + +[project.urls] +Homepage = "https://developer.nvidia.com/multidimensional-image-processing" +Documentation = "https://docs.rapids.ai/api/cucim/stable/" +Changelog = "https://github.com/rapidsai/cucim/blob/branch-23.12/CHANGELOG.md" +Source = "https://github.com/rapidsai/cucim" +Tracker = "https://github.com/rapidsai/cucim/issues" + +[project.optional-dependencies] +test = [ + "cupy-cuda11x>=12.0.0", + "scipy", + "scikit-image>=0.19", + "pytest", + "pytest-lazy-fixture", + "gputil", + "openslide-python", +] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. +developer = [ + "black", + "isort", + "pre-commit", + "ruff", +] +docs = [ + "Sphinx==4.5.0", + "sphinx-autobuild", + "sphinx-book-theme", + "sphinxcontrib-bibtex<2.0.0", # https://github.com/executablebooks/jupyter-book/issues/1137 + "sphinx-copybutton", + "sphinx-panels", + "sphinx-thebe", + "sphinx-togglebutton", + "sphinxemoji", + "ablog", + "docutils==0.16", # 0.17 causes error. https://github.com/executablebooks/MyST-Parser/issues/343 + "pydata_sphinx_theme", + "myst-parser", + "myst-nb", + "ipywidgets", + "nbclient", + "plotly<5", + "pandas", + "matplotlib", + "cupy-cuda110", + "numpy", + "scipy", + "scikit-image", +] + +[project.entry-points."console_scripts"] +cucim = "cucim.clara.cli:main" + +[tool.setuptools] +license-files = ["LICENSE"] +# By default, include-package-data is true in pyproject.toml, so you do +# NOT have to specify this line. +include-package-data = true + +[tool.setuptools.packages.find] +where = ["src/cucim"] + +[tool.setuptools.package-data] +mypkg = ["*.pyi", "*.h", "*.cu"] + +[tool.isort] +profile = "black" +force_single_line = false +line_length = 80 +forced_separate = "test_cucim" +force_grid_wrap = 0 +multi_line_output = 3 +order_by_type = true +combine_as_imports = true +include_trailing_comma = true +known_first_party = [ + "cucim", +] +default_section = "THIRDPARTY" +sections = [ + "FUTURE", + "STDLIB", + "THIRDPARTY", + "FIRSTPARTY", + "LOCALFOLDER", +] +skip = [ + "3rdparty", + "thirdparty", + ".eggs", + ".git", + ".hg", + ".mypy_cache", + ".tox", + ".venv", + "ci", + "cpp", + "_build", + "build", + "build-debug", + "build-release", + "_deps", + "dist", +] + +[tool.pytest.ini_options] +# If a pytest section is found in one of the possible config files +# (pytest.ini, tox.ini or setup.cfg), then pytest will not look for any others, +# so if you add a pytest config section elsewhere, +# you will need to delete this section from setup.cfg. +norecursedirs = "migrations" +python_files = [ + "test_*.py", + "*_test.py", + "tests.py", +] +addopts = [ + "-ra", + "--strict-markers", + # --doctest-modules", + # --doctest-glob=\*.rst", + "--tb=short", + "--ignore-glob=build*", +] +testpaths = [ + "src", + "tests", +] + +[tool.ruff] +# see: https://docs.astral.sh/ruff/rules/ +select = ["E", "F", "W"] +fixable = ["ALL"] +exclude = [ + # TODO: Remove this in a follow-up where we fix __all__. + ".tox", + ".eggs", + "ci/templates", + "build", + "dist", + ".git", + "__pycache__", + "doc/conf.py", + "doc/sphinxext", + "__init__.py", +] +line-length = 80 + +[tool.ruff.per-file-ignores] +# "src/cucim/skimage/util/tests/test_shape.py" = ["E201", "E202"] + +[tool.black] +line-length = 80 +target-version = ["py39"] +include = '\.py?$' +exclude = ''' +/( + 3rdparty | + thirdparty | + \.eggs | + \.git | + \.hg | + \.mypy_cache | + \.tox | + \.venv | + _build | + _deps | + cpp | + ci | + build | + build-debug | + build-release | + dist | + docker | + docs | +)/ +''' + +[tool.codespell] +# note: pre-commit passes explicit lists of files here, which this skip file list doesn't override - +# this is only to allow you to run codespell interactively +# e.g. via +# codespell --toml python/cucim/pyproject.toml . -i 3 -w +skip = "build*,dist,.cache,html,_build,_deps,3rdparty,_static,generated,latex,.git,*.ipynb,test_data/input/LICENSE-3rdparty,jitify_testing" +# ignore-regex = "" +ignore-words-list = "ans,coo,boun,bui,gool,hart,lond,nd,paeth,unser,wronly" +quiet-level = 3 + +# to undo: ./test_data/input/LICENSE-3rdparty diff --git a/python/cucim/pyproject_.toml b/python/cucim/pyproject_.toml deleted file mode 100644 index c5351f058..000000000 --- a/python/cucim/pyproject_.toml +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. -# See file LICENSE for terms. - -[tool.isort] -profile = "black" -force_single_line = false -line_length = 80 -forced_separate = "test_cucim" -force_grid_wrap = 0 -multi_line_output = 3 -order_by_type = true -combine_as_imports = true -include_trailing_comma = true -known_first_party = [ - "cucim", -] -default_section = "THIRDPARTY" -sections = [ - "FUTURE", - "STDLIB", - "THIRDPARTY", - "FIRSTPARTY", - "LOCALFOLDER", -] -skip = [ - "3rdparty", - "thirdparty", - ".eggs", - ".git", - ".hg", - ".mypy_cache", - ".tox", - ".venv", - "ci", - "cpp", - "_build", - "build", - "build-debug", - "build-release", - "_deps", - "dist", -] - -[tool.pytest.ini_options] -# If a pytest section is found in one of the possible config files -# (pytest.ini, tox.ini or setup.cfg), then pytest will not look for any others, -# so if you add a pytest config section elsewhere, -# you will need to delete this section from setup.cfg. -norecursedirs = "migrations" -python_files = [ - "test_*.py", - "*_test.py", - "tests.py", -] -addopts = [ - "-ra", - "--strict-markers", - # --doctest-modules", - # --doctest-glob=\*.rst", - "--tb=short", - "--ignore-glob=build*", -] -testpaths = [ - "src", - "tests", -] - -[tool.ruff] -select = ["E", "F", "W"] -fixable = ["ALL"] -exclude = [ - # TODO: Remove this in a follow-up where we fix __all__. - ".tox", - ".eggs", - "ci/templates", - "build", - "dist", - ".git", - "__pycache__", - "doc/conf.py", - "doc/sphinxext", - "__init__.py", -] -line-length = 80 - -[tool.ruff.per-file-ignores] -# "src/cucim/skimage/util/tests/test_shape.py" = ["E201", "E202"] - -[tool.black] -line-length = 80 -target-version = ["py39"] -include = '\.py?$' -exclude = ''' -/( - 3rdparty | - thirdparty | - \.eggs | - \.git | - \.hg | - \.mypy_cache | - \.tox | - \.venv | - _build | - _deps | - cpp | - ci | - build | - build-debug | - build-release | - dist | - docker | - docs | -)/ -''' - -[tool.setuptools] -license-files = ["LICENSE"] - -[tool.codespell] -# note: pre-commit passes explicit lists of files here, which this skip file list doesn't override - -# this is only to allow you to run codespell interactively -# e.g. via -# codespell --toml python/cucim/pyproject.toml . -i 3 -w -skip = "build*,dist,.cache,html,_build,_deps,3rdparty,_static,generated,latex,.git,*.ipynb,test_data/input/LICENSE-3rdparty,jitify_testing" -# ignore-regex = "" -ignore-words-list = "ans,coo,boun,bui,gool,hart,lond,nd,paeth,unser,wronly" -quiet-level = 3 - -# to undo: ./test_data/input/LICENSE-3rdparty diff --git a/python/cucim/setup.py b/python/cucim/setup.py deleted file mode 100755 index ad6b05600..000000000 --- a/python/cucim/setup.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -import io -import sys -from os.path import dirname, join - -from setuptools import find_packages, setup - -# Give setuptools a hint to complain if it's too old a version -# 24.2.0 added the python_requires option -# Should match pyproject.toml -SETUP_REQUIRES = ["setuptools >= 24.2.0"] -# This enables setuptools to install wheel on-the-fly -SETUP_REQUIRES += ["wheel"] if "bdist_wheel" in sys.argv else [] - - -def read(*names, **kwargs): - with io.open( - join(dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8") - ) as fh: - return fh.read() - - -opts = dict( - name="cucim", - version=read("VERSION").strip(), - license="Apache-2.0", - description="cuCIM - an extensible toolkit designed to provide GPU accelerated I/O, computer vision & image processing primitives for N-Dimensional images with a focus on biomedical imaging.", # noqa - long_description="%s\n%s" % (read("README.md"), read("CHANGELOG.md")), - long_description_content_type="text/markdown", - author="NVIDIA Corporation", - url="https://developer.nvidia.com/multidimensional-image-processing", - packages=find_packages("src"), - package_dir={"cucim": "src/cucim"}, - package_data={"": ["*.pyi", "*.h", "*.cu"]}, - include_package_data=True, - zip_safe=False, - classifiers=[ - # complete classifier list: - # http://pypi.python.org/pypi?%3Aaction=list_classifiers - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Intended Audience :: Education", - "Intended Audience :: Science/Research", - "Intended Audience :: Healthcare Industry", - "Operating System :: POSIX :: Linux", - "Environment :: Console", - "Environment :: GPU :: NVIDIA CUDA :: 11.0", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: C++", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - # 'Operating System :: OS Independent', - # 'Operating System :: Unix', - # 'Operating System :: POSIX', - # 'Operating System :: Microsoft :: Windows', - # 'Programming Language :: Python :: Implementation :: CPython', - # uncomment if you test on these interpreters: - # 'Programming Language :: Python :: Implementation :: PyPy', - # 'Programming Language :: Python :: Implementation :: IronPython', - # 'Programming Language :: Python :: Implementation :: Jython', - # 'Programming Language :: Python :: Implementation :: Stackless', - "Topic :: Scientific/Engineering :: Image Processing", - ], - project_urls={ - "Source": "https://github.com/rapidsai/cucim", - "Documentation": "https://docs.rapids.ai/api/cucim/stable/", - "Changelog": "https://github.com/rapidsai/cucim/blob/main/CHANGELOG.md", - "Issue Tracker": "https://github.com/rapidsai/cucim/issues", - }, - keywords=[ - # eg: 'keyword1', 'keyword2', 'keyword3', - ], - python_requires=">= 3.6", - platforms=["manylinux2014_x86_64"], - setup_requires=SETUP_REQUIRES, - install_requires=[ - # TODO: Check cupy dependency based on cuda version - "click", - "numpy", - "lazy_loader>=0.1", # 'scipy', 'scikit-image' - # eg: 'aspectlib==1.1.1', 'six>=1.7', - ], - extras_require={ - # eg: - # 'rst': ['docutils>=0.11'], - # ':python_version=="2.6"': ['argparse'], - }, - entry_points={ - "console_scripts": [ - "cucim = cucim.clara.cli:main", - ] - }, -) - -if __name__ == "__main__": - setup(**opts) diff --git a/run b/run index a70dfe891..862dd74f5 100755 --- a/run +++ b/run @@ -744,17 +744,19 @@ build_python_package_() { rm -rf ${SRC_ROOT}/python/cucim/build # Compile wheels (one python binary is enough) pybins="$(echo /opt/python/*/bin)" - [ ! -e /opt/python/cp36-cp36m/bin ] && pybins="$(dirname $(which python3))" # for building at host + [ ! -e /opt/python/cp39-cp39/bin ] && pybins="$(dirname $(which python3))" # for building at host pybins="$(echo /opt/python/*/bin)" if [ "${pybins}" = "/opt/python/*/bin" ]; then # if multiple python binaries not found pybins="$(dirname $(which python3))" # for building at host else - pybins=/opt/python/cp36-cp36m/bin # use Python 3.6 for executing setup.py + pybins=/opt/python/cp39-cp39/bin # use Python 3.9 for executing `pip wheel` fi for PYBIN in ${pybins}; do # /opt/python/*/bin - run_command "${PYBIN}/python3" setup.py bdist_wheel -p $PLAT -d ${TEMP_PYPKG_DIR} + # run_command "${PYBIN}/python3" setup.py bdist_wheel -p $PLAT -d ${TEMP_PYPKG_DIR} + # no pip equivalent of -p for platform? + run_command "${PYBIN}/python3" -m pip wheel . --wheel-dir ${TEMP_PYPKG_DIR} done # Do not bundle external shared libraries for now.