Skip to content

Python local version identifiers#

Python local version identifiers are used to distinguish between different builds of the same version of a package. They are used to indicate that a package has been modified in some way from the original source code, but should still be considered the same version.

Check the PEP 440 for more details.

Local version identifiers MUST comply with the following scheme:

<public version identifier>[+<local version label>]

A simple way to compute this version number could be:

file setup.py
from datetime import datetime, timezone
...
# suppose the Python module my_package has a __version__ attribute
version=my_package.__version__ + "+" + datetime.now(timezone.utc).strftime("%Y%m%d.%H%M%S")

datetime.now(timezone.utc) is preferred over datetime.utcnow()

Comments