From 0c67c6183f6678c99cfe7620456ea9d8279d9d8b Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sun, 20 Mar 2022 22:45:32 +0800 Subject: [PATCH 01/11] Migrate project metadata from setup.py to pyproject.toml following PEP621 --- pyproject.toml | 39 +++++++++++++++++++++++++++++++- setup.py | 60 ++------------------------------------------------ 2 files changed, 40 insertions(+), 59 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d470afe6d9b..2a5955f7e0b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,44 @@ [build-system] -requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"] +requires = ["setuptools>=61", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" +[project] +name = "pygmt" +description = "A Python interface for the Generic Mapping Tools" +readme = "README.rst" +requires-python = ">=3.8" +license = {text = "BSD License"} +authors = [{name = "The PyGMT Developers", email = "leouieda@gmail.com"}] +maintainers = [{name = "The PyGMT Developers", email = "leouieda@gmail.com"}] +keywords = [] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Science/Research", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Topic :: Scientific/Engineering", + "Topic :: Software Development :: Libraries", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "License :: OSI Approved :: BSD License", +] +dependencies = ["numpy>=1.19", "pandas", "xarray", "netCDF4", "packaging"] +dynamic = ["version"] + +[project.urls] +homepage = "https://www.pygmt.org" +documentation = "https://www.pygmt.org" +repository = "https://github.com/GenericMappingTools/pygmt" +changelog = "https://www.pygmt.org/latest/changes.html" + +[tool.setuptools] +platforms = ["Any"] + +[tool.setuptools.packages.find] +include = ["pygmt*"] +exclude = ["doc"] + [tool.setuptools_scm] local_scheme = "node-and-date" fallback_version = "unknown" diff --git a/setup.py b/setup.py index a7815ccd7da..606849326a4 100644 --- a/setup.py +++ b/setup.py @@ -1,59 +1,3 @@ -""" -Build and install the project. -""" -from setuptools import find_packages, setup +from setuptools import setup -NAME = "pygmt" -FULLNAME = "PyGMT" -AUTHOR = "The PyGMT Developers" -AUTHOR_EMAIL = "leouieda@gmail.com" -MAINTAINER = AUTHOR -MAINTAINER_EMAIL = AUTHOR_EMAIL -LICENSE = "BSD License" -URL = "https://github.com/GenericMappingTools/pygmt" -DESCRIPTION = "A Python interface for the Generic Mapping Tools" -KEYWORDS = "" -with open("README.rst", "r", encoding="utf8") as f: - LONG_DESCRIPTION = "".join(f.readlines()) - -PACKAGES = find_packages(exclude=["doc"]) -SCRIPTS = [] -PACKAGE_DATA = {"pygmt.tests": ["data/*", "baseline/*"]} - -CLASSIFIERS = [ - "Development Status :: 4 - Beta", - "Intended Audience :: Science/Research", - "Intended Audience :: Developers", - "Intended Audience :: Education", - "Topic :: Scientific/Engineering", - "Topic :: Software Development :: Libraries", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - f"License :: OSI Approved :: {LICENSE}", -] -PLATFORMS = "Any" -PYTHON_REQUIRES = ">=3.8" -INSTALL_REQUIRES = ["numpy>=1.19", "pandas", "xarray", "netCDF4", "packaging"] - -if __name__ == "__main__": - setup( - name=NAME, - fullname=FULLNAME, - description=DESCRIPTION, - long_description=LONG_DESCRIPTION, - author=AUTHOR, - author_email=AUTHOR_EMAIL, - maintainer=MAINTAINER, - maintainer_email=MAINTAINER_EMAIL, - license=LICENSE, - url=URL, - platforms=PLATFORMS, - scripts=SCRIPTS, - packages=PACKAGES, - package_data=PACKAGE_DATA, - classifiers=CLASSIFIERS, - keywords=KEYWORDS, - python_requires=PYTHON_REQUIRES, - install_requires=INSTALL_REQUIRES, - ) +setup() From 7cff590829d014d7df846019e2dc1485147f9801 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sun, 27 Mar 2022 23:44:32 +0800 Subject: [PATCH 02/11] Add docstrings to setup.py --- setup.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/setup.py b/setup.py index 606849326a4..055963d05a4 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,10 @@ +""" +A simple setup.py script to support editable installs. +""" +# References: +# - https://github.com/pypa/setuptools/issues/2816 +# - https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html + from setuptools import setup setup() From cc9d8e0d23de4f888a7c17466572d21639b4fd02 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 29 Mar 2022 09:42:26 +0800 Subject: [PATCH 03/11] Use the new email address for pygmt team --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2a5955f7e0b..a61e299904b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,8 +8,8 @@ description = "A Python interface for the Generic Mapping Tools" readme = "README.rst" requires-python = ">=3.8" license = {text = "BSD License"} -authors = [{name = "The PyGMT Developers", email = "leouieda@gmail.com"}] -maintainers = [{name = "The PyGMT Developers", email = "leouieda@gmail.com"}] +authors = [{name = "The PyGMT Developers", email = "pygmt.team@gmail.com"}] +maintainers = [{name = "The PyGMT Developers", email = "pygmt.team@gmail.com"}] keywords = [] classifiers = [ "Development Status :: 4 - Beta", From 033d369c9c702aea5798587a45a932dbd2afafda Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 1 Apr 2022 21:22:48 +0800 Subject: [PATCH 04/11] Update the link for development mode --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 055963d05a4..4a38730163c 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ """ # References: # - https://github.com/pypa/setuptools/issues/2816 -# - https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html +# - https://setuptools.pypa.io/en/latest/userguide/quickstart.html#development-mode from setuptools import setup From f6bf6f6be22079dbf274fae8ab52f47180130257 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 1 Apr 2022 21:24:00 +0800 Subject: [PATCH 05/11] Set include-package-data to include baseline and data files --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index a61e299904b..d7bd1b511d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ changelog = "https://www.pygmt.org/latest/changes.html" [tool.setuptools] platforms = ["Any"] +include-package-data = true [tool.setuptools.packages.find] include = ["pygmt*"] From cfc20a706ae2c89e6e1e3bfc71d483406c7b3654 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 11 Aug 2022 22:33:07 -0700 Subject: [PATCH 06/11] Remove setup.py completely. Requires setuptools>=64.0.0 --- Makefile | 8 ++++---- doc/maintenance.md | 2 +- pyproject.toml | 2 +- setup.py | 10 ---------- 4 files changed, 6 insertions(+), 16 deletions(-) delete mode 100644 setup.py diff --git a/Makefile b/Makefile index 30b78c92093..4fb1c9d6a11 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,12 @@ TESTDIR=tmp-test-dir-with-unique-name PYTEST_COV_ARGS=--cov=$(PROJECT) --cov-config=../pyproject.toml \ --cov-report=term-missing --cov-report=xml --cov-report=html \ --pyargs ${PYTEST_EXTRA} -BLACK_FILES=$(PROJECT) setup.py doc/conf.py examples +BLACK_FILES=$(PROJECT) doc/conf.py examples BLACKDOC_OPTIONS=--line-length 79 -DOCFORMATTER_FILES=$(PROJECT) setup.py doc/conf.py examples +DOCFORMATTER_FILES=$(PROJECT) doc/conf.py examples DOCFORMATTER_OPTIONS=--recursive --pre-summary-newline --make-summary-multi-line --wrap-summaries 79 --wrap-descriptions 79 -FLAKE8_FILES=$(PROJECT) setup.py doc/conf.py examples -LINT_FILES=$(PROJECT) setup.py doc/conf.py +FLAKE8_FILES=$(PROJECT) doc/conf.py examples +LINT_FILES=$(PROJECT) doc/conf.py help: @echo "Commands:" diff --git a/doc/maintenance.md b/doc/maintenance.md index f4202a16b96..7320b7c649e 100644 --- a/doc/maintenance.md +++ b/doc/maintenance.md @@ -167,7 +167,7 @@ alongside the rest of the Scientific Python ecosystem, and therefore supports: * All minor versions of NumPy released in the 24 months prior to the project, and at minimum the last three minor versions. -In `setup.py`, the `python_requires` variable should be set to the minimum +In `pyproject.toml`, the `requires-python` key should be set to the minimum supported version of Python. Minimum Python and NumPy version support should be adjusted upward on every major and minor release, but never on a patch release. diff --git a/pyproject.toml b/pyproject.toml index d6be56c1a72..a0d4f2d0f28 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61", "setuptools_scm[toml]>=6.2"] +requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" [project] diff --git a/setup.py b/setup.py deleted file mode 100644 index 4a38730163c..00000000000 --- a/setup.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -A simple setup.py script to support editable installs. -""" -# References: -# - https://github.com/pypa/setuptools/issues/2816 -# - https://setuptools.pypa.io/en/latest/userguide/quickstart.html#development-mode - -from setuptools import setup - -setup() From f85015ef3e4b69d2dfd6260bc5bb36a834aea478 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 13 Aug 2022 23:03:19 +0800 Subject: [PATCH 07/11] Fix the minimum required numpy version to 1.20 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a0d4f2d0f28..9bda0df1d25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "License :: OSI Approved :: BSD License", ] -dependencies = ["numpy>=1.19", "pandas", "xarray", "netCDF4", "packaging"] +dependencies = ["numpy>=1.20", "pandas", "xarray", "netCDF4", "packaging"] dynamic = ["version"] [project.urls] From f257a361b2ef870b0f9d159835fd5cbac065c5cb Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 13 Aug 2022 23:42:40 +0800 Subject: [PATCH 08/11] Add package data --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 9bda0df1d25..2dfe8327cc8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,9 @@ include-package-data = true include = ["pygmt*"] exclude = ["doc"] +[tool.setuptools.package-data] +tests = ["data/*", "baseline/*"] + [tool.setuptools_scm] local_scheme = "node-and-date" fallback_version = "999.999.999+unknown" From 7553f0b4d28f91cdac2180102c70dca3aa55a341 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 13 Aug 2022 23:54:06 +0800 Subject: [PATCH 09/11] Update the command to check README syntax --- doc/maintenance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/maintenance.md b/doc/maintenance.md index 7320b7c649e..a78784e5bdf 100644 --- a/doc/maintenance.md +++ b/doc/maintenance.md @@ -277,7 +277,7 @@ So slightly broken RST can cause the PyPI page to not render the correct content using the `rst2html.py` script that comes with docutils: ``` -python setup.py --long-description | rst2html.py --no-raw > index.html +rst2html.py --no-raw README.rst > index.html ``` Open `index.html` and check for any flaws or error messages. From 9d9ce070e53508212aa7af843fdf375dc6de30eb Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 18 Aug 2022 13:08:21 +0800 Subject: [PATCH 10/11] Run tests in editable mode --- .github/workflows/ci_tests.yaml | 4 +--- .github/workflows/ci_tests_dev.yaml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 69be6dcf732..de9fdc10152 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -126,9 +126,7 @@ jobs: # Install the package that we want to test - name: Install the package - run: | - python -m build --sdist - pip install dist/* + run: make install # Run the regular tests - name: Run tests diff --git a/.github/workflows/ci_tests_dev.yaml b/.github/workflows/ci_tests_dev.yaml index 2e236e91611..12e339b4383 100644 --- a/.github/workflows/ci_tests_dev.yaml +++ b/.github/workflows/ci_tests_dev.yaml @@ -150,9 +150,7 @@ jobs: # Install the package that we want to test - name: Install the package - run: | - python -m build --sdist - pip install dist/* + run: make install - name: Add GMT's bin to PATH (Linux/macOS) run: echo ${GITHUB_WORKSPACE}/gmt-install-dir/bin >> $GITHUB_PATH From 5f54cc53e4f1b7d68de2ed1bb2ea261bb0386cf6 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 19 Aug 2022 12:37:25 +0800 Subject: [PATCH 11/11] Multi-line dependencies Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pyproject.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2dfe8327cc8..d55e18b1d2f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,13 @@ classifiers = [ "Programming Language :: Python :: 3.10", "License :: OSI Approved :: BSD License", ] -dependencies = ["numpy>=1.20", "pandas", "xarray", "netCDF4", "packaging"] +dependencies = [ + "numpy>=1.20", + "pandas", + "xarray", + "netCDF4", + "packaging" +] dynamic = ["version"] [project.urls]