-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate project metadata from setup.py to pyproject.toml following PEP621 #1848
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @seisman! Just some quick comments for now. There seems to be 166 in CI due to missing baseline images for some reason, is there something missing?
pyproject.toml
Outdated
@@ -1,7 +1,44 @@ | |||
[build-system] | |||
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"] | |||
requires = ["setuptools>=61", "setuptools_scm[toml]>=6.2"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note that changes in this PR require setuptools>=61.
setuptools v61.0.0 was released on Mar. 24, 2022. This version starts to support storing project metadata in pyproject.toml
following PEP621 but it's still experimental and may change in future versions. I think we should not merge this PR unless the pyproject.toml
support is stable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's wait and see first. I've had to pin to setuptools=58.4.0 on one of my projects 3 weeks ago because one of the dependencies didn't like setuptools v60.9. There might be some other packages pinning to a lower setuptools version too.
Having recently gone through all of this, there are 2 options that would work well here:
Either way, getting rid of |
We are also trying to get rid of the
I also noticed
Yes, we have switched to |
Ah right, if keeping setup.cfg is out of the question then it would a matter of waiting until setuptools support is stable. It underpins so many packages that generating conflicts with it will likely be a nightmare. |
setup.py
Outdated
@@ -1,59 +1,10 @@ | |||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setup.py is no longer required since setuptools 64.0.0 (https://setuptools.pypa.io/en/latest/userguide/development_mode.html)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, it seems like setuptools v64.0.0 enabled non setup.py editable installs!
On the developer side, this seems ok to remove setup.py, but are there any potential side effects for users not having such a new setuptools version? Or to put it another way, do we want to remove setup.py for PyGMT v0.8.0, or wait another minor version (e.g. v0.9.0)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there any potential side effects for users not having such a new setuptools version?
I have setuptools 62.6.0 installed. Checking out this branch and running make install
and make package
work well for me.
When running make package
, I see the following messages:
$ make package
python -m build --sdist --wheel
* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools>=64, setuptools_scm[toml]>=6.2)
* Getting dependencies for sdist...
/tmp/build-env-ld441dbo/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*.
warnings.warn(msg, _BetaConfiguration)
running egg_info
writing pygmt.egg-info/PKG-INFO
writing dependency_links to pygmt.egg-info/dependency_links.txt
writing requirements to pygmt.egg-info/requires.txt
writing top-level names to pygmt.egg-info/top_level.txt
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE.txt'
adding license file 'AUTHORS.md'
adding license file 'AUTHORSHIP.md'
writing manifest file 'pygmt.egg-info/SOURCES.txt'
* Building sdist...
/tmp/build-env-ld441dbo/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*.
warnings.warn(msg, _BetaConfiguration)
running sdist
running egg_info
writing pygmt.egg-info/PKG-INFO
writing dependency_links to pygmt.egg-info/dependency_links.txt
writing requirements to pygmt.egg-info/requires.txt
writing top-level names to pygmt.egg-info/top_level.txt
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE.txt'
adding license file 'AUTHORS.md'
adding license file 'AUTHORSHIP.md'
writing manifest file 'pygmt.egg-info/SOURCES.txt'
running check
...
It seems build dependencies like setuptools>=64 are automatically installed in isolated environments and do not affect users' installations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A downside here is that make install
no longer works without internet access, even if setuptools>=64 is installed in the environment. I'll do some more searching for a workaround but if anyone knows a solution that would be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried disconnecting and used pip install --no-deps --no-build-isolation --editable=.
which seems to work offline (presumably it manages to pick up a pre-downloaded setuptools>=64
). However, it results in a editable version named pygmt-0.0.0
. Maybe the offline feature can be raised upstream to PyPA?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A downside here is that
make install
no longer works without internet access, even if setuptools>=64 is installed in the environment.
It's unrelated to this PR. Offline make install
worked for pygmt<=0.2.0 and started to fail since v0.3.0, in which we switched from versioneer to setuptools_scm (https://www.pygmt.org/dev/changes.html#id47). So it's likely a problem for setuptools_scm.
I tried disconnecting and used
pip install --no-deps --no-build-isolation --editable=.
which seems to work offline (presumably it manages to pick up a pre-downloadedsetuptools>=64
). However, it results in a editable version namedpygmt-0.0.0
.
This command gives the correct version for pygmt <= 0.6.0 but results in pygmt-0.0.0
for pygmt v0.7.0. Not sure if it's caused by changes in #1945.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maxrjones Perhaps open an issue report for the offline pip
issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opened a PR in #2097.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening the issue @seisman. Apologies for not responding to your question. I had originally interpreted your comment as opening an issue in the PyPA repo and wanted to do more debugging before taking that step.
That's because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, keeping PyGMT nice and modern 😃 Just some very minor suggestions, otherwise looks good to me.
pyproject.toml
Outdated
"Programming Language :: Python :: 3.10", | ||
"License :: OSI Approved :: BSD License", | ||
] | ||
dependencies = ["numpy>=1.20", "pandas", "xarray", "netCDF4", "packaging"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking of whether to declare optional dependencies (https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#dependencies-optional-dependencies). Maybe do in a separate PR.
Motivation would be to enable something like pip install pygmt[all]
that includes dependencies like geopandas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened a PR #2069 for it.
Co-authored-by: Wei Ji <[email protected]>
…P621 (GenericMappingTools#1848) Delete setup.py and move all project metadata to pyproject.toml as per https://peps.python.org/pep-0621. * Migrate project metadata from setup.py to pyproject.toml following PEP621 * Add docstrings to setup.py * Use the new email address for pygmt team * Update the link for development mode * Set include-package-data to include baseline and data files * Remove setup.py completely. Requires setuptools>=64.0.0 * Fix the minimum required numpy version to 1.20 * Add package data * Update the command to check README syntax * Run tests in editable mode * Multi-line dependencies Co-authored-by: Wei Ji <[email protected]>
Description of proposed changes
Fixes #1836.
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Slash Commands
You can write slash commands (
/command
) in the first line of a comment to performspecific operations. Supported slash commands are:
/format
: automatically format and lint the code/test-gmt-dev
: run full tests on the latest GMT development version