I'm developing a python script and the last stable version of this script is installed on my PC (using setuptools).
How can I know (from the python source) that the running script is the installed version or development version. (If I call python -m awesomescript
in the repository, the dev version will start otherwise the installed version.)
My only idea is to check if the script file is located under the sitepackages, but that doesn't seem as a "beauty" solution.
UPDATE
The main goal is to get proper version, using pbr. The following method can be used to get the version of the script within the code. (Fethced from this post.)
import pkg_resources # part of setuptools
version = pkg_resources.require("MyProject")[0].version
However the pkg_resources.require("MyProject")[0].version
will return the version of the installed variant, which is irrelevant if I run development variant of the script.