[Python] 'pdm build' adds date to scm version number, TestPyPI rejects it

Discussão em 'Python' iniciado por Stack, Fevereiro 21, 2025.

  1. Stack

    Stack Membro Participativo

    My distribution project is managed with git, The last tag is 0.1.2.dev1. I use PDM (https://pdm-project.org). The relevant snipped in pyproject.toml is:

    [build-system]
    requires = ["pdm-backend"]
    build-backend = "pdm.backend"

    [tool.pdm]
    distribution = true
    version = {source = "scm", write_to = "ff_testpkg/version.py", write_template = "__version__ = '{}'" }


    On pdm build:

    pdm build
    Building sdist...
    Built sdist at C:/dev/pylib/ff-testpkg/dist\ff-testpkg-0.1.2.dev1+d20250221.tar.gz
    Building wheel from sdist...
    Built wheel at C:/dev/pylib/ff-testpkg/dist\ff-testpkg-0.1.2.dev1+d20250221-py3-none-any.whl


    I see the same auto-generated version number in version.py:

    __version__ = '0.1.2.dev1+d20250221'


    On pdm publish, I get this error:

    400 The use of local versions in <Version('0.1.2.dev1+d20250221')> is not allowed. See https://packaging.python.org/specifications/core-metadata for more information.


    How do I make pdm not inject the +d=date= local versioning?

    Edit: I read https://packaging.python.org/en/latest/specifications/version-specifiers/#local-version-identifiers, it says local versions must comply with <public version identifier>[+<local version label>], but after a paragraph it says: "local version labels MUST be limited to the following set of permitted characters: ASCII letters ([a-zA-Z]), ASCII digits ([0-9]), periods (.)". This means 0.1.2.dev1+d20250221 should be allowed, right?

    Continue reading...

Compartilhe esta Página