Publish dev releases to PyPi and automatize version computation
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
- Type d'issue
- Fonctionnalité
- Clarté
- À clarifier
- Activité
- À l'abandon
- Stack technique
- git, github-actions, python
- Domaine
- build-system, ci-cd, release
Piste de recherche
Start by reviewing the package init.py version definition and the publish-dev workflow, then compare the proposed versioningit configuration with the current release setup. The work is complete when the agreed versioning approach is implemented, development releases are published as intended, and runtime version lookup matches released packages.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Disclaimer: this is an exploratory issue, I'm still not totally convinced this is the proper way of working, so far this is more a dump of which issue I have and what I've found which could help.
Context
Issue https://github.com/openzim/zimit/issues/300 shows that it might be interesting to publish dev versions to Pypi for proper integration of warc2zim package inside zimit. This would also help to test dev versions more easily for external contributors. Note that by default, pip considers only stable versions, so this is not a problem ; should we want dev versions, we need to use the --pre flag.
Currently, we setup the version manually in main package __init__.py : https://github.com/openzim/_python-bootstrap/blob/3856ce249adb15b4cf37bb7be8bd80e569f1c6e2/src/great_project/__init__.py#L3
This however means that we need an automated way to bump dev versions for every commit on main branch. It would be good to not have to make a new commit just to bump the version, since this would double the number of commits for almost nothing, making the git history quite dirty.
At the same time, we currently rely on manual setup of the next release, meaning we have to manually make commits (again on main branch) at every release to push the proper version, and after release to prepare for next version. Since we also place a tag for the release, there is a significant chance of mismanipulation leading to discrepancy between the tag and the version in Pypi.
We use a major.minor.patch scheme for production, or major.minor.patch-devN for development.
Currently, right after a release we bump the version to the next minor and zero the patch. I.e. if version released is 1.2.3, we bump the version to 1.3.0-dev0. This is not quite appropriate, since we usually never know yet if the next code going to be merged to main is going to be for a patch, for a minor or for a major. Solving this would be great as well.
Proposition
- publish dev versions to Pypi
- remove the version from
__init__.pyand compute it automatically withversioningit: https://versioningit.readthedocs.io/en/stable/index.html- basically we use tags to compute the released version
- for dev, the version is computed based on last tag + number of commits since this tag
- do not commit current version anymore to source code, this information will be stored in git history
- retrieve version at runtime from
importlib.metadata.version("mypackage")
This means we need (but it is a good opportunity) to change our way of working:
- by default, we assumes that next version is going to be a patch of latest released tag (released tag meaning a tag without a
.devNsuffix) - once we know we have significant changes needing a minor, the associated merge commit is tagged with the minor dev version (e.g. v1.3.0.dev0).
- every subsequent commit is automatically numbered based on the distance to latest tag commit, hence being the dev version of next minor
- should we decide to make breaking changes needing a major, again the merge commit is tagged with the major dev version (e.g. v2.0.0.dev0).
- again, every subsequent commit is automatically numbered based on the distance to current commit, hence being the dev version of next major
Ideally the merge commit going to move from a patch to a minor or major release should be pushed first as a tag, then as a commit to main branch. This way when the CI trigger on push to main branch, the tag is already appropriately incremented (otherwise it will build a 1.2.x.devN instead of a 1.3.0.dev0 for instance). Since we know that this is not going to always be the case (people love to click the "Merge PR" in Github UI), we can modify the publish-dev workflow to also be triggered on push to tags matching the v*.dev0 pattern.
This means we need a custom next_version computation (don't know why it is not standard in versioningit) which:
- compute the next patch if latest tag has no
-devsuffix- e.g. if latest tag is
1.2.0(because it has been released), then next commit on main branch will computenext_versionas1.2.1, which once formatted will become1.2.1.dev1
- e.g. if latest tag is
- keep the same released version if it has a
-devsuffix- e.g. if latest tag is
1.3.0.dev0(because we decided to bump to a minor), then next commit on main branch will computenext_versionas1.3.0, which once formatted will become1.3.0.dev1
- e.g. if latest tag is
I propose to share this next_version method in hatch-openzim package since it is also used to distribute shared stuff across openZIM organization.
Final configuration:
[tool.versioningit.next-version]
method = { module = "hatch-openzim.versioningit", value = "next_version" }
[tool.versioningit.format]
distance = "{next_version}.dev{distance}+{vcs}{rev}"
# Example formatted version: 1.2.4.dev42+ge174a1f
dirty = "{base_version}+d{build_date:%Y%m%d}"
# Example formatted version: 1.2.3+d20230922
distance-dirty = "{next_version}.dev{distance}+{vcs}{rev}.d{build_date:%Y%m%d}"
# Example formatted version: 1.2.4.dev42+ge174a1f.d20230922
WDYT?
- Langage dominant
- Python
- Étoiles
- 1
- Forks
- 2
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Fournit un Dockerfile ou un fichier Docker Compose
- Aucun modèle de pull request
- Aucun guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de openzim/_python-bootstrap
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 76/100
openzim/_python-bootstrap#57 ·
-
Adapt bootstrap / conventions to use `pylock.toml`Peut-être à nouveau libre @rgaudin l’a pris il y a 444 jours, et aucune pull request n’est ouverte. Ouverteenhancement
openzim/_python-bootstrap#54 · 1 commentaire · 2 personnes assignées ·
-
Workflow conventionPeut-être à nouveau libre @benoit74 l’a pris il y a 458 jours, et aucune pull request n’est ouverte. Ouvertequestion
openzim/_python-bootstrap#53 · 1 personne assignée ·
-
Move `.pre-commit.yaml` to hatchOuverteenhancement
Difficulté 3/5 1-2 jours Accessibilité débutants 25/100
openzim/_python-bootstrap#51 · 3 commentaires ·
-
What about nested logsPeut-être à nouveau libre @rgaudin l’a pris il y a 732 jours, et aucune pull request n’est ouverte. Ouverteenhancement
openzim/_python-bootstrap#48 · 2 personnes assignées ·
Toutes les issues de openzim/_python-bootstrap
Issues similaires
-
bug llm translation
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Arkansas 2025 tax is $1.70 high above $100,000 net taxable income ($3,809 + 3.9% rule)Peut-être pris @PavelMakarchuk l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
PolicyEngine/policyengine-us#9828 ·
Les mainteneurs répondent en général sous 2 jours
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
jellyfin/jellyfin-mpv-shim#800 ·
Les mainteneurs répondent en général sous 1 jour
-
skillfs: one malformed chat-log line aborts the entire skill-usage analysis (skill_usage_from_chat_logs.py)Peut-être pris @zjncs l’a pris aujourd’hui. Ouvertecomponent:skillfs
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
agentic-os-org/ANOLISA#6116 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
P4: low query
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
jeffknupp/association#336 ·