package versioning

This commit is contained in:
Jan Benda 2024-04-26 22:22:45 +02:00
parent 8a9a50346d
commit a146dd80e4

View File

@ -2,8 +2,8 @@
This is a brief introduction to python packages. How to make them, how
to install them, how to upload them, how to maintain them, how to work
with them. For details consult https://packaging.python.org and other
sites.
with them. For details consult https://packaging.python.org, or
https://py-pkgs.org, or other sites.
## Why packages?
@ -193,6 +193,22 @@ python3 -m twine upload dist/*
token
## Versioning
Your package needs a version number (for details se below). But how to
choose the right version number? A nice and brief overview is given at
the [Python Packaging User
Guide](https://packaging.python.org/en/latest/discussions/versioning/).
In short, for semantic versioning the version number is composed of
three integer numbers called `major`, `minor`, and `patch`, separated
by a dot. These numbers are incremented in the following way:
- `major`, when incompatible API changes have been introduced,
- `minor`, when functionality is added in a backwards-compatible manner, and
- `patch`, for backwards-compatible bug fixes.
## Package version
For uploading your package to [PyPi](https://pypi.org/) you need to
@ -235,14 +251,15 @@ def about():
But how do you get the very same version into the `pyproject.toml`
file? It would be a very bad idea to write it there directly and
update it whenever you change it in the `__init__.py` file.
For this you need to specify the `version` field as `dynamic` in the
`[project]` section. This tells the package tool that the version will
be set dynamically by some code. There are several options to do
so. The simplest one is to add a `[tool.setuptools.dynamic]` section
where the version is read as an attribute from the `numerix` package,
that is its `__init__.py`file:
update it whenever you change it in the `__init__.py` file. The
version number should be set only in one place.
This is possible, of course. You need to specify the `version` field
as `dynamic` in the `[project]` section. This tells the package tool
that the version will be set dynamically by some code. There are
several options to do so. The simplest one is to add a
`[tool.setuptools.dynamic]` section where the version is read as an
attribute from the `numerix` package, that is its `__init__.py`file:
```txt
...