-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
124 lines (91 loc) · 3.55 KB
/
setup.py
File metadata and controls
124 lines (91 loc) · 3.55 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# This file is adapted from
# https://github.com/awslabs/sockeye/blob/master/setup.py
import os
import re
import subprocess
from setuptools import setup, find_packages
from contextlib import contextmanager
ROOT = os.path.dirname(__file__)
def get_long_description():
with open(os.path.join(ROOT, 'README.md'), encoding='utf-8') as f:
markdown_txt = f.read()
return markdown_txt
def get_version():
version_re = re.compile(r'''__version__ = ['"]([0-9.]+)['"]''')
init = open(os.path.join(ROOT, 'sign_language_segmentation', '__init__.py')).read()
return version_re.search(init).group(1)
def get_git_hash():
# noinspection PyBroadException
try:
sp = subprocess.Popen(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out_str = sp.communicate()[0].decode("utf-8").strip()
return out_str
except:
return "unkown"
@contextmanager
def temporarily_write_git_hash(git_hash, filename=os.path.join('sign_language_segmentation', 'git_version.py')):
"""Temporarily create a module git_version in sign_language_segmentation so that it will be
included when installing and packaging."""
content = """
# This file is automatically generated in setup.py
git_hash = "%s"
""" % git_hash
if os.path.exists(filename):
raise RuntimeError("%s already exists, will not overwrite" % filename)
with open(filename, "w") as out:
out.write(content)
# noinspection PyBroadException
try:
yield
except:
raise
finally:
os.remove(filename)
requirements_map = {"git+https://github.com/sign-language-processing/datasets.git":
"sign-language-datasets @ git+https://github.com/sign-language-processing/datasets.git",
"git+https://github.com/bricksdont/pose-format.git@add_tf_tensor_tests":
"pose-format @ git+https://github.com/bricksdont/pose-format.git@add_tf_tensor_tests"}
def get_requirements(filename):
with open(os.path.join(ROOT, filename)) as f:
requirements = []
for line in f:
line = line.rstrip()
if "git+" in line:
line = requirements_map[line]
requirements.append(line)
return requirements
install_requires = get_requirements('requirements.txt')
entry_points = {
'console_scripts': [
'sign-language-segmentation-create-tfrecord = sign_language_segmentation.create_tfrecord:main',
'sign-language-segmentation-train = sign_language_segmentation.train:main',
],
}
args = dict(
name='sign_language_segmentation',
version=get_version(),
description='Segmentation models for sign languages',
long_description=get_long_description(),
long_description_content_type="text/markdown",
url='https://github.com/bricksdont/sign-segmentation',
author='Mathias Müller',
author_email='mathias.mueller@uzh.ch',
maintainer_email='mathias.mueller@uzh.ch',
license='MIT License',
python_requires='>=3',
packages=find_packages(exclude=("test", "test.*")),
setup_requires=['pytest-runner'],
tests_require=['pytest', 'pytest-cov', 'pillow'],
install_requires=install_requires,
entry_points=entry_points,
package_data={
# If any package contains *.poseheader files, include them:
"": ["*.poseheader"],
},
classifiers=[
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3 :: Only',
]
)
with temporarily_write_git_hash(get_git_hash()):
setup(**args)