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

Remove out-of-date versioneer import #158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Yoshanuikabundi
Copy link

Hi!

I might just be thick, but I'm getting ModuleNotFoundError: No module named 'projectname._version' when loading a new project in a Python interpreter or Sphinx. I think this line is just left over from the versioneer -> versioningit transition, but I'm surprised no one has reported it in nearly a month!

@janash
Copy link
Member

janash commented Aug 20, 2022

I think the migration from versioneer to versioningit was merged only two days ago, so not a month :)

Thanks for finding!

@Yoshanuikabundi
Copy link
Author

I think I was looking at the commit date, not the merge date 🤦 that makes more sense

@Lnaden
Copy link
Collaborator

Lnaden commented Aug 22, 2022

So the _version.py file is now only generated on package install. VersionInGit will auto-generate this file anytime the package is installed through pip install ..., and if the package is ever bundled for release, it will generate the static version of the file to load into the package.

What I suspect happened is you attempted to run the code without first installing it, so the file wasn't there and wasn't imported. If this is a use case for you, then its an edge case we should support.

I think the solution here would be to create try...except around that import in case the file isnt found. Either way, I feel this line needs to remain intact.

Thoughts?

@janash
Copy link
Member

janash commented Aug 22, 2022

Good to know, thanks for the explanation! Yes, we should document or explain this. We can add a try except with a comment explaining what's happening.

Copy link
Member

@janash janash left a comment

Choose a reason for hiding this comment

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

Need to make changes suggested by @Lnaden

@eirrgang
Copy link
Contributor

Note that the file is generated in several other instances in which versioningit is invoked, such as when building the package, even as an sdist, or (possibly) when using the versioningit command line tool to check the version.

I'm not sure I agree with a try: ... except block around the import. I think a comment with a link to the versioningit docs would be more useful.

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