Closed wabiloo closed 3 months ago
The
__version__.py
is in the .gitignore
That will cause Poetry to ignore it as well, by default:
https://python-poetry.org/docs/pyproject/#include-and-exclude
If a VCS is being used for a package, the exclude field will be seeded with the VCS’ ignore settings (.gitignore for git for example).
Explicitly declaring entries in include will negate VCS' ignore settings.
If you add a line for include = ["opinionated_media_processor/__version__.py"]
in the [tool.poetry]
section, then it should work :)
I ended up removing the __version__.py
from .gitignore and committing it with "0.0.0" inside.
On running poetry build
I (naturally) get it into the dist file, with a proper version number. That sort of takes care of that.
However that means I cannot wrap the application in a Docker image from local files. So I changed that do copy the dist file and pip install it in the image.
Still, I'm wondering what the best/recommended way to go is.
With this method I obviously need to remember to never commit that version file if I use poetry dynamic-versioning
command. But the same applies to the pyproject.toml file in this case anyway (which can't go in .gitignore)...
Why is it recommended in the first place not to add the version file to VCS? Seems it could make running files locally more error-prone...
(I'm still a beginner in Python when it comes to that sort of thing...)
Why is it recommended in the first place not to add the version file to VCS? Seems it could make running files locally more error-prone...
Mainly so you don't have to worry about accidentally committing the plugin's changes when using commands like poetry build
or poetry run
. You're right that you do still have to be careful with poetry dynamic-versioning
, of course, but for most commands, you don't have to think about it.
Hi
My package relies on a
__version__.py
file which contains a__version__
string. I would like to understand whether it's recommended to not add it to VCS, as your documentation seems to imply...I did this, with the following configuration:
The
__version__.py
is in the .gitignoreHowever, after building and installing locally, the
omp --version
command, I get an error that seems to indicate that the file is missing:And indeed, if I unzip the dist file, there is no such file.