Skip to content

Start transitioning to pyproject.toml #23829

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 80 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
[project]
name = "matplotlib"
authors = [
{email = "matplotlib-users@python.org"},
{name = "John D. Hunter, Michael Droettboom"}
]
description = "Python plotting package"
readme = "README.md"
license = { file = "LICENSE/LICENSE" }
dynamic = ["version", "optional-dependencies"]
classifiers=[
'Development Status :: 5 - Production/Stable',
'Framework :: Matplotlib',
'Intended Audience :: Science/Research',
'Intended Audience :: Education',
'License :: OSI Approved :: Python Software Foundation License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Scientific/Engineering :: Visualization',
]

# When updating the list of dependencies, add an api_changes/development
# entry and also update the following places:
# - lib/matplotlib/__init__.py (matplotlib._check_versions())
# - requirements/testing/minver.txt
# - doc/devel/dependencies.rst
# - .github/workflows/tests.yml
# - environment.yml
dependencies = [
"contourpy>=1.0.1",
"cycler>=0.10",
"fonttools>=4.22.0",
"kiwisolver>=1.0.1",
"numpy>=1.21",
"packaging>=20.0",
"pillow>=6.2.0",
"pyparsing>=2.3.1",
"python-dateutil>=2.7",
"setuptools_scm>=7.0"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be conditional, but I have not found any info how to do this dynamically.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is needed at all as it is in the [build-system] requires section. It is needed by anyone who uses --no-build-isolation in their pip install ., but in that situation they will need to have preinstalled all of the [build-system] requires packages to proceed.

Although I might be missing some other use of setuptools_scm in testing or somewhere else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was added as someone had problems running tests in a particular setup(?).

Without it, this breaks in the tests:

if ((root / ".matplotlib-repo").exists()
and (root / ".git").exists()
and not (root / ".git/shallow").exists()):
import setuptools_scm
return setuptools_scm.get_version(
root=root,
version_scheme="release-branch-semver",
local_scheme="node-and-date",
fallback_version=_version.version,
)

although it indeed is not really required for a user install.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now. So it shouldn't be in the dependencies section of the pyproject.toml as then wheel users will be forced to have it which means it should be in one of the requirements files instead, perhaps requirements/testing/all.txt?

Eventually I would expect the requirements files to be replaced with [project.optional-dependencies] sections in the pyproject.toml, but that is not necessary yet.

]
requires-python = ">=3.9"

[build-system]
build-backend = "setuptools.build_meta"
requires = [
Expand All @@ -7,11 +52,45 @@ requires = [
"setuptools_scm>=7",
]


[tool.isort]
known_mpltoolkits = "mpl_toolkits"
known_pydata = "numpy, matplotlib.pyplot"
known_firstparty = "matplotlib"
sections = "FUTURE,STDLIB,THIRDPARTY,PYDATA,FIRSTPARTY,MPLTOOLKITS,LOCALFOLDER"
no_lines_before = "MPLTOOLKITS"
force_sort_within_sections = true

[tool.setuptools]
platforms = ["any"]
py-modules = ["pylab"]
namespace-packages = ["mpl_toolkits"]

[tool.setuptools.packages.find]
where = ["lib"]
include = ["matplotlib*", "mpl_toolkits*"]
exclude = [
"matplotlib.tests*",
"mpl_toolkits.axes_grid1.tests*",
"mpl_toolkits.axisartist.tests*",
"mpl_toolkits.mplot3d.tests*"
]
namespaces = false

[tool.setuptools.exclude-package-data]
"*" = ["*.png", "*.svg"]

[tool.setuptools_scm]
version_scheme = "release-branch-semver"
local_scheme = "node-and-date"
write_to = "lib/matplotlib/_version.py"
parentdir_prefix_version = "matplotlib-"
fallback_version = "0.0+UNKNOWN"

[project.urls]
'Homepage' = 'https://matplotlib.org'
'Download' = 'https://matplotlib.org/stable/users/installing/index.html'
'Documentation' = 'https://matplotlib.org'
'Source Code' = 'https://github.com/matplotlib/matplotlib'
'Bug Tracker' = 'https://github.com/matplotlib/matplotlib/issues'
'Forum' = 'https://discourse.matplotlib.org/'
'Donate' = 'https://numfocus.org/donate-to-matplotlib'
69 changes: 1 addition & 68 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import shutil
import subprocess

from setuptools import setup, find_packages, Distribution, Extension
from setuptools import setup, Distribution, Extension
import setuptools.command.build_ext
import setuptools.command.build_py
import setuptools.command.sdist
Expand Down Expand Up @@ -268,83 +268,16 @@ def make_release_tree(self, base_dir, files):
package_data[key] = list(set(val + package_data[key]))

setup( # Finally, pass this all along to setuptools to do the heavy lifting.
name="matplotlib",
description="Python plotting package",
author="John D. Hunter, Michael Droettboom",
author_email="matplotlib-users@python.org",
url="https://matplotlib.org",
download_url="https://matplotlib.org/stable/users/installing/index.html",
project_urls={
'Documentation': 'https://matplotlib.org',
'Source Code': 'https://github.com/matplotlib/matplotlib',
'Bug Tracker': 'https://github.com/matplotlib/matplotlib/issues',
'Forum': 'https://discourse.matplotlib.org/',
'Donate': 'https://numfocus.org/donate-to-matplotlib'
},
long_description=Path("README.md").read_text(encoding="utf-8"),
long_description_content_type="text/markdown",
license="PSF",
platforms="any",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Framework :: Matplotlib',
'Intended Audience :: Science/Research',
'Intended Audience :: Education',
'License :: OSI Approved :: Python Software Foundation License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Scientific/Engineering :: Visualization',
],

package_dir={"": "lib"},
packages=find_packages("lib"),
namespace_packages=["mpl_toolkits"],
py_modules=["pylab"],
# Dummy extension to trigger build_ext, which will swap it out with
# real extensions that can depend on numpy for the build.
ext_modules=[Extension("", [])],
package_data=package_data,

python_requires='>={}'.format('.'.join(str(n) for n in py_min_version)),
# When updating the list of dependencies, add an api_changes/development
# entry and also update the following places:
# - lib/matplotlib/__init__.py (matplotlib._check_versions())
# - requirements/testing/minver.txt
# - doc/devel/dependencies.rst
# - .github/workflows/tests.yml
# - environment.yml
install_requires=[
"contourpy>=1.0.1",
"cycler>=0.10",
"fonttools>=4.22.0",
"kiwisolver>=1.0.1",
"numpy>=1.21",
"packaging>=20.0",
"pillow>=6.2.0",
"pyparsing>=2.3.1",
"python-dateutil>=2.7",
] + (
# Installing from a git checkout that is not producing a wheel.
["setuptools_scm>=7"] if (
Path(__file__).with_name(".git").exists() and
os.environ.get("CIBUILDWHEEL", "0") != "1"
) else []
),
extras_require={
':python_version<"3.10"': [
"importlib-resources>=3.2.0",
],
},
use_scm_version={
"version_scheme": "release-branch-semver",
"local_scheme": "node-and-date",
"write_to": "lib/matplotlib/_version.py",
"parentdir_prefix_version": "matplotlib-",
"fallback_version": "0.0+UNKNOWN",
},
cmdclass={
"build_ext": BuildExtraLibraries,
"build_py": BuildPy,
Expand Down