support overriding versioneer

This commit is contained in:
Sebastien Bourdeauducq 2019-02-17 14:49:45 +08:00
parent 861ad0a62c
commit 40a0cf806d
2 changed files with 18 additions and 0 deletions

View File

@ -481,6 +481,12 @@ def get_versions():
# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
# case we can only use expanded keywords. # case we can only use expanded keywords.
override = os.getenv("VERSIONEER_OVERRIDE")
if override:
return {"version": override, "full-revisionid": None,
"dirty": None,
"error": None, "date": None}
cfg = get_config() cfg = get_config()
verbose = cfg.verbose verbose = cfg.verbose

View File

@ -901,6 +901,12 @@ def get_versions():
# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
# case we can only use expanded keywords. # case we can only use expanded keywords.
override = os.getenv("VERSIONEER_OVERRIDE")
if override:
return {"version": override, "full-revisionid": None,
"dirty": None,
"error": None, "date": None}
cfg = get_config() cfg = get_config()
verbose = cfg.verbose verbose = cfg.verbose
@ -1404,6 +1410,12 @@ def get_versions(verbose=False):
Returns dict with two keys: 'version' and 'full'. Returns dict with two keys: 'version' and 'full'.
""" """
override = os.getenv("VERSIONEER_OVERRIDE")
if override:
return {"version": override, "full-revisionid": None,
"dirty": None,
"error": None, "date": None}
if "versioneer" in sys.modules: if "versioneer" in sys.modules:
# see the discussion in cmdclass.py:get_cmdclass() # see the discussion in cmdclass.py:get_cmdclass()
del sys.modules["versioneer"] del sys.modules["versioneer"]