-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
setup.py
64 lines (48 loc) · 1.87 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
import os
import sys
from pathlib import Path
from setuptools import find_namespace_packages, setup
ROOT_FOLDER = Path(__file__).parent.absolute()
REQUIREMENTS_FOLDER = ROOT_FOLDER / "requirements"
# Since we're importing `redbot` package, we have to ensure that it's in sys.path.
sys.path.insert(0, str(ROOT_FOLDER))
from redbot import VersionInfo
version, _ = VersionInfo._get_version(ignore_installed=True)
def get_requirements(fp):
return [
line.strip()
for line in fp.read().splitlines()
if line.strip() and not line.strip().startswith("#")
]
def extras_combined(*extra_names):
return list(
{
req
for extra_name, extra_reqs in extras_require.items()
if not extra_names or extra_name in extra_names
for req in extra_reqs
}
)
with open(REQUIREMENTS_FOLDER / "base.txt", encoding="utf-8") as fp:
install_requires = get_requirements(fp)
extras_require = {}
for file in REQUIREMENTS_FOLDER.glob("extra-*.txt"):
with file.open(encoding="utf-8") as fp:
extras_require[file.stem[len("extra-") :]] = get_requirements(fp)
extras_require["dev"] = extras_combined()
extras_require["all"] = extras_combined("postgres")
python_requires = ">=3.8.1"
if not os.getenv("TOX_RED", False) or sys.version_info < (3, 12):
python_requires += ",<3.12"
# Metadata and options defined in pyproject.toml
setup(
version=version,
python_requires=python_requires,
# TODO: use [tool.setuptools.dynamic] table once this feature gets out of beta
install_requires=install_requires,
extras_require=extras_require,
# TODO: use [project] table once PEP 639 gets accepted
license_files=["LICENSE", "redbot/**/*.LICENSE"],
# TODO: use [tool.setuptools.packages] table once this feature gets out of beta
packages=find_namespace_packages(include=["redbot", "redbot.*"]),
)