Skip to content

Commit

Permalink
Migrate as much as possible to pyproject.toml (rapidsai#1324)
Browse files Browse the repository at this point in the history
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: rapidsai#1324
  • Loading branch information
vyasr authored and lowener committed Mar 15, 2023
1 parent 5f497bd commit e030e87
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 117 deletions.
23 changes: 10 additions & 13 deletions ci/release/apply_wheel_modifications.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 7 additions & 9 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions python/pylibraft/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions python/pylibraft/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 0 additions & 45 deletions python/pylibraft/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
)
7 changes: 7 additions & 0 deletions python/raft-dask/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions python/raft-dask/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions python/raft-dask/setup.cfg

This file was deleted.

45 changes: 0 additions & 45 deletions python/raft-dask/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
)

0 comments on commit e030e87

Please sign in to comment.