Skip to content

Commit

Permalink
Migrate from setup.cfg to pyproject.toml (#48)
Browse files Browse the repository at this point in the history
* Migrate project metadata from setup.py to pyproject.toml

Define project metadata in pyproject.toml! Required dependencies are now listed under the [project] section instead of in requirements.txt. Versioneer config has also been moved from setup.cfg to [tool.versioneer].

* Fix check on sdist version number

Package name is cupy_xarray, not cupy-xarray.

* Include optional test dependencies in pyproject.toml

Remove requirements_test.txt file, moving the test dependencies to pyproject.toml instead. Also updated MANIFEST.in to remove the requirements.txt entry.

* Keep setup.py with versioneer.get_version() and .get_cmdclass()

Still need these two lines so that the sdist won't have a 0.0.0 version. Xref https://github.com/python-versioneer/python-versioneer/blob/0.29/INSTALL.md#common-steps
  • Loading branch information
weiji14 authored Jun 28, 2024
1 parent 791c62d commit 167945e
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pypi-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
run: |
python -m twine check dist/*
pwd
if [ -f dist/cupy-xarray-0.0.0.tar.gz ]; then
if [ -f dist/cupy_xarray-0.0.0.tar.gz ]; then
echo "❌ INVALID VERSION NUMBER"
exit 1
else
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
include versioneer.py
include cupy_xarray/_version.py
include requirements.txt
include LICENSE
include README.md
include pyproject.toml
prune cupy_xarray/tests*


recursive-exclude * __pycache__
recursive-exclude * *.py[co]
35 changes: 35 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
[build-system]
requires = ["setuptools", "versioneer[toml]"]
build-backend = "setuptools.build_meta"

[project]
name = "cupy-xarray"
description = "Interface for using cupy in xarray, providing convenience accessors."
authors = [{name = "cupy-xarray developers"}]
license = {text = "Apache License"}
readme = "README.md"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]
dynamic = ["version"]
dependencies = [
"cupy",
"xarray>=2024.02.0",
]

[project.optional-dependencies]
test = [
"dask",
"pytest",
]

[tool.ruff]
line-length = 100 # E501 (line-too-long)
exclude = [
Expand All @@ -17,3 +44,11 @@ select = [
"SIM", # flake8-simplify
"W", # pycodestyle warnings
]

[tool.versioneer]
VCS = "git"
style = "pep440"
versionfile_source = "cupy_xarray/_version.py"
versionfile_build = "cupy_xarray/_version.py"
tag_prefix = ""
parentdir_prefix = ""
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements_test.txt

This file was deleted.

7 changes: 0 additions & 7 deletions setup.cfg

This file was deleted.

26 changes: 5 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,8 @@

import versioneer

with open("README.md", encoding="utf-8") as fh:
long_description = fh.read()
with open("requirements.txt") as fh:
requirements = [line.strip() for line in fh]

setuptools.setup(
name="cupy-xarray",
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
author="cupy-xarray developers",
description="Interface for using cupy in xarray, providing convenience accessors.",
long_description=long_description,
long_description_content_type="text/markdown",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
python_requires=">=3.7",
install_requires=requirements,
)
if __name__ == "__main__":
setuptools.setup(
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
)

0 comments on commit 167945e

Please sign in to comment.