Skip to content

Conversation

@jochenklar
Copy link
Member

With 2.4.0, I would like to an automatically generated version, created from the git tag or the latest ref. I use this setup in several other repos for some time now. Any objections @MyPyDavid @afuetterer ? (lets see if this breaks the CI)

@jochenklar jochenklar self-assigned this Nov 20, 2025
@jochenklar jochenklar added this to the RDMO 2.4.0 milestone Nov 20, 2025
MyPyDavid and others added 2 commits November 21, 2025 12:40
Signed-off-by: David Wallace <david.wallace@tu-darmstadt.de>
@afuetterer
Copy link
Member

Are tests passing locally? Is there something wrong with the version in init.py? It looks as if every tests fails?

@jochenklar
Copy link
Member Author

This is weird, locally it works. Even if I download the whl from GitHub and then install in a fresh VM using pip install ~/Downloads/Packages/rdmo-2.4.0.dev169+g86c72bdee-py3-none-any.whl[ci] everything works.

@afuetterer
Copy link
Member

Something with replace and None.

Maybe you temporarily select just one test module via pytest rmdo/some_test_module to speed up the debugging. You don't need to have 20k failing tests.

Also add pytest -vvv to increase verbosity of outputs to max.

@jochenklar
Copy link
Member Author

Ok, this is a weird Python quirk. If I install the wheel locally and run pytest in my rdmo root dir it will not use the wheel for import rdmo etc. but the rdmo python module/directory which is available in the directory. If there is no _version.py it will fail (this happens in the CI) if it there from the previous build, it works. It also works if I just change to a different directory before calling python -c 'from rdmo import version; print(version)'.

I think is is also why coverage is tracked, even when we don't use pip install -e. I am not sure what to do now. We cannot change the directory since pytest depends on running in the rdmo right?

@MyPyDavid
Copy link
Member

maybe move to the "conventional" src/rdmo/ layout afterall 😜
There may also be another way according to GPT by using:

from importlib_metadata import PackageNotFoundError, version as _dist_version

to get the version in the __init__.py

@MyPyDavid
Copy link
Member

@jochenklar
Copy link
Member Author

Yes, thanks, that is apparently the way to go. Added it (a bit more concise) to this branch. I looked at other repose and now I am also convinced that VERSION and __version__ is sufficient. I think I only added the parsed version, since the _version.py file provides them.

from importlib.metadata import version as _version

try:
VERSION = __version__ = _version(__package__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last question: Which part of the project consumes VERSION? I saw a couple of usages of ___version__.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its just convention to expose VERSION and __version__ in the "root" python module, e.g. https://github.com/django/django/blob/main/django/__init__.py.

Copy link
Member

@MyPyDavid MyPyDavid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me like this!
It still makes the ...dev..+g.. version as well.

@jochenklar jochenklar merged commit 499177e into 2.4.0 Nov 25, 2025
27 of 30 checks passed
@jochenklar jochenklar deleted the 2.4.0-dynamic-version branch November 25, 2025 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants