-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.py
147 lines (120 loc) · 3.83 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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import os
from importlib.util import module_from_spec, spec_from_file_location
from typing import List
import setuptools
_PATH_ROOT = os.path.dirname(__file__)
def _load_readme(file_name: str = "README.md") -> str:
"""
Load readme from a text file.
Args:
file_name (str, optional): File name that contains the readme. Defaults to "README.md".
Returns:
str: Readme text.
"""
with open(os.path.join(_PATH_ROOT, file_name), "r", encoding="utf-8") as file:
readme = file.read()
return readme
def _load_requirements(
file_name: str = "requirements.txt", comment_char: str = "#"
) -> List[str]:
"""
Load requirements from a text file.
Args:
file_name (str, optional): File name. Defaults to "requirements.txt".
comment_char (str, optional): Disregard lines starting with this character. Defaults to "#".
Returns:
List[str]: List of requirements.
"""
# Open the file
with open(os.path.join(_PATH_ROOT, file_name), "r", encoding="utf-8") as file:
lines = [ln.strip() for ln in file.readlines()]
reqs = []
for line in lines:
# Disregard comments
if comment_char in line:
line = line[: line.index(comment_char)].strip()
# Disregard http or @http lines
if line.startswith("http") or "@http" in line:
continue
# Add the line to the list
if line:
reqs.append(line)
return reqs
def _load_version(file_name: str = "satellighte/version.py") -> str:
"""
Load readme from a text file.
Args:
file_name (str, optional): File name that contains the verison. Defaults to ""satellighte/version.py"".
Returns:
str: Version.
"""
with open(os.path.join(_PATH_ROOT, file_name), "r", encoding="utf-8") as file:
version = file.read().split("=")[-1].replace("'", "").replace('"', "").strip()
return version
def _load_py_module(fname, pkg="satellighte"):
spec = spec_from_file_location(
os.path.join(pkg, fname), os.path.join(_PATH_ROOT, pkg, fname)
)
py_module = module_from_spec(spec)
spec.loader.exec_module(py_module)
return py_module
about = _load_py_module("__about__.py")
__requirements__ = _load_requirements()
test_require = [
"pytest>=6.0.0",
"pytest-pylint",
"pytest-cov",
"pylint",
"black",
]
deploy_require = [
"pytest>=6.0.0",
"pytest-pylint",
"pytest-cov",
"pylint",
"black",
]
docs_require = [
"sphinxemoji",
"sphinx_rtd_theme",
"recommonmark",
"sphinx_markdown_tables",
"sphinxcontrib-napoleon",
"sphinx-autodoc-typehints",
"nbsphinx",
"furo",
]
extras_require = {
"test": test_require,
"docs": docs_require,
"deploy": __requirements__ + deploy_require,
"all": __requirements__ + test_require + deploy_require,
}
setuptools.setup(
name=about.__pkg_name__,
version=_load_version(),
description=about.__description__,
author=about.__author__,
author_email=about.__author_email__,
url=about.__homepage__,
license=about.__license__,
packages=setuptools.find_packages(),
include_package_data=True,
long_description=_load_readme(),
long_description_content_type="text/markdown",
python_requires=">=3.8",
extras_require=extras_require,
setup_requires=[],
install_requires=__requirements__,
classifiers=[
# Indicate who your project is intended for
"Topic :: Scientific/Engineering :: Artificial Intelligence",
# Pick your license as you wish
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
# Specify the Python versions you support here.
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
)