forked from ilastik/ilastikrag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
54 lines (48 loc) · 2.13 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
import os
import subprocess
from setuptools import setup, find_packages
def determine_version(default_version_file):
# If running in conda-build, read version from the environment.
if 'PKG_VERSION' in os.environ:
auto_version = os.environ['PKG_VERSION']
else:
# Try getting it from the latest git tag
try:
commit_details = subprocess.check_output("git describe --tags --long HEAD".split()).decode('utf-8')
last_tag, commits_since_tag = commit_details.split('-')[:2]
auto_version = last_tag
if int(commits_since_tag) > 0:
# Append commit count to version
# (BTW, the .post## convention is recognized by PEP440)
# For example: '0.2.post5'
auto_version = last_tag + '.post' + commits_since_tag
except subprocess.CalledProcessError:
# Weird: We're not in a git repo or conda-bld/work.
# Read the default value from the source code, I guess.
version_globals = {}
exec(compile(open(default_version_file).read(), default_version_file, 'exec'), version_globals)
auto_version = version_globals['__version__']
return auto_version
VERSION_FILE = 'ilastikrag/version.py'
auto_version = determine_version(VERSION_FILE)
# Cache version.py, then overwrite it with the auto-version
with open(VERSION_FILE, 'r') as f:
orig_version_contents = f.read()
with open(VERSION_FILE, 'w') as f:
f.write("__version__ = '{}'\n".format(auto_version))
try:
setup(name='ilastikrag',
version=auto_version,
description='ND Region Adjacency Graph with edge feature algorithms',
author='Stuart Berg',
author_email='[email protected]',
url='github.com/stuarteberg/ilastikrag',
packages=find_packages()
## see conda-recipe/meta.yaml for dependency information
##install_requires=['numpy', 'h5py', 'pandas', 'vigra', 'networkx']
)
finally:
# Restore the version.py source as it was
with open(VERSION_FILE, 'w') as f:
f.write(orig_version_contents)