Skip to content

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

Closed

Description

@venthur

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__"}

Activity

  1. chrysle commented on May 23, 2023

    @chrysle
    Contributor

    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.

  2. webknjaz commented on May 23, 2023

    @webknjaz
    Member

    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.

  3. webknjaz commented on May 23, 2023

    @webknjaz
    Member

    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.

  4. chrysle commented on May 23, 2023

    @chrysle
    Contributor

    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?

  5. webknjaz commented on May 23, 2023

    @webknjaz
    Member

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

  6. wimglenn commented on Jun 8, 2023

    @wimglenn
    Contributor

    @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.

  7. ChrisBarker-NOAA commented on Jul 10, 2023

    @ChrisBarker-NOAA
    Contributor

    thin the page needs updating:

    See #1273

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

  8. ncoghlan commented on Oct 15, 2024

    @ncoghlan
    Contributor

    Resolved in #1612

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions