-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathsetup.py
More file actions
102 lines (83 loc) · 3.3 KB
/
setup.py
File metadata and controls
102 lines (83 loc) · 3.3 KB
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
# This library is self-using and auto-bootstraps itself
import os
import subprocess
import sys
import setuptools
HERE = os.path.dirname(os.path.abspath(__file__))
EGG = os.path.join(HERE, "setupmeta.egg-info")
ENTRY_POINTS = """
[distutils.commands]
check = setupmeta.commands:CheckCommand
explain = setupmeta.commands:ExplainCommand
version = setupmeta.commands:VersionCommand
[setuptools.finalize_distribution_options]
setupmeta = setupmeta.hook:finalize_dist
[distutils.setup_keywords]
setup_requires = setupmeta.hook:register_keyword
versioning = setupmeta.hook:register_keyword
"""
def run_bootstrap(message):
sys.stderr.write(f"--- Bootstrapping {message}\n")
p = subprocess.Popen([sys.executable, "setup.py", "egg_info"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) # noqa: S603
output, error = p.communicate()
if p.returncode:
print(output)
sys.stderr.write(f"{error}\n")
sys.exit(p.returncode)
if not os.path.isdir(EGG):
sys.exit("Could not bootstrap egg-info")
def complete_args(args):
args["setup_requires"] = ["setupmeta"]
args["install_requires"] = ["setuptools>=67"]
args["versioning"] = "dev"
if __name__ == "__main__":
os.chdir(HERE)
have_egg = os.path.isdir(EGG)
# Explicit on entry points due to bootstrap
args = {
"name": "setupmeta",
"entry_points": ENTRY_POINTS,
"packages": ["setupmeta"],
"python_requires": ">=3.7",
"zip_safe": True,
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX",
"Operating System :: Unix",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"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",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Version Control",
"Topic :: System :: Installation/Setup",
"Topic :: System :: Software Distribution",
"Topic :: Utilities",
],
}
if have_egg:
# We're bootstrapped, we can self-refer
complete_args(args)
if len(sys.argv) == 2 and sys.argv[1] == "egg_info":
# egg_info as lone command is bootstrap mode
setuptools.setup(**args)
sys.exit(0)
if not have_egg:
# No egg yet, not running egg_info -> must bootstrap
run_bootstrap("first pass")
# Rerun one more time to get the right VERSION filled-in etc
run_bootstrap("second pass")
# We're bootstrapped now, we can self-refer
complete_args(args)
setuptools.setup(**args)