Search code examples
pythonpipuploadpypi

PyPi refuses version value


I am trying to upload package to pypi and getting error:

'4.5.1-2021.2-0' is an invalid value for Version. Error: Start and end with a letter or numeral containing only ASCII numeric and '.', '_' and '-'. See https://packaging.python.org/specifications/core-metadata for more information.

I know that my name is not PEP440 compliant, but it matches PyPi value format. Strange, that it substitites _ to -

From setup.py:

setuptools.setup(
    name="opencv-python-inference-engine",
    version="4.5.1_2021.2_0",
...

Package filename: opencv_python_inference_engine-4.5.1_2021.2_0-py3-none-manylinux1_x86_64.whl

What I am doing wrong, except PRP440 compliance?

UPD: '4.5.1-2021.2' also generates error, however it looks PEP440 compliant (pre-release separators).


Solution

  • Your version isn't PEP440 compliant. Prerelease versions have to include the prerelease "phase" (alpha, beta, release candidate).

    The pre-release segment consists of an alphabetical identifier for the pre-release phase, along with a non-negative integer value. Pre-releases for a given release are ordered first by phase (alpha, beta, release candidate) and then by the numerical component within that phase.

    X.YaN   # Alpha release
    X.YbN   # Beta release
    X.YrcN  # Release Candidate
    X.Y     # Final release
    

    For alpha this means the letter a, for beta this means the letter b, and for Release Candidate you need rc. Change your dash to an a or b and I think it will work.