-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.py
68 lines (55 loc) · 2 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""
Package setup for the yellowgreen-multi module.
"""
import os
import textwrap
from setuptools import find_packages, setup
def node_and_dirty_tag_scheme(version):
"""Keep the hash when distance with the dirty tag local scheme."""
if version.exact or version.node is None:
return version.format_choice('', '+dirty')
return version.format_choice('+{node}', '+{node}.dirty')
def parse_git_describe_string(_root, config=None):
"""
Return a setuptools_scm parsed version from a Git describe string found in the environment
variable GIT_DESCRIBE_STRING.
:param str _root: Relative path to cwd, used for finding the scm root.
:param setuptools_scm.config.Configuration config: Configuration instance.
:return: Parsed version or ``None``.
:rtype: setuptools_scm.version.ScmVersion
"""
# pylint: disable=import-error
# Those imports are only available at install time
from setuptools_scm.git import _git_parse_describe
from setuptools_scm.version import meta
git_describe = os.environ.get('GIT_DESCRIBE_STRING')
if not git_describe:
return None
tag, number, node, dirty = _git_parse_describe(git_describe)
kwargs = {'distance': number} if number else {}
return meta(tag, dirty=dirty, node=node, config=config, **kwargs)
VERSION_CONFIG = {
'fallback_version': '0.0.0+scm.missing',
'local_scheme': node_and_dirty_tag_scheme,
'write_to': 'src/yellowgreenmulti/version.py',
'write_to_template': textwrap.dedent('''\
"""
File generated by setuptools_scm.
Do not track in version control.
"""
__version__ = {version!r}
''')
}
# Add a custom function to parse the result of a git describe command from an environment
# variable, this is useful when the git history is not available at build time.
if 'GIT_DESCRIBE_STRING' in os.environ:
VERSION_CONFIG['parse'] = parse_git_describe_string
# Main package setup configuration
# See also setup.cfg
SETUP_PARAMS = dict(
use_scm_version=VERSION_CONFIG,
packages=find_packages('src'),
package_dir={'': 'src'}
)
if __name__ == '__main__':
setup(**SETUP_PARAMS)