Skip to content

Commit

Permalink
Merge pull request #21 from scipp/version
Browse files Browse the repository at this point in the history
runtime __version__ info
  • Loading branch information
nvaytet authored Apr 27, 2021
2 parents aa03775 + d5f93b2 commit 15c9524
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.pyc
.idea
_fixed_version.py
9 changes: 8 additions & 1 deletion conda/bld.bat
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
move src\ess %CONDA_PREFIX%\lib\
@echo off
echo | set /p="__version__ = '" > _fixed_version.py
python src\ess\_version.py > output_ver
set /p version=<output_ver
echo | set /p=%version%' >> _fixed_version.py
del output_ver
move _fixed_version.py src\ess
move src\ess %CONDA_PREFIX%\lib\
3 changes: 3 additions & 0 deletions conda/build.sh
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
set -ex
echo __version__ = '"'$(python src/ess/_version.py)'"' > _fixed_version.py
cp _fixed_version.py src/ess/
cp -r src/ess "$CONDA_PREFIX"/lib/python*/
1 change: 1 addition & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ requirements:
- python {{ python }}
- sphinx>=1.6
- sphinx_rtd_theme
- gitpython
run:
- python {{ python }}
- scippneutron
Expand Down
1 change: 1 addition & 0 deletions ess-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ dependencies:
- astropy
- matplotlib
- python
- gitpython
2 changes: 2 additions & 0 deletions src/ess/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import _version
__version__ = _version.__version__
19 changes: 19 additions & 0 deletions src/ess/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os


def _version():
dir_path = os.path.dirname(os.path.realpath(__file__))
try:
import git
g = git.cmd.Git(dir_path)
g.fetch()
return g.describe('--tags')
except (ImportError, git.exc.GitError):
from . import _fixed_version
return _fixed_version.__version__


if __name__ == "__main__":
print(_version())
else:
__version__ = _version()

0 comments on commit 15c9524

Please sign in to comment.