pypa / packaging.python.org

Python Packaging User Guide
http://packaging.python.org
1.41k stars 885 forks source link

Guide for "Single sourcing the package version" refers to setup.py #1260

Open venthur opened 1 year ago

venthur commented 1 year ago

https://packaging.python.org/en/latest/guides/single-sourcing-package-version/ refers to setup.py and the many ways how to get the version into setup.py. pyproject.toml is mentioned only as a side note.

Since setup.py is deprecated in favour of pyproject.toml, I wonder what to do with this document. Single sourcing the version should be a non-issue. We could either strip the whole document down to pyproject.toml which would make the document very small, or move the relevant paragraph into the packaging tutorial:

[project]
name = "package"
dynamic = ["version"]

[tool.setuptools.dynamic]
version = {attr = "package.__version__"}
chrysle commented 1 year ago

https://packaging.python.org/en/latest/guides/single-sourcing-package-version/ refers to setup.py and the many ways how to get the version into setup.py. pyproject.toml is mentioned only as a side note.

Since setup.py is deprecated in favour of pyproject.toml, I wonder what to do with this document.

setup.py isn't deprecated that long, and many projects are still using it. I'm for keeping the page as-is.

webknjaz commented 1 year ago

FWIW setup.py isn't deprecated at all. What's discouraged is calling it directly as a script. Using it through the standard PEP 517 interface is perfectly valid use.

webknjaz commented 1 year ago

It would be nice, however, to swap the preference in the document. I'd still go for setup.cfg, though, as my personal preference is to keep the metadata in a dedicated file. Besides, pyproject.toml is still labeled as beta in setuptools.

chrysle commented 1 year ago

FWIW setup.py isn't deprecated at all. What's discouraged is calling it directly as a script.

There's some excellent lecture about this, maybe this can be linked?

It would be nice, however, to swap the preference in the document.

Preference for what do you mean?

webknjaz commented 1 year ago

For the main article contents to feature setup.cfg, moving setup.py to the "note" blocks.

wimglenn commented 1 year ago

@webknjaz To correct some misconceptions:

pyproject.toml is not labelled as beta in setuptools. It is support for declaring configurations not standardized by PEP 621 that is still in beta stage. version is not one of those fields.

The plan from setuptools is to eventually deprecate setup.cfg, so its use should not be recommended in the packaging guide.

+1 for moving pyproject.toml example to the top, the existing setup.py example is quite crufty and hacky.

ChrisBarker-NOAA commented 1 year ago

thin the page needs updating:

See https://github.com/pypa/packaging.python.org/pull/1273

Please comment / edit that so we can get a nicer page together.