-
Notifications
You must be signed in to change notification settings - Fork 10
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
Newly created project crashes when calling with --version parameter #752
Comments
Interesting finding. I can reproduce this. It works with the cookietemple repository: |
We can fix it by adapting the
However, this would require the package to be installed and does not work with
|
How about this, which works in a development setting (I suppose
That way, no need to redefine the version, we just use the value defined in As to using
|
I guess this would have to be
Could do that. I'll try it out soonish. |
Hi @Zethson, I've been looking a bit more around, and I don't know if the approach of importing from Looking at this SO discussion, there doesn't seem to be one best solution. Maybe the most pragmatic would be your suggestion at the end of this post:
Since you already have all the infrastructure to update hardcoded values, one more place where it would get updated shouldn't be a problem. And that way we prevent causing issues for people that would want to use cookietemple to create Python modules... What do you think? |
Yeah, might then be the most reasonable solution. Any opinion @Imipenem ? |
- version is now hardcoded in templates and will be bumped as well
* Fix #752: Project version using poetry run - version is now hardcoded in templates and will be bumped as well * fix f-string Co-authored-by: Lukas Heumos <[email protected]>
Associated Template/Command/Core
poetry run python <project_name>\__main__.py --version
After having created a fresh new project, running the unchanged code with the
--version
flag ends up in a Traceback:RuntimeError: Could not determine the version for None automatically.
The
main()
function has the@click.version_option()
decorator defined, without options. Should Click's version_option be passed the version number explicitly like this?@click.version_option(version="0.1.0")
Making this change results in the expected behavior:
Or will that cause issues with cookietemple's version bumping?
That function's documentation has some info about
importlib.metadata.version()
being used to determine the version if it is not passed, maybe this means this code works fine when running from a full package, but shouldn't it also work when running from a development setup?Full Traceback (Click to expand)
To Reproduce
Steps to reproduce the behavior:
--version
flag, in my case:poetry run python timelog_tracker\__main__.py --version
Expected behavior
I would have expected the program to output the version number that was indicated when creating the project.
System:
pipx
)pipx
Additional context
None
The text was updated successfully, but these errors were encountered: