-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup.py
85 lines (67 loc) · 2.44 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
import os
import re
import typing
from setuptools import setup
def get_version(package) -> str:
"""Return package version as listed in `__version__` in `init.py`."""
path = os.path.join(package, "__init__.py")
version = ""
with open(path, "r", encoding="utf8") as init_py:
version = re.search(
r"^__version__\s*=\s*['\"]([^'\"]*)['\"]",
init_py.read(),
re.MULTILINE,
).group(1)
if not version:
raise RuntimeError(f"__version__ is not set in {path}")
return version
def get_packages(package) -> typing.List[str]:
"""Return root package and all sub-packages."""
return [
dirpath.replace("\\", ".")
for dirpath, *_ in os.walk(package)
if os.path.exists(os.path.join(dirpath, "__init__.py"))
]
def get_long_description(filename: str = "README.rst") -> str:
"""Return the README."""
with open(filename, "r", encoding="utf8") as readme:
long_description = readme.read()
return long_description
def get_requirements(filename: str = "requirements.txt") -> typing.List[str]:
"""Return the requirements."""
requirements = []
with open(filename, "r", encoding="utf8") as requirements_txt:
requirements = requirements_txt.read().splitlines()
return requirements
extra_requires = {
"async": get_requirements("async-requirements.txt"),
}
setup(
name="codingame",
version=get_version("codingame"),
url="https://github.com/takos22/codingame",
license="MIT",
description="Pythonic wrapper for the undocumented CodinGame API.",
long_description=get_long_description(),
long_description_content_type="text/x-rst",
author="takos22",
author_email="[email protected]",
packages=get_packages("codingame"),
python_requires=">=3.8",
install_requires=get_requirements(),
extras_require=extra_requires,
project_urls={
"Documentation": "https://codingame.readthedocs.io/",
"Issue tracker": "https://github.com/takos22/codingame/issues",
},
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
)