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

get version without importing #12

Merged
merged 2 commits into from
Jun 24, 2020
Merged

get version without importing #12

merged 2 commits into from
Jun 24, 2020

Conversation

javierggt
Copy link
Collaborator

@javierggt javierggt commented Jun 17, 2020

Description

This removes a hack in version.get_version. Instead of importing a partially loaded module, use importlib.util.find_spec

Testing

  • Passes unit tests on MacOS, linux, Windows (at least one required), although the relevant parts are not tested.
  • Functional testing:
    • run python setup.py --version on a clean/dirty package git directory (without defining PYTHONPATH)
    • defined PYTHONPATH pointing to a dirty git directory, then python -c 'import proseco; print(proseco.__version__)'
    • running testr using this module, including a few other packages. Output seemed fine.

@jeanconn
Copy link
Contributor

Great. I thought we had already been down this road and it didn't work for our use case, but I must be misremembering.

@javierggt
Copy link
Collaborator Author

well, we discussed this hack before, but I don't remember seeing importlib.util.find_spec then.

Copy link
Member

@taldcroft taldcroft 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, very glad this appears to be working. The goal was always import-free versions.

I don't recall discussing this particular importlib function and I'm guessing we would have gone down that path had it been in the fray.

@javierggt
Copy link
Collaborator Author

After much fiddling and puzzling... my issue was a stray egg directory within my git local copy. It was left from a time when I did pip install -e .. For some reason I still do not understand, get_version was failing when running within testr, because importlib.util.find_spec was getting one path and pkg_resources.get_distribution was getting the other. I have not been able to reproduce it again.

@javierggt
Copy link
Collaborator Author

I will merge this PR.

@javierggt javierggt merged commit 2090801 into master Jun 24, 2020
@taldcroft taldcroft mentioned this pull request Jun 25, 2020
2 tasks
@javierggt javierggt mentioned this pull request Jul 28, 2020
@javierggt javierggt mentioned this pull request Aug 12, 2020
@javierggt javierggt deleted the no-import branch January 5, 2023 16:47
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.

3 participants