cookiecutter-cms
cookiecutter-cms copied to clipboard
Remove out-of-date versioneer import
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!
I think the migration from versioneer
to versioningit
was merged only two days ago, so not a month :)
Thanks for finding!
I think I was looking at the commit date, not the merge date 🤦 that makes more sense
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?
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.
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.