Dynamic Versioning in pyproject.toml
Dynamic versioning allows you to set the version of your Python package based on runtime information, such as the current date or other dynamic data. This is useful for automating version management.
Configuration Steps
To implement dynamic versioning in your pyproject.toml, follow these steps:
Define the Version in Your Code
In your package's init.py, define the version dynamically. For example:
python
__version__ = f"{1}.{2}.{3}" # Replace with your dynamic logic
Set Up pyproject.toml
Your pyproject.toml should include the following sections:
toml
[project]
dynamic = ["version"]
[build-system]
requires = ["setuptools>=61.0.0", "setuptools-scm"]
build-backend = "setuptools.build_meta"
[tool.setuptools.dynamic]
version = { attr = "your_package_name.__version__" } # You see very simple with setuptools
Important Considerations
Static vs. Dynamic: If you set the version as a static string (e.g., version = "1.2.3"), it will work without issues. However, using a dynamic expression (like a function call) may lead to errors during the build process.
Build Errors: If you encounter errors, ensure that the attribute you reference in pyproject.toml is correctly defined in your package's code. The build system needs to access this attribute at build time.
see
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
see tox
https://github.com/tox-dev/tox/blob/main/pyproject.toml#
it seems we need this for poetry or we change the build system ????
Dynamic Versioning in pyproject.toml
Dynamic versioning allows you to set the version of your Python package based on runtime information, such as the current date or other dynamic data. This is useful for automating version management.
Configuration Steps
To implement dynamic versioning in your pyproject.toml, follow these steps:
Define the Version in Your Code
In your package's init.py, define the version dynamically. For example:
python
__version__ = f"{1}.{2}.{3}" # Replace with your dynamic logicSet Up pyproject.toml
Your pyproject.toml should include the following sections:
toml
Important Considerations
Static vs. Dynamic: If you set the version as a static string (e.g., version = "1.2.3"), it will work without issues. However, using a dynamic expression (like a function call) may lead to errors during the build process.
Build Errors: If you encounter errors, ensure that the attribute you reference in pyproject.toml is correctly defined in your package's code. The build system needs to access this attribute at build time.
see
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
see tox
https://github.com/tox-dev/tox/blob/main/pyproject.toml#
it seems we need this for poetry or we change the build system ????