cookiecutter-cms icon indicating copy to clipboard operation
cookiecutter-cms copied to clipboard

Remove out-of-date versioneer import

Open Yoshanuikabundi opened this issue 2 years ago • 5 comments

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!

Yoshanuikabundi avatar Aug 20 '22 12:08 Yoshanuikabundi

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

Thanks for finding!

janash avatar Aug 20 '22 12:08 janash

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

Yoshanuikabundi avatar Aug 20 '22 17:08 Yoshanuikabundi

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?

Lnaden avatar Aug 22 '22 18:08 Lnaden

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.

janash avatar Aug 22 '22 19:08 janash

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.

eirrgang avatar Sep 22 '22 14:09 eirrgang