-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Derive version automatically from source control
- Loading branch information
1 parent
bc12a9e
commit 5e30a72
Showing
4 changed files
with
122 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
include CHANGES.rst | ||
include LICENSE | ||
include README.rst | ||
include *.rst | ||
global-include _version_lock.py | ||
|
||
include .coveragerc | ||
include pylintrc | ||
include pytest.ini | ||
include test_*.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
try: | ||
# For distributions | ||
from ._version_lock import version # type: ignore # pylint: disable=unused-import | ||
except ImportError: | ||
# For development trees | ||
from os import environ | ||
from os.path import dirname, join | ||
|
||
try: | ||
from dulwich.porcelain import describe # type: ignore | ||
except ImportError: | ||
from subprocess import SubprocessError, run | ||
from warnings import warn | ||
|
||
def describe(repo): | ||
env = dict(environ) | ||
env['GIT_DIR'] = repo | ||
try: | ||
return (run(['git', 'describe'], | ||
capture_output=True, | ||
check=True, | ||
env=env, | ||
encoding='ascii') | ||
.stdout.rstrip('\n')) | ||
except SubprocessError as e: # pragma: no cover | ||
warn("Could not determine dvrip version: {}" | ||
.format(e)) | ||
return '0.0.0-0-unknown' | ||
|
||
if '_repo' not in globals(): # except for setup.py | ||
_repo = join(dirname(dirname(__file__)), '.git') | ||
_desc = describe(_repo).split('-', 3) | ||
version = ('{0}.dev{1}+{2}'.format(*_desc) | ||
if len(_desc) == 3 else _desc[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters