From f8708e14e229fbe44945d92794d181f932aafc17 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 13 Mar 2023 20:30:40 -0400 Subject: [PATCH] Migrate as much as possible to pyproject.toml (#1324) This moves as much packaging information and linter configuration out of setup.[py|cfg] files into pyproject.toml with the aim of migrating to more modern Python builders in the future. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Ben Frederickson (https://github.com/benfred) - Joseph (https://github.com/jolorunyomi) URL: https://github.com/rapidsai/raft/pull/1324 --- ci/release/apply_wheel_modifications.sh | 23 ++++++------- ci/release/update-version.sh | 16 ++++----- python/pylibraft/MANIFEST.in | 7 ++++ python/pylibraft/pyproject.toml | 36 ++++++++++++++++++++ python/pylibraft/setup.py | 45 ------------------------- python/raft-dask/MANIFEST.in | 7 ++++ python/raft-dask/pyproject.toml | 40 ++++++++++++++++++++++ python/raft-dask/setup.cfg | 5 --- python/raft-dask/setup.py | 45 ------------------------- 9 files changed, 107 insertions(+), 117 deletions(-) create mode 100644 python/pylibraft/MANIFEST.in create mode 100644 python/raft-dask/MANIFEST.in delete mode 100644 python/raft-dask/setup.cfg diff --git a/ci/release/apply_wheel_modifications.sh b/ci/release/apply_wheel_modifications.sh index 410bcc5577..ed3d2a15fd 100755 --- a/ci/release/apply_wheel_modifications.sh +++ b/ci/release/apply_wheel_modifications.sh @@ -10,18 +10,15 @@ CUDA_SUFFIX=${2} sed -i "s/__version__ = .*/__version__ = \"${VERSION}\"/g" python/pylibraft/pylibraft/__init__.py sed -i "s/__version__ = .*/__version__ = \"${VERSION}\"/g" python/raft-dask/raft_dask/__init__.py -# setup.py versions -sed -i "s/version=.*,/version=\"${VERSION}\",/g" python/pylibraft/pylibraft/__init__.py -sed -i "s/version=.*,/version=\"${VERSION}\",/g" python/raft-dask/raft_dask/__init__.py +# pyproject.toml versions +sed -i "s/^version = .*/version = \"${VERSION}\"/g" python/pylibraft/pyproject.toml +sed -i "s/^version = .*/version = \"${VERSION}\"/g" python/raft-dask/pyproject.toml -# pylibraft setup.py cuda suffixes -sed -i "s/name=\"pylibraft\"/name=\"pylibraft${CUDA_SUFFIX}\"/g" python/pylibraft/setup.py -sed -i "s/rmm/rmm${CUDA_SUFFIX}/g" python/pylibraft/setup.py - -# raft-dask setup.py cuda suffixes -sed -i "s/name=\"raft-dask\"/name=\"raft-dask${CUDA_SUFFIX}\"/g" python/raft-dask/setup.py -sed -i "s/ucx-py/ucx-py${CUDA_SUFFIX}/g" python/raft-dask/setup.py -sed -i "s/pylibraft/pylibraft${CUDA_SUFFIX}/g" python/raft-dask/setup.py - -# Dependency versions in pyproject.toml +# pylibraft pyproject.toml cuda suffixes +sed -i "s/^name = \"pylibraft\"/name = \"pylibraft${CUDA_SUFFIX}\"/g" python/pylibraft/pyproject.toml sed -i "s/rmm/rmm${CUDA_SUFFIX}/g" python/pylibraft/pyproject.toml + +# raft-dask pyproject.toml cuda suffixes +sed -i "s/^name = \"raft-dask\"/name = \"raft-dask${CUDA_SUFFIX}\"/g" python/raft-dask/pyproject.toml +sed -i "s/pylibraft/pylibraft${CUDA_SUFFIX}/g" python/raft-dask/pyproject.toml +sed -i "s/ucx-py/ucx-py${CUDA_SUFFIX}/g" python/raft-dask/pyproject.toml diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index b9afd2674d..d8c22b4931 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -42,9 +42,9 @@ sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cma sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/pylibraft/pylibraft/__init__.py sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/raft-dask/raft_dask/__init__.py -# Python setup.py updates -sed_runner "s/version=.*,/version=\"${NEXT_FULL_TAG}\",/g" python/pylibraft/pylibraft/__init__.py -sed_runner "s/version=.*,/version=\"${NEXT_FULL_TAG}\",/g" python/raft-dask/raft_dask/__init__.py +# Python pyproject.toml updates +sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/pylibraft/pyproject.toml +sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/raft-dask/pyproject.toml # Docs update sed_runner 's/version = .*/version = '"'${NEXT_SHORT_TAG}'"'/g' docs/source/conf.py @@ -70,15 +70,13 @@ done NEXT_SHORT_TAG_PEP440=$(python -c "from setuptools.extern import packaging; print(packaging.version.Version('${NEXT_SHORT_TAG}'))") NEXT_UCX_PY_SHORT_TAG_PEP440=$(python -c "from setuptools.extern import packaging; print(packaging.version.Version('${NEXT_UCX_PY_SHORT_TAG}'))") -# Wheel builds install intra-RAPIDS dependencies from same release -sed_runner "s/{cuda_suffix}[^\"].*\",/{cuda_suffix}==${NEXT_SHORT_TAG_PEP440}.*\",/g" python/pylibraft/setup.py -sed_runner "s/dask-cuda==.*\",/dask-cuda==${NEXT_SHORT_TAG_PEP440}.*\",/g" python/raft-dask/setup.py -sed_runner "s/pylibraft{cuda_suffix}.*\",/pylibraft{cuda_suffix}==${NEXT_SHORT_TAG_PEP440}.*\",/g" python/raft-dask/setup.py -sed_runner "s/ucx-py{cuda_suffix}.*\",/ucx-py{cuda_suffix}==${NEXT_UCX_PY_SHORT_TAG_PEP440}.*\",/g" python/raft-dask/setup.py - # Dependency versions in pyproject.toml sed_runner "s/rmm==.*\",/rmm==${NEXT_SHORT_TAG_PEP440}.*\",/g" python/pylibraft/pyproject.toml +sed_runner "s/pylibraft==.*\",/pylibraft==${NEXT_SHORT_TAG_PEP440}.*\",/g" python/raft-dask/pyproject.toml +sed_runner "s/dask-cuda==.*\",/dask-cuda==${NEXT_SHORT_TAG_PEP440}.*\",/g" python/raft-dask/pyproject.toml +sed_runner "s/ucx-py.*\",/ucx-py==${NEXT_UCX_PY_SHORT_TAG_PEP440}.*\",/g" python/raft-dask/pyproject.toml + for FILE in .github/workflows/*.yaml; do sed_runner "/shared-action-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}" done diff --git a/python/pylibraft/MANIFEST.in b/python/pylibraft/MANIFEST.in new file mode 100644 index 0000000000..761f403b54 --- /dev/null +++ b/python/pylibraft/MANIFEST.in @@ -0,0 +1,7 @@ +# Cython files +recursive-include pylibraft *.pxd +recursive-include pylibraft *.pyx + +# Build files. Don't use a recursive include on '.' in case the repo is dirty +include . CMakeLists.txt +recursive-include pylibraft CMakeLists.txt diff --git a/python/pylibraft/pyproject.toml b/python/pylibraft/pyproject.toml index c8cf252d0a..7d92fd0763 100644 --- a/python/pylibraft/pyproject.toml +++ b/python/pylibraft/pyproject.toml @@ -26,6 +26,42 @@ requires = [ ] build-backend = "setuptools.build_meta" +[project] +name = "pylibraft" +version = "23.04.00" +description = "RAFT: Reusable Algorithms Functions and other Tools" +readme = { file = "README.md", content-type = "text/markdown" } +authors = [ + { name = "NVIDIA Corporation" }, +] +license = { text = "Apache 2.0" } +requires-python = ">=3.8" +dependencies = [ + "numpy", + "cuda-python>=11.7.1,<12.0", + "rmm==23.4.*", +] +classifiers = [ + "Intended Audience :: Developers", + "Programming Language :: Python", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.10", +] + +[project.optional-dependencies] +test = [ + "pytest", + "scipy", + "scikit-learn", +] + +[project.urls] +Homepage = "https://github.com/rapidsai/raft" +Documentation = "https://docs.rapids.ai/api/raft/stable/" + +[tool.setuptools] +license-files = ["LICENSE"] + [tool.isort] line_length = 79 multi_line_output = 3 diff --git a/python/pylibraft/setup.py b/python/pylibraft/setup.py index 5a6cede641..d00e36d804 100644 --- a/python/pylibraft/setup.py +++ b/python/pylibraft/setup.py @@ -17,20 +17,6 @@ from setuptools import find_packages from skbuild import setup -install_requires = [ - "numpy", - "cuda-python>=11.7.1,<12.0", - "rmm==23.4.*", -] - -extras_require = { - "test": [ - "pytest", - "scipy", - "scikit-learn", - ] -} - def exclude_libcxx_symlink(cmake_manifest): return list( @@ -42,40 +28,9 @@ def exclude_libcxx_symlink(cmake_manifest): setup( - name="pylibraft", - description="RAFT: Reusable Algorithms Functions and other Tools", - version="23.04.00", - classifiers=[ - "Intended Audience :: Developers", - "Programming Language :: Python", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - ], - author="NVIDIA Corporation", include_package_data=True, - package_data={ - # Note: A dict comprehension with an explicit copy is necessary - # (rather than something simpler like a dict.fromkeys) because - # otherwise every package will refer to the same list and skbuild - # modifies it in place. - key: ["*.hpp", "*.pxd"] - for key in find_packages( - include=[ - "pylibraft.distance", - "pylibraft.distance.includes", - "pylibraft.common", - "pylibraft.common.includes", - "pylibraft.random", - "pylibraft.random.includes", - ] - ) - }, - install_requires=install_requires, - extras_require=extras_require, # Don't want libcxx getting pulled into wheel builds. cmake_process_manifest_hook=exclude_libcxx_symlink, packages=find_packages(include=["pylibraft", "pylibraft.*"]), - license="Apache 2.0", zip_safe=False, ) diff --git a/python/raft-dask/MANIFEST.in b/python/raft-dask/MANIFEST.in new file mode 100644 index 0000000000..f160a731e9 --- /dev/null +++ b/python/raft-dask/MANIFEST.in @@ -0,0 +1,7 @@ +# Cython files +recursive-include raft-dask *.pxd +recursive-include raft-dask *.pyx + +# Build files. Don't use a recursive include on '.' in case the repo is dirty +include . CMakeLists.txt +recursive-include raft-dask CMakeLists.txt diff --git a/python/raft-dask/pyproject.toml b/python/raft-dask/pyproject.toml index 947a0677ed..2fe6522f57 100644 --- a/python/raft-dask/pyproject.toml +++ b/python/raft-dask/pyproject.toml @@ -23,6 +23,46 @@ requires = [ "ninja", ] +[project] +name = "raft-dask" +version = "23.04.00" +description = "Reusable Accelerated Functions & Tools Dask Infrastructure" +readme = { file = "README.md", content-type = "text/markdown" } +authors = [ + { name = "NVIDIA Corporation" }, +] +license = { text = "Apache 2.0" } +requires-python = ">=3.8" +dependencies = [ + "numpy", + "numba>=0.49", + "joblib>=0.11", + "dask-cuda==23.4.*", + "dask>=2023.1.1", + "ucx-py==0.31.*", + "distributed>=2023.1.1", + "pylibraft==23.4.*", +] +classifiers = [ + "Intended Audience :: Developers", + "Programming Language :: Python", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.10", +] + +[project.optional-dependencies] +test = [ + "pytest", + "dask[distributed,dataframe]", +] + +[project.urls] +Homepage = "https://github.com/rapidsai/raft" +Documentation = "https://docs.rapids.ai/api/raft/stable/" + +[tool.setuptools] +license-files = ["LICENSE"] + [tool.isort] line_length = 79 multi_line_output = 3 diff --git a/python/raft-dask/setup.cfg b/python/raft-dask/setup.cfg deleted file mode 100644 index 41e4ad8574..0000000000 --- a/python/raft-dask/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright (c) 2020-2023, NVIDIA CORPORATION. - -[options] -packages = find: -python_requires = >=3.8,<3.11 diff --git a/python/raft-dask/setup.py b/python/raft-dask/setup.py index 66fcf78abc..c9215e96e6 100644 --- a/python/raft-dask/setup.py +++ b/python/raft-dask/setup.py @@ -17,24 +17,6 @@ from setuptools import find_packages from skbuild import setup -install_requires = [ - "numpy", - "numba>=0.49", - "joblib>=0.11", - "dask-cuda==23.4.*", - "dask>=2023.1.1", - "ucx-py==0.31.*", - "distributed>=2023.1.1", - "pylibraft==23.4.*", -] - -extras_require = { - "test": [ - "pytest", - "dask[distributed,dataframe]", - ] -} - def exclude_libcxx_symlink(cmake_manifest): return list( @@ -46,35 +28,8 @@ def exclude_libcxx_symlink(cmake_manifest): setup( - name="raft-dask", - description="Reusable Accelerated Functions & Tools Dask Infrastructure", - version="23.04.00", - classifiers=[ - "Intended Audience :: Developers", - "Programming Language :: Python", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - ], - author="NVIDIA Corporation", include_package_data=True, - package_data={ - # Note: A dict comprehension with an explicit copy is necessary - # (rather than something simpler like a dict.fromkeys) because - # otherwise every package will refer to the same list and skbuild - # modifies it in place. - key: ["*.hpp", "*.pxd"] - for key in find_packages( - include=[ - "raft_dask.common", - "raft_dask.common.includes", - ] - ) - }, - install_requires=install_requires, - extras_require=extras_require, cmake_process_manifest_hook=exclude_libcxx_symlink, packages=find_packages(include=["raft_dask", "raft_dask.*"]), - license="Apache 2.0", zip_safe=False, )