-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathsetup.py
114 lines (96 loc) · 3.74 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
import pathlib
import re
from setuptools import setup, find_packages
# Root directory
# (README.md, mangadex_downloader/__init__.py)
HERE = pathlib.Path(__file__).parent
README = (HERE / "README.md").read_text()
init_file = (HERE / "mangadex_downloader/__init__.py").read_text()
def get_version():
"""Get version of the app"""
re_version = r'__version__ = \"([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.{0,})\"'
_version = re.search(re_version, init_file)
if _version is None:
raise RuntimeError("Version is not set")
return _version.group(1)
def get_value_var(var_name):
"""Get value of `__{var_name}__` from `mangadex_downloader/__init__.py`"""
var = f'__{var_name}__'
regex = '%s = "(.{1,})"' % var
found = re.search(regex, init_file)
if found is None:
raise RuntimeError(f'{var} is not set in "mangadex_downloader/__init__.py"')
return found.group(1)
def get_requirements():
"""Return tuple of library needed for app to run"""
main = []
try:
with open('./requirements.txt', 'r') as r:
main = r.read().splitlines()
except FileNotFoundError:
raise RuntimeError("requirements.txt is needed to build mangadex-downloader")
if not main:
raise RuntimeError("requirements.txt have no necessary libraries inside of it")
docs = []
try:
with open('./requirements-docs.txt', 'r') as r:
docs = r.read().splitlines()
except FileNotFoundError:
# There is no docs requirements
# Developers can ignore this error and continue to install without any problem.
# However, this is needed if developers want to create documentation in readthedocs.org or local device.
pass
optional = []
try:
with open('./requirements-optional.txt', 'r') as r:
optional = r.read().splitlines()
except FileNotFoundError:
raise RuntimeError("requirements-optional.txt is needed to build mangadex-downloader")
if not optional:
raise RuntimeError("requirements-optional.txt have no necessary libraries inside of it")
return main, {
"docs": docs,
"optional": optional
}
# Get requirements needed to build app
requires_main, extras_require = get_requirements()
# Get all modules
packages = find_packages('.')
# Get repository
repo = get_value_var('repository')
# Finally run main setup
setup(
name = 'mangadex-downloader',
packages = packages,
version = get_version(),
license=get_value_var('license'),
description = get_value_var('description'),
long_description= README,
long_description_content_type= 'text/markdown',
author = get_value_var('author'),
author_email = get_value_var('author_email'),
url = f'https://github.com/{repo}',
download_url = f'https://github.com/{repo}/releases',
keywords = ['mangadex'],
install_requires=requires_main,
extras_require=extras_require,
entry_points = {
'console_scripts': [
'mangadex-downloader=mangadex_downloader.__main__:main',
'mangadex-dl=mangadex_downloader.__main__:main'
]
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],
python_requires='>=3.8',
include_package_data=True
)