Package: buildsys-dateversion
buildsys-dateversionEasy date-based versioning for Python projects.buildsys-dateversionOverviewUsagePrerequisitesInstallation (setuptools)Installation (flit)Installation (other)Configuration referenceCaveatsLicenseOverviewbuildsys-dateversionis a Python build system extension to automatically
set a version string based on the current date/time as a project builds.
Once enabled, your project's version number while building a source distribution
or wheel will be automatically generated.At minimum, the version string will contain the current year & month.
If the generated version would clash with a version already released to PyPI,
additional date/time portions are added to the string (i.e. day, hour, minute)
until the clash is resolved.buildsys-dateversionis aPEP 517compliant build system and can be used with other PEP 517 implementations,
such assetuptoolsandflit.Here's an example of a sequence of version strings which may result
from usingbuildsys-dateversionfor a project:Release is made at...Version string2025-03-25 12:002025.32025-03-31 12:002025.3.312025-03-31 13:002025.3.31.132025-03-31 14:002025.3.31.142025-03-31 14:302025.3.31.14.302025-03-31 17:302025.3.31.172025-04-02 12:002025.4UsagePrerequisitesYour project must usepyproject.toml.Your project's sources must contain a.pyfile with a line of the form:__version__="0"(The specific value for__version__does not matter, as it will be
overwritten during build, but"0"is recommended.)Installation (setuptools)Yourpyproject.tomlshould look like this:[project]name="myproject"dynamic=["version"][tool.setuptools.dynamic]version={attr="myproject.__version__"}[build-system]requires=["buildsys-dateversion"]build-backend="buildsys_dateversion"(Note thatbuildsys-dateversionusespip-compatible build-system defaults;
this is the reason why it is not necessary to explicitly configuresetuptoolsas a build backend or to list it inrequires, as
is necessary in the flit example below.)Installation (flit)Yourpyproject.tomlshould look like this:[project]name="myproject"dynamic=["version","description"][build-system]requires=["buildsys-dateversion","flit_core >=3.2,<4"]build-backend="buildsys_dateversion"[tool.buildsys-dateversion]# buildsys-dateversion only handles generating the version number.# This tells it which build backend should be used for all the# other build steps.build-backend="flit_core.buildapi"Installation (other)buildsys-dateversionis theoretically compatible with other
PEP 517 build backends (though only setuptools and flit are tested).
The primary requirement is that the build backend must support
a dynamicversionbased on a__version__attr in the project,
as both setuptools and flit do.[project]name="myproject"# The chosen PEP 517 backend must support a dynamic version.dynamic=["version"][build-system]# Require buildsys-dateversion + the build backend.requires=["buildsys-dateversion","some_build_backend"]build-backend="buildsys_dateversion"[tool.buildsys-dateversion]# This should be a module implementing the PEP 517 hooks.build-backend="some_build_backend.hooks"Configuration referenceThe following values can be set inpyproject.toml, in thetool.buildsys-dateversiontable.[tool.buildsys-dateversion]# Should point at a module implementing PEP 517 hooks.# If omitted, default is "setuptools.build_meta:__legacy__"build-backend="some_build_backend.hooks"# A comment added on patched __version__ lines.version-marker="generated by buildsys-dateversion"# Path to the file containing __version__.# If omitted, the file is located automatically.version-path="src/mymodule/__init__.py"CaveatsTake note of the following before using this project:The setting of the__version__attribute currently relies on temporarily
patching files in the source tree, which has some implications:The source tree during a build must not be read-only.If the build process is interrupted, the file defining__version__might
not be restored to its original state.buildsys-dateversionis implemented as a PEP 517 build backend which
wraps another PEP 517 build backend. However, this wrapping is not perfect
and might result in subtle behavior differences from the underlying backend.LicenseThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.