Embedding version in command-line program

Tony Flury tony.flury at btinternet.com
Thu Oct 15 05:04:22 EDT 2020


On 07/10/2020 12:06, Loris Bennett wrote:
> Hi,
>
> I have written a program, which I can run on the command-line thus
>
>    mypyprog --version
>
> and the get the version, which is currently derived from a variable in
> the main module file.
>
> However, I also have the version in an __init__.py file and in a
> pyproject.toml (as I'm using poetry, otherwise this would be in
> setup.py).
>
> What's the best way of reducing these three places where the version is
> defined to a single one?
>
> Cheers,
>
> Loris
My top level package always has a version.py file which defines 
__version__, __author__ etc. I am not sure if that helps in your .toml 
file though - is it executed or does it have the ability to read files 
when it creates the distributable ?


More information about the Python-list mailing list