FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Move config from `setup.cfg` to `pyproject.toml` by hugovk · Pull Request #7484 · python-pillow/Pillow · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cfg  (1) .in  (1) .py  (1) .rst  (1) .sh  (1) .toml  (1) dotfile  (1) All 7 file types selected
Only manifest files
Deleted files Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
10 changes: 10 additions & 0 deletions .ci/install.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ if [[ $(uname) != CYGWIN* ]]; then
python3 -m pip install pyqt6
fi

# Pyroma uses non-isolated build and fails with old setuptools
if [[
$GHA_PYTHON_VERSION == pypy3.9
|| $GHA_PYTHON_VERSION == 3.8
|| $GHA_PYTHON_VERSION == 3.9
]]; then
# To match pyproject.toml
python3 -m pip install "setuptools>=67.8"
fi

# webp
pushd depends && ./install_webp.sh && popd

Expand Down
3 changes: 3 additions & 0 deletions .flake8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
extend-ignore = E203
max-line-length = 88
1 change: 1 addition & 0 deletions MANIFEST.in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include *.rst
include *.sh
include *.txt
include *.yaml
include .flake8
include LICENSE
include Makefile
include tox.ini
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ for your machine (e.g. :file:`/usr` or :file:`/usr/local`), no
additional configuration should be required. If they are installed in
a non-standard location, you may need to configure setuptools to use
those locations by editing :file:`setup.py` or
:file:`setup.cfg`, or by adding environment variables on the command
:file:`pyproject.toml`, or by adding environment variables on the command
line::

CFLAGS="-I/usr/pkg/include" python3 -m pip install --upgrade Pillow --no-binary :all:
Expand Down
77 changes: 77 additions & 0 deletions pyproject.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,80 @@ requires = [
backend-path = [
"_custom_build",
]

[project]
name = "pillow"
description = "Python Imaging Library (Fork)"
readme = "README.md"
keywords = [
"Imaging",
]
license = {text = "HPND"}
authors = [{name = "Jeffrey A. Clark (Alex)", email = "aclark@aclark.net"}]
requires-python = ">=3.8"
classifiers = [
"Development Status :: 6 - Mature",
"License :: OSI Approved :: Historical Permission Notice and Disclaimer (HPND)",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Multimedia :: Graphics",
"Topic :: Multimedia :: Graphics :: Capture :: Digital Camera",
"Topic :: Multimedia :: Graphics :: Capture :: Screen Capture",
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
"Topic :: Multimedia :: Graphics :: Viewers",
]
dynamic = [
"version",
]

radarhere Oct 22, 2023
edited by hugovk
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looking at https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#dynamic-metadata,
should this not be

dynamic = ["version", "readme"]

and move readme = "README.md" from earlier into

[tool.setuptools.dynamic]
version = {attr = "PIL.__version__"}
readme = {file = "README.md"}

later?

nulano Oct 22, 2023
edited by hugovk
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The readme is listed in both examples at that page, but it looks to me like it should be in the dynamic section so that the content type can be specified (the default is text/x-rst):

readme = {file = "README.md", content-type = "text/markdown"}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Version:

Setting the version is good, it means we can move version=PILLOW_VERSION out of setup.py's setup().

README:

Despite the docs saying content-type defaults to text/x-rst, I did a test upload to https://test.pypi.org/project/pillow/10.2.0.dev0/ (files built using python -m build from the current state of the PR) and the README renders just fine, so I think it's fine?

PS @radarhere and other Pillow maintainers: if you like, I can add you to https://test.pypi.org/project/pillow/ in case you want to test anything out there. Just let me know your username (you need to create a new account there).

[project.optional-dependencies]
docs = [
"furo",
"olefile",
"sphinx>=2.4",
"sphinx-copybutton",
"sphinx-inline-tabs",
"sphinx-removed-in",
"sphinxext-opengraph",
]
tests = [
"check-manifest",
"coverage",
"defusedxml",
"markdown2",
"olefile",
"packaging",
"pyroma",
"pytest",
"pytest-cov",
"pytest-timeout",
]
[project.urls]
Changelog = "https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst"
Documentation = "https://pillow.readthedocs.io"
Funding = "https://tidelift.com/subscription/pkg/pypi-pillow?utm_source=pypi-pillow&utm_medium=pypi"
Homepage = "https://python-pillow.org"
Mastodon = "https://fosstodon.org/@pillow"
"Release notes" = "https://pillow.readthedocs.io/en/stable/releasenotes/index.html"
Source = "https://github.com/python-pillow/Pillow"
Twitter = "https://twitter.com/PythonPillow"

[tool.setuptools]
packages = ["PIL"]
include-package-data = true
package-dir = {"" = "src"}

[tool.setuptools.dynamic]
version = {attr = "PIL.__version__"}

[tool.isort]
profile = "black"

[tool.pytest.ini_options]
addopts = "-ra --color=yes"
testpaths = ["Tests"]
74 changes: 0 additions & 74 deletions setup.cfg

This file was deleted.

1 change: 0 additions & 1 deletion setup.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,6 @@ def debug_build():

try:
setup(
version=PILLOW_VERSION,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is there a way to query the version from setuptools instead of reading it from a file in get_version?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

There are 7 options at https://packaging.python.org/en/latest/guides/single-sourcing-package-version/

  1. Also reads from file
  2. I'm not too sure about those external build tools
  3. We're using something like this
  4. Also reads from file
  5. Moves version constant to setup.py, project code fetchs via importlib.metadata
  6. Import the version from src/PIL/__init__.py, but I'm not sure if we can import PIL before the build?
  7. Get the version number from SCM using setuptools_scm. I've used setuptools_scm in other projects, this might work.

But I suggest these could be topics for a followup.

cmdclass={"build_ext": pil_build_ext},
ext_modules=ext_modules,
zip_safe=not (debug_build() or PLATFORM_MINGW),
Expand Down

Back | FazBrowse Home | New Git URL