Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to packaging and importlib_metadata #29

Merged
merged 2 commits into from
Oct 9, 2021

Conversation

flying-sheep
Copy link
Contributor

@flying-sheep flying-sheep commented Oct 8, 2021

Fixes #28

  • This also contains another best practices changes, such as not having __init__.py in pytest directories.
  • IDK why poetry updates all those packages in the lockfile once I run poetry add or poetry remove. Is there a way to make it not do that?

Import times improve significantly:

before

after

@mtkennerly mtkennerly added the enhancement New feature or request label Oct 8, 2021
Copy link
Owner

@mtkennerly mtkennerly left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! The pre-commit hooks are complaining about a minor whitespace issue, but I can fix that after the merge.

IDK why poetry updates all those packages in the lockfile once I run poetry add or poetry remove. Is there a way to make it not do that?

I'm not sure offhand, but I don't mind it.

@mtkennerly mtkennerly merged commit 1c16f9b into mtkennerly:master Oct 9, 2021
@mtkennerly mtkennerly added this to the v1.7.0 milestone Oct 9, 2021
@mtkennerly
Copy link
Owner

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 flying-sheep deleted the no-pkg-resources branch October 9, 2021 15:38
@flying-sheep
Copy link
Contributor Author

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…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get rid of pkg_resources dependency
2 participants