Embedding version in command-line program
Loris Bennett
loris.bennett at fu-berlin.de
Thu Oct 8 09:00:37 EDT 2020
Marco Sulla <Marco.Sulla.Python at gmail.com> writes:
> On Wed, 7 Oct 2020 at 14:16, Loris Bennett <loris.bennett at fu-berlin.de>
> wrote:
>
>> But the toml file isn't part of the distribution and so it won't be
>> installed.
>>
>> I suppose I could write a separate program which parses the toml file
>> and then just injects the version into __init__.py.
>
> Yes, I do not know poetry, but I suppose you can generate it in its
> setup. I usually create a separate VERSION file and I read it in
> __init__.py. Other people creates a version.py that is evaled inside
> __init__.py
I ended up using the module
poetry_version
which allows one to extract the version like this:
import poetry_version
__version__ = poetry_version.extract(source_file=__file__)
Cheers,
Loris
--
This signature is currently under construction.
More information about the Python-list
mailing list