Skip to content

Poetry v2 doesn't accept version with -SNAPSHOT unless using v1.8-style pyproject.toml #10229

@jamcpherson-clgx

Description

@jamcpherson-clgx

Description

My organization's CICD process automatically adds "+SNAPSHOT" to the version string for builds on the development branch. This is consistent across every language we use, Python included.

I discovered yesterday that if I use a Poetry v2 form of the pyproject.toml file, then that extra uppercase word prevents Poetry v2.0.1 from installing or building packages.

CICD logfile excerpt:

16:37:39  ci baseVersion from version.txt file: 1.0.0
16:37:39  [Pipeline] sh
16:37:40  + sed -r -i s/version = "1.0.0"/version = "1.0.0+SNAPSHOT"/ pyproject.toml
16:37:40  [Pipeline] sh
16:37:40  + cat pyproject.toml
16:37:40  + grep version
16:37:40  version = "1.0.0+SNAPSHOT"
16:37:40  [Pipeline] sh
16:37:41  + poetry install -v
16:37:41  
16:37:41    RuntimeError
16:37:41  
16:37:41    The Poetry configuration is invalid:
16:37:41      - project.version must match pattern ^v?((([0-9]+)!)?([0-9]+(\.[0-9]+)*)([-_\.]?(alpha|a|beta|b|preview|pre|c|rc)[-_\.]?([0-9]+)?)?((-([0-9]+))|([-_\.]?(post|rev|r)[-_\.]?([0-9]+)?))?([-_\.]?(dev)[-_\.]?([0-9]+)?)?)(\+([a-z0-9]+([-_\.][a-z0-9]+)*))?$
16:37:41    
16:37:41  
16:37:41    at /usr/local/lib/python3.10/dist-packages/poetry/core/factory.py:59 in create_poetry
16:37:41         55│             message = ""
16:37:41         56│             for error in check_result["errors"]:
16:37:41         57│                 message += f"  - {error}\n"
16:37:41         58│ 
16:37:41      →  59│             raise RuntimeError("The Poetry configuration is invalid:\n" + message)
16:37:41         60│ 
16:37:41         61│         for warning in check_result["warnings"]:
16:37:41         62│             logger.warning(warning)

When using Poetry v1.8.2 to build the package, that additional "+SNAPSHOT" did not prevent the package's dependencies being installed, and did not prevent the package from building.

When I changed the pyproject.toml to use the v1.8.x syntax

ie, from

[project]
name = "package-name"
version = "1.0.0"
description = "package description"
authors = [
    {name = "OP", email = "[email protected]"}
]

to

[tool.poetry]
name = "package-name"
version = "1.0.0"
description = "packages description"
authors = ["OP <[email protected]>"]
readme = "README.md"

then Poetry v2.0.1 built the package correctly with the "+SNAPSHOT" in the input version string, and that was correctly translated in the build package name to be "-snapshot".

Workarounds

If you need to use the local part of the version string, per https://peps.python.org/pep-0440/#local-version-identifiers, then either

  • use a lowercase local version identifier, or
  • use the v1.8.x form of your pyproject.toml

Poetry Installation Method

pip

Operating System

Ubuntu 22.04.5 LTS

Poetry Version

Poetry (version 2.0.1)

Poetry Configuration

cache-dir = "/home/jenkins/.cache/pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/jenkins/.cache/pypoetry/virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false

Python Sysconfig

It's the standard Python3.10 built by Canonical for Ubuntu 22.04:

$ apt list --installed |grep python3.10

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libpython3.10-minimal/jammy-updates,jammy-security,now 3.10.12-1~22.04.8 amd64 [installed,automatic]
libpython3.10-stdlib/jammy-updates,jammy-security,now 3.10.12-1~22.04.8 amd64 [installed,automatic]
libpython3.10/jammy-updates,jammy-security,now 3.10.12-1~22.04.8 amd64 [installed,automatic]
python3.10-minimal/jammy-updates,jammy-security,now 3.10.12-1~22.04.8 amd64 [installed,automatic]
python3.10/jammy-updates,jammy-security,now 3.10.12-1~22.04.8 amd64 [installed]

Example pyproject.toml

See description

Poetry Runtime Logs

See description

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/coreRelated to the poetry-core librarykind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions