-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print version info in all generated files
- Loading branch information
1 parent
f9fdffa
commit 0720f40
Showing
9 changed files
with
82 additions
and
14 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
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
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 |
---|---|---|
@@ -1,4 +1,40 @@ | ||
"""Version metadata file. This file is overridden by setuptools with the | ||
actual version when the module is "built".""" | ||
|
||
__version__ = 'not-installed' | ||
import os | ||
from subprocess import Popen, PIPE | ||
|
||
|
||
def _run_cmd(*args): | ||
"""Runs a command using subprocess, returning a two-tuple consisting of | ||
the return code and a binary string containing the data written to | ||
stdout.""" | ||
proc = Popen( | ||
args, stdin=PIPE, stdout=PIPE, stderr=PIPE, | ||
cwd=os.path.dirname(__file__)) | ||
output, _ = proc.communicate() | ||
code = proc.returncode | ||
return code, output | ||
|
||
|
||
def _get_version(): | ||
"""Attempts to get vhdmmio's version at runtime using `git`.""" | ||
try: | ||
code, output = _run_cmd('git', 'describe', '--tags') | ||
if code: | ||
return 'unknown' | ||
output = output.decode('utf8').strip().split('-') | ||
if len(output) != 3: | ||
return 'unknown' | ||
version = '%s+%s' % (output[0], output[2]) | ||
|
||
code, _ = _run_cmd('git', 'diff', '--quiet') | ||
if code: | ||
version += '+dirty' | ||
|
||
return version | ||
except OSError: | ||
return 'unknown' | ||
|
||
|
||
__version__ = _get_version() |
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
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
2 changes: 2 additions & 0 deletions
2
vhdmmio/vhdl/vhdmmio_pkg.vhd → vhdmmio/vhdl/vhdmmio_pkg.template.vhd
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