I'm having fun with python packaging today. i want to populate the
__version__ keyword in my package, but only when it's pip install'd. if I'm using it locally, then I want the version to come from
git describe. So what i have is this:
def get_version(): """ Get the version for the ground station. If the __version__.py exists, it uses the version in there. Otherwise it uses the git describe version """ try: from . import __version__ return __version__.__version__ except ImportError: return get_git_tag() def get_git_tag(): """Return string of latest (annotated) git tag""" version = subprocess.check_output(["git", "describe", "--dirty", "--long"]).decode() version = version.rstrip() return version
which works great. But I want to make sure
__version__.py only exists on released versions, not in my working repo--and I don't want to risk having a
__version__.py leak into my development workspace.
So at this point, I'm researching ways to create a file in setup.py that will only exist in the distrubuted version of my package. Any have any tips or warnings as i do this?