-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathsetup.py
67 lines (49 loc) · 1.81 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
import codecs
import re
from os import path
from setuptools import find_packages, setup
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, "README.md"), "r") as fh:
long_description = fh.read()
def read(*parts):
with codecs.open(path.join(this_directory, *parts), "r") as fp:
return fp.read()
def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
def get_requirements(file_name):
"""Strip a requirement files of all comments
Args:
file_name (string): File which contains requirements
Returns:
list: list of requirements
"""
with open(path.join(this_directory, "{}.txt".format(file_name)), "r") as file:
reqs = []
for req in file.readlines():
if not req.startswith("#"):
if req.startswith("git+"):
name = req.split("#")[-1].replace("egg=", "").strip()
req.replace("git+", "")
reqs.append(f"{name} @ {req}")
else:
reqs.append(req)
return reqs
INSTALL_REQUIRES = get_requirements("requirements")
TESTS_REQUIRES = get_requirements("requirements-tests")
EXTRA_REQUIRE = {"tests": TESTS_REQUIRES}
setup(
name="deepsphere",
version=find_version("deepsphere", "__init__.py"),
description="Deep Sphere package",
long_description=long_description,
long_description_content_type="text/markdown",
author="Arcanite",
author_email="[email protected]",
install_requires=INSTALL_REQUIRES,
extras_require=EXTRA_REQUIRE,
packages=find_packages(),
)