[TIP] Tox : Can I retrieve a project version from within tox.ini
holger krekel
holger at merlinux.eu
Tue Oct 21 12:17:20 PDT 2014
Hi Laurent,
On Tue, Oct 21, 2014 at 11:58 -0700, Laurent Brack wrote:
> I was wondering if it was possible to retrieve a project version
> from within tox other than by exporting it to an environment
> variable prior to running tox.
>
> something equivalent to export VERSION=`myproject --version`
>
> I know that you can do something like {env:MY_VERSION:1.2} but this
> requires that the version env. var is set prior to calling tox.
>
> being able to extract this information during a tox run would be useful.
In principle these lines work if you need a version from python code:
import pkg_resources
print (pkg_resources.get_distribution("myproject").version)
If you for some reason can't do that you need to wrap what you call with
a script that uses the above to set an environment variable before
calling the script.
cheers,
holger
More information about the testing-in-python
mailing list