mtkennerly / dunamai

Dynamic versioning library and CLI
https://dunamai.readthedocs.io/en/latest
MIT License
312 stars 24 forks source link

Switch to packaging and importlib_metadata #29

Closed flying-sheep closed 2 years ago

flying-sheep commented 2 years ago

Fixes #28

Import times improve significantly:

before

after

mtkennerly commented 2 years ago

I found an interesting side effect of this change when I ran the tests locally. I have Dunamai 1.5.5 installed globally, and the virtual environment has 1.6.0 because it's in pyproject.toml. The new get_version implementation finds 1.5.5 instead of the expected 1.6.0.

________________________ test__get_version__from_name _________________________

    def test__get_version__from_name() -> None:
>       assert get_version("dunamai") == Version(pkg_resources.get_distribution("dunamai").version)
E       AssertionError: assert Version(base='1.5.5', stage=None, revision=None, distance=0, commit=None, dirty=None, tagged_metadata=None) == Version(base='1.6.0', stage=None, revision=None, distance=0, commit=None, dirty=None, tagged_metadata=None)
E        +  where Version(base='1.5.5', stage=None, revision=None, distance=0, commit=None, dirty=None, tagged_metadata=None) = get_version('dunamai')
E        +  and   Version(base='1.6.0', stage=None, revision=None, distance=0, commit=None, dirty=None, tagged_metadata=None) = Version('1.6.0')
E        +    where '1.6.0' = dunamai 1.6.0 (d:\github\mtkennerly\dunamai\.venv\lib\site-packages).version
E        +      where dunamai 1.6.0 (d:\github\mtkennerly\dunamai\.venv\lib\site-packages) = <function get_distribution at 0x045AB780>('dunamai')
E        +        where <function get_distribution at 0x045AB780> = pkg_resources.get_distribution

tests\unit\test_dunamai.py:417: AssertionError

I'll look into this some more before making a new release.

flying-sheep commented 2 years ago

huh! maybe that’s also a get_version problem, but in any way it would be great to figure it out. We had problems with get_version finding the wrong git root before…