Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +3 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/__pycache__/__init__.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/__pycache__/config.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/__pycache__/errors.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/__pycache__/extension.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/__pycache__/util.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__init__.py +31 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/__init__.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/bdist.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/bdist_dumb.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/bdist_msi.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/bdist_rpm.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/bdist_wininst.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/build.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/build_clib.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/build_ext.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/build_py.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/build_scripts.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/check.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/clean.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/config.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/install.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/install_data.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/install_egg_info.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/install_headers.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/install_lib.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/install_scripts.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/py37compat.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/register.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/sdist.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/upload.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/bdist.py +143 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/bdist_dumb.py +123 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/bdist_msi.py +749 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/bdist_rpm.py +579 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/bdist_wininst.py +377 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/build.py +157 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/build_clib.py +209 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py +755 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/build_py.py +392 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/build_scripts.py +152 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/check.py +148 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/clean.py +76 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/config.py +344 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/install.py +721 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/install_data.py +79 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/install_egg_info.py +84 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/install_headers.py +47 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/install_lib.py +217 -0
- env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/install_scripts.py +60 -0
.gitattributes
CHANGED
@@ -130,3 +130,6 @@ env-llmeval/lib/python3.10/site-packages/scipy.libs/libopenblasp-r0-24bff013.3.2
|
|
130 |
env-llmeval/lib/python3.10/site-packages/scipy.libs/libgfortran-040039e1.so.5.0.0 filter=lfs diff=lfs merge=lfs -text
|
131 |
llmeval-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so filter=lfs diff=lfs merge=lfs -text
|
132 |
env-llmeval/lib/python3.10/site-packages/yaml/_yaml.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
130 |
env-llmeval/lib/python3.10/site-packages/scipy.libs/libgfortran-040039e1.so.5.0.0 filter=lfs diff=lfs merge=lfs -text
|
131 |
llmeval-env/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so filter=lfs diff=lfs merge=lfs -text
|
132 |
env-llmeval/lib/python3.10/site-packages/yaml/_yaml.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
133 |
+
env-llmeval/lib/python3.10/site-packages/triton/_C/libtriton.so filter=lfs diff=lfs merge=lfs -text
|
134 |
+
env-llmeval/lib/python3.10/site-packages/zstandard/backend_c.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
135 |
+
env-llmeval/lib/python3.10/site-packages/zstandard/_cffi.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (555 Bytes). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/__pycache__/config.cpython-310.pyc
ADDED
Binary file (3.59 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/__pycache__/errors.cpython-310.pyc
ADDED
Binary file (4.99 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/__pycache__/extension.cpython-310.pyc
ADDED
Binary file (7.01 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/__pycache__/util.cpython-310.pyc
ADDED
Binary file (14.7 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__init__.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command
|
2 |
+
|
3 |
+
Package containing implementation of all the standard Distutils
|
4 |
+
commands."""
|
5 |
+
|
6 |
+
__all__ = ['build',
|
7 |
+
'build_py',
|
8 |
+
'build_ext',
|
9 |
+
'build_clib',
|
10 |
+
'build_scripts',
|
11 |
+
'clean',
|
12 |
+
'install',
|
13 |
+
'install_lib',
|
14 |
+
'install_headers',
|
15 |
+
'install_scripts',
|
16 |
+
'install_data',
|
17 |
+
'sdist',
|
18 |
+
'register',
|
19 |
+
'bdist',
|
20 |
+
'bdist_dumb',
|
21 |
+
'bdist_rpm',
|
22 |
+
'bdist_wininst',
|
23 |
+
'check',
|
24 |
+
'upload',
|
25 |
+
# These two are reserved for future use:
|
26 |
+
#'bdist_sdux',
|
27 |
+
#'bdist_pkgtool',
|
28 |
+
# Note:
|
29 |
+
# bdist_packager is not included because it only provides
|
30 |
+
# an abstract base class
|
31 |
+
]
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (528 Bytes). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/bdist.cpython-310.pyc
ADDED
Binary file (3.66 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/bdist_dumb.cpython-310.pyc
ADDED
Binary file (3.64 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/bdist_msi.cpython-310.pyc
ADDED
Binary file (19.7 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/bdist_rpm.cpython-310.pyc
ADDED
Binary file (12.3 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/bdist_wininst.cpython-310.pyc
ADDED
Binary file (8.63 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/build.cpython-310.pyc
ADDED
Binary file (3.89 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/build_clib.cpython-310.pyc
ADDED
Binary file (4.87 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/build_ext.cpython-310.pyc
ADDED
Binary file (16.2 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/build_py.cpython-310.pyc
ADDED
Binary file (9.89 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/build_scripts.cpython-310.pyc
ADDED
Binary file (4.01 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/check.cpython-310.pyc
ADDED
Binary file (5.01 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/clean.cpython-310.pyc
ADDED
Binary file (2.15 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/config.cpython-310.pyc
ADDED
Binary file (10.3 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/install.cpython-310.pyc
ADDED
Binary file (15.3 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/install_data.cpython-310.pyc
ADDED
Binary file (2.34 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/install_egg_info.cpython-310.pyc
ADDED
Binary file (3.31 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/install_headers.cpython-310.pyc
ADDED
Binary file (1.77 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/install_lib.cpython-310.pyc
ADDED
Binary file (5.17 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/install_scripts.cpython-310.pyc
ADDED
Binary file (2.2 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/py37compat.cpython-310.pyc
ADDED
Binary file (1.04 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/register.cpython-310.pyc
ADDED
Binary file (8.68 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/sdist.cpython-310.pyc
ADDED
Binary file (14.5 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/__pycache__/upload.cpython-310.pyc
ADDED
Binary file (5.37 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/bdist.py
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.bdist
|
2 |
+
|
3 |
+
Implements the Distutils 'bdist' command (create a built [binary]
|
4 |
+
distribution)."""
|
5 |
+
|
6 |
+
import os
|
7 |
+
from distutils.core import Command
|
8 |
+
from distutils.errors import *
|
9 |
+
from distutils.util import get_platform
|
10 |
+
|
11 |
+
|
12 |
+
def show_formats():
|
13 |
+
"""Print list of available formats (arguments to "--format" option).
|
14 |
+
"""
|
15 |
+
from distutils.fancy_getopt import FancyGetopt
|
16 |
+
formats = []
|
17 |
+
for format in bdist.format_commands:
|
18 |
+
formats.append(("formats=" + format, None,
|
19 |
+
bdist.format_command[format][1]))
|
20 |
+
pretty_printer = FancyGetopt(formats)
|
21 |
+
pretty_printer.print_help("List of available distribution formats:")
|
22 |
+
|
23 |
+
|
24 |
+
class bdist(Command):
|
25 |
+
|
26 |
+
description = "create a built (binary) distribution"
|
27 |
+
|
28 |
+
user_options = [('bdist-base=', 'b',
|
29 |
+
"temporary directory for creating built distributions"),
|
30 |
+
('plat-name=', 'p',
|
31 |
+
"platform name to embed in generated filenames "
|
32 |
+
"(default: %s)" % get_platform()),
|
33 |
+
('formats=', None,
|
34 |
+
"formats for distribution (comma-separated list)"),
|
35 |
+
('dist-dir=', 'd',
|
36 |
+
"directory to put final built distributions in "
|
37 |
+
"[default: dist]"),
|
38 |
+
('skip-build', None,
|
39 |
+
"skip rebuilding everything (for testing/debugging)"),
|
40 |
+
('owner=', 'u',
|
41 |
+
"Owner name used when creating a tar file"
|
42 |
+
" [default: current user]"),
|
43 |
+
('group=', 'g',
|
44 |
+
"Group name used when creating a tar file"
|
45 |
+
" [default: current group]"),
|
46 |
+
]
|
47 |
+
|
48 |
+
boolean_options = ['skip-build']
|
49 |
+
|
50 |
+
help_options = [
|
51 |
+
('help-formats', None,
|
52 |
+
"lists available distribution formats", show_formats),
|
53 |
+
]
|
54 |
+
|
55 |
+
# The following commands do not take a format option from bdist
|
56 |
+
no_format_option = ('bdist_rpm',)
|
57 |
+
|
58 |
+
# This won't do in reality: will need to distinguish RPM-ish Linux,
|
59 |
+
# Debian-ish Linux, Solaris, FreeBSD, ..., Windows, Mac OS.
|
60 |
+
default_format = {'posix': 'gztar',
|
61 |
+
'nt': 'zip'}
|
62 |
+
|
63 |
+
# Establish the preferred order (for the --help-formats option).
|
64 |
+
format_commands = ['rpm', 'gztar', 'bztar', 'xztar', 'ztar', 'tar',
|
65 |
+
'wininst', 'zip', 'msi']
|
66 |
+
|
67 |
+
# And the real information.
|
68 |
+
format_command = {'rpm': ('bdist_rpm', "RPM distribution"),
|
69 |
+
'gztar': ('bdist_dumb', "gzip'ed tar file"),
|
70 |
+
'bztar': ('bdist_dumb', "bzip2'ed tar file"),
|
71 |
+
'xztar': ('bdist_dumb', "xz'ed tar file"),
|
72 |
+
'ztar': ('bdist_dumb', "compressed tar file"),
|
73 |
+
'tar': ('bdist_dumb', "tar file"),
|
74 |
+
'wininst': ('bdist_wininst',
|
75 |
+
"Windows executable installer"),
|
76 |
+
'zip': ('bdist_dumb', "ZIP file"),
|
77 |
+
'msi': ('bdist_msi', "Microsoft Installer")
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
def initialize_options(self):
|
82 |
+
self.bdist_base = None
|
83 |
+
self.plat_name = None
|
84 |
+
self.formats = None
|
85 |
+
self.dist_dir = None
|
86 |
+
self.skip_build = 0
|
87 |
+
self.group = None
|
88 |
+
self.owner = None
|
89 |
+
|
90 |
+
def finalize_options(self):
|
91 |
+
# have to finalize 'plat_name' before 'bdist_base'
|
92 |
+
if self.plat_name is None:
|
93 |
+
if self.skip_build:
|
94 |
+
self.plat_name = get_platform()
|
95 |
+
else:
|
96 |
+
self.plat_name = self.get_finalized_command('build').plat_name
|
97 |
+
|
98 |
+
# 'bdist_base' -- parent of per-built-distribution-format
|
99 |
+
# temporary directories (eg. we'll probably have
|
100 |
+
# "build/bdist.<plat>/dumb", "build/bdist.<plat>/rpm", etc.)
|
101 |
+
if self.bdist_base is None:
|
102 |
+
build_base = self.get_finalized_command('build').build_base
|
103 |
+
self.bdist_base = os.path.join(build_base,
|
104 |
+
'bdist.' + self.plat_name)
|
105 |
+
|
106 |
+
self.ensure_string_list('formats')
|
107 |
+
if self.formats is None:
|
108 |
+
try:
|
109 |
+
self.formats = [self.default_format[os.name]]
|
110 |
+
except KeyError:
|
111 |
+
raise DistutilsPlatformError(
|
112 |
+
"don't know how to create built distributions "
|
113 |
+
"on platform %s" % os.name)
|
114 |
+
|
115 |
+
if self.dist_dir is None:
|
116 |
+
self.dist_dir = "dist"
|
117 |
+
|
118 |
+
def run(self):
|
119 |
+
# Figure out which sub-commands we need to run.
|
120 |
+
commands = []
|
121 |
+
for format in self.formats:
|
122 |
+
try:
|
123 |
+
commands.append(self.format_command[format][0])
|
124 |
+
except KeyError:
|
125 |
+
raise DistutilsOptionError("invalid format '%s'" % format)
|
126 |
+
|
127 |
+
# Reinitialize and run each command.
|
128 |
+
for i in range(len(self.formats)):
|
129 |
+
cmd_name = commands[i]
|
130 |
+
sub_cmd = self.reinitialize_command(cmd_name)
|
131 |
+
if cmd_name not in self.no_format_option:
|
132 |
+
sub_cmd.format = self.formats[i]
|
133 |
+
|
134 |
+
# passing the owner and group names for tar archiving
|
135 |
+
if cmd_name == 'bdist_dumb':
|
136 |
+
sub_cmd.owner = self.owner
|
137 |
+
sub_cmd.group = self.group
|
138 |
+
|
139 |
+
# If we're going to need to run this command again, tell it to
|
140 |
+
# keep its temporary files around so subsequent runs go faster.
|
141 |
+
if cmd_name in commands[i+1:]:
|
142 |
+
sub_cmd.keep_temp = 1
|
143 |
+
self.run_command(cmd_name)
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/bdist_dumb.py
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.bdist_dumb
|
2 |
+
|
3 |
+
Implements the Distutils 'bdist_dumb' command (create a "dumb" built
|
4 |
+
distribution -- i.e., just an archive to be unpacked under $prefix or
|
5 |
+
$exec_prefix)."""
|
6 |
+
|
7 |
+
import os
|
8 |
+
from distutils.core import Command
|
9 |
+
from distutils.util import get_platform
|
10 |
+
from distutils.dir_util import remove_tree, ensure_relative
|
11 |
+
from distutils.errors import *
|
12 |
+
from distutils.sysconfig import get_python_version
|
13 |
+
from distutils import log
|
14 |
+
|
15 |
+
class bdist_dumb(Command):
|
16 |
+
|
17 |
+
description = "create a \"dumb\" built distribution"
|
18 |
+
|
19 |
+
user_options = [('bdist-dir=', 'd',
|
20 |
+
"temporary directory for creating the distribution"),
|
21 |
+
('plat-name=', 'p',
|
22 |
+
"platform name to embed in generated filenames "
|
23 |
+
"(default: %s)" % get_platform()),
|
24 |
+
('format=', 'f',
|
25 |
+
"archive format to create (tar, gztar, bztar, xztar, "
|
26 |
+
"ztar, zip)"),
|
27 |
+
('keep-temp', 'k',
|
28 |
+
"keep the pseudo-installation tree around after " +
|
29 |
+
"creating the distribution archive"),
|
30 |
+
('dist-dir=', 'd',
|
31 |
+
"directory to put final built distributions in"),
|
32 |
+
('skip-build', None,
|
33 |
+
"skip rebuilding everything (for testing/debugging)"),
|
34 |
+
('relative', None,
|
35 |
+
"build the archive using relative paths "
|
36 |
+
"(default: false)"),
|
37 |
+
('owner=', 'u',
|
38 |
+
"Owner name used when creating a tar file"
|
39 |
+
" [default: current user]"),
|
40 |
+
('group=', 'g',
|
41 |
+
"Group name used when creating a tar file"
|
42 |
+
" [default: current group]"),
|
43 |
+
]
|
44 |
+
|
45 |
+
boolean_options = ['keep-temp', 'skip-build', 'relative']
|
46 |
+
|
47 |
+
default_format = { 'posix': 'gztar',
|
48 |
+
'nt': 'zip' }
|
49 |
+
|
50 |
+
def initialize_options(self):
|
51 |
+
self.bdist_dir = None
|
52 |
+
self.plat_name = None
|
53 |
+
self.format = None
|
54 |
+
self.keep_temp = 0
|
55 |
+
self.dist_dir = None
|
56 |
+
self.skip_build = None
|
57 |
+
self.relative = 0
|
58 |
+
self.owner = None
|
59 |
+
self.group = None
|
60 |
+
|
61 |
+
def finalize_options(self):
|
62 |
+
if self.bdist_dir is None:
|
63 |
+
bdist_base = self.get_finalized_command('bdist').bdist_base
|
64 |
+
self.bdist_dir = os.path.join(bdist_base, 'dumb')
|
65 |
+
|
66 |
+
if self.format is None:
|
67 |
+
try:
|
68 |
+
self.format = self.default_format[os.name]
|
69 |
+
except KeyError:
|
70 |
+
raise DistutilsPlatformError(
|
71 |
+
"don't know how to create dumb built distributions "
|
72 |
+
"on platform %s" % os.name)
|
73 |
+
|
74 |
+
self.set_undefined_options('bdist',
|
75 |
+
('dist_dir', 'dist_dir'),
|
76 |
+
('plat_name', 'plat_name'),
|
77 |
+
('skip_build', 'skip_build'))
|
78 |
+
|
79 |
+
def run(self):
|
80 |
+
if not self.skip_build:
|
81 |
+
self.run_command('build')
|
82 |
+
|
83 |
+
install = self.reinitialize_command('install', reinit_subcommands=1)
|
84 |
+
install.root = self.bdist_dir
|
85 |
+
install.skip_build = self.skip_build
|
86 |
+
install.warn_dir = 0
|
87 |
+
|
88 |
+
log.info("installing to %s", self.bdist_dir)
|
89 |
+
self.run_command('install')
|
90 |
+
|
91 |
+
# And make an archive relative to the root of the
|
92 |
+
# pseudo-installation tree.
|
93 |
+
archive_basename = "%s.%s" % (self.distribution.get_fullname(),
|
94 |
+
self.plat_name)
|
95 |
+
|
96 |
+
pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
|
97 |
+
if not self.relative:
|
98 |
+
archive_root = self.bdist_dir
|
99 |
+
else:
|
100 |
+
if (self.distribution.has_ext_modules() and
|
101 |
+
(install.install_base != install.install_platbase)):
|
102 |
+
raise DistutilsPlatformError(
|
103 |
+
"can't make a dumb built distribution where "
|
104 |
+
"base and platbase are different (%s, %s)"
|
105 |
+
% (repr(install.install_base),
|
106 |
+
repr(install.install_platbase)))
|
107 |
+
else:
|
108 |
+
archive_root = os.path.join(self.bdist_dir,
|
109 |
+
ensure_relative(install.install_base))
|
110 |
+
|
111 |
+
# Make the archive
|
112 |
+
filename = self.make_archive(pseudoinstall_root,
|
113 |
+
self.format, root_dir=archive_root,
|
114 |
+
owner=self.owner, group=self.group)
|
115 |
+
if self.distribution.has_ext_modules():
|
116 |
+
pyversion = get_python_version()
|
117 |
+
else:
|
118 |
+
pyversion = 'any'
|
119 |
+
self.distribution.dist_files.append(('bdist_dumb', pyversion,
|
120 |
+
filename))
|
121 |
+
|
122 |
+
if not self.keep_temp:
|
123 |
+
remove_tree(self.bdist_dir, dry_run=self.dry_run)
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/bdist_msi.py
ADDED
@@ -0,0 +1,749 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2005, 2006 Martin von Löwis
|
2 |
+
# Licensed to PSF under a Contributor Agreement.
|
3 |
+
# The bdist_wininst command proper
|
4 |
+
# based on bdist_wininst
|
5 |
+
"""
|
6 |
+
Implements the bdist_msi command.
|
7 |
+
"""
|
8 |
+
|
9 |
+
import os
|
10 |
+
import sys
|
11 |
+
import warnings
|
12 |
+
from distutils.core import Command
|
13 |
+
from distutils.dir_util import remove_tree
|
14 |
+
from distutils.sysconfig import get_python_version
|
15 |
+
from distutils.version import StrictVersion
|
16 |
+
from distutils.errors import DistutilsOptionError
|
17 |
+
from distutils.util import get_platform
|
18 |
+
from distutils import log
|
19 |
+
import msilib
|
20 |
+
from msilib import schema, sequence, text
|
21 |
+
from msilib import Directory, Feature, Dialog, add_data
|
22 |
+
|
23 |
+
class PyDialog(Dialog):
|
24 |
+
"""Dialog class with a fixed layout: controls at the top, then a ruler,
|
25 |
+
then a list of buttons: back, next, cancel. Optionally a bitmap at the
|
26 |
+
left."""
|
27 |
+
def __init__(self, *args, **kw):
|
28 |
+
"""Dialog(database, name, x, y, w, h, attributes, title, first,
|
29 |
+
default, cancel, bitmap=true)"""
|
30 |
+
Dialog.__init__(self, *args)
|
31 |
+
ruler = self.h - 36
|
32 |
+
bmwidth = 152*ruler/328
|
33 |
+
#if kw.get("bitmap", True):
|
34 |
+
# self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
|
35 |
+
self.line("BottomLine", 0, ruler, self.w, 0)
|
36 |
+
|
37 |
+
def title(self, title):
|
38 |
+
"Set the title text of the dialog at the top."
|
39 |
+
# name, x, y, w, h, flags=Visible|Enabled|Transparent|NoPrefix,
|
40 |
+
# text, in VerdanaBold10
|
41 |
+
self.text("Title", 15, 10, 320, 60, 0x30003,
|
42 |
+
r"{\VerdanaBold10}%s" % title)
|
43 |
+
|
44 |
+
def back(self, title, next, name = "Back", active = 1):
|
45 |
+
"""Add a back button with a given title, the tab-next button,
|
46 |
+
its name in the Control table, possibly initially disabled.
|
47 |
+
|
48 |
+
Return the button, so that events can be associated"""
|
49 |
+
if active:
|
50 |
+
flags = 3 # Visible|Enabled
|
51 |
+
else:
|
52 |
+
flags = 1 # Visible
|
53 |
+
return self.pushbutton(name, 180, self.h-27 , 56, 17, flags, title, next)
|
54 |
+
|
55 |
+
def cancel(self, title, next, name = "Cancel", active = 1):
|
56 |
+
"""Add a cancel button with a given title, the tab-next button,
|
57 |
+
its name in the Control table, possibly initially disabled.
|
58 |
+
|
59 |
+
Return the button, so that events can be associated"""
|
60 |
+
if active:
|
61 |
+
flags = 3 # Visible|Enabled
|
62 |
+
else:
|
63 |
+
flags = 1 # Visible
|
64 |
+
return self.pushbutton(name, 304, self.h-27, 56, 17, flags, title, next)
|
65 |
+
|
66 |
+
def next(self, title, next, name = "Next", active = 1):
|
67 |
+
"""Add a Next button with a given title, the tab-next button,
|
68 |
+
its name in the Control table, possibly initially disabled.
|
69 |
+
|
70 |
+
Return the button, so that events can be associated"""
|
71 |
+
if active:
|
72 |
+
flags = 3 # Visible|Enabled
|
73 |
+
else:
|
74 |
+
flags = 1 # Visible
|
75 |
+
return self.pushbutton(name, 236, self.h-27, 56, 17, flags, title, next)
|
76 |
+
|
77 |
+
def xbutton(self, name, title, next, xpos):
|
78 |
+
"""Add a button with a given title, the tab-next button,
|
79 |
+
its name in the Control table, giving its x position; the
|
80 |
+
y-position is aligned with the other buttons.
|
81 |
+
|
82 |
+
Return the button, so that events can be associated"""
|
83 |
+
return self.pushbutton(name, int(self.w*xpos - 28), self.h-27, 56, 17, 3, title, next)
|
84 |
+
|
85 |
+
class bdist_msi(Command):
|
86 |
+
|
87 |
+
description = "create a Microsoft Installer (.msi) binary distribution"
|
88 |
+
|
89 |
+
user_options = [('bdist-dir=', None,
|
90 |
+
"temporary directory for creating the distribution"),
|
91 |
+
('plat-name=', 'p',
|
92 |
+
"platform name to embed in generated filenames "
|
93 |
+
"(default: %s)" % get_platform()),
|
94 |
+
('keep-temp', 'k',
|
95 |
+
"keep the pseudo-installation tree around after " +
|
96 |
+
"creating the distribution archive"),
|
97 |
+
('target-version=', None,
|
98 |
+
"require a specific python version" +
|
99 |
+
" on the target system"),
|
100 |
+
('no-target-compile', 'c',
|
101 |
+
"do not compile .py to .pyc on the target system"),
|
102 |
+
('no-target-optimize', 'o',
|
103 |
+
"do not compile .py to .pyo (optimized) "
|
104 |
+
"on the target system"),
|
105 |
+
('dist-dir=', 'd',
|
106 |
+
"directory to put final built distributions in"),
|
107 |
+
('skip-build', None,
|
108 |
+
"skip rebuilding everything (for testing/debugging)"),
|
109 |
+
('install-script=', None,
|
110 |
+
"basename of installation script to be run after "
|
111 |
+
"installation or before deinstallation"),
|
112 |
+
('pre-install-script=', None,
|
113 |
+
"Fully qualified filename of a script to be run before "
|
114 |
+
"any files are installed. This script need not be in the "
|
115 |
+
"distribution"),
|
116 |
+
]
|
117 |
+
|
118 |
+
boolean_options = ['keep-temp', 'no-target-compile', 'no-target-optimize',
|
119 |
+
'skip-build']
|
120 |
+
|
121 |
+
all_versions = ['2.0', '2.1', '2.2', '2.3', '2.4',
|
122 |
+
'2.5', '2.6', '2.7', '2.8', '2.9',
|
123 |
+
'3.0', '3.1', '3.2', '3.3', '3.4',
|
124 |
+
'3.5', '3.6', '3.7', '3.8', '3.9']
|
125 |
+
other_version = 'X'
|
126 |
+
|
127 |
+
def __init__(self, *args, **kw):
|
128 |
+
super().__init__(*args, **kw)
|
129 |
+
warnings.warn("bdist_msi command is deprecated since Python 3.9, "
|
130 |
+
"use bdist_wheel (wheel packages) instead",
|
131 |
+
DeprecationWarning, 2)
|
132 |
+
|
133 |
+
def initialize_options(self):
|
134 |
+
self.bdist_dir = None
|
135 |
+
self.plat_name = None
|
136 |
+
self.keep_temp = 0
|
137 |
+
self.no_target_compile = 0
|
138 |
+
self.no_target_optimize = 0
|
139 |
+
self.target_version = None
|
140 |
+
self.dist_dir = None
|
141 |
+
self.skip_build = None
|
142 |
+
self.install_script = None
|
143 |
+
self.pre_install_script = None
|
144 |
+
self.versions = None
|
145 |
+
|
146 |
+
def finalize_options(self):
|
147 |
+
self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
|
148 |
+
|
149 |
+
if self.bdist_dir is None:
|
150 |
+
bdist_base = self.get_finalized_command('bdist').bdist_base
|
151 |
+
self.bdist_dir = os.path.join(bdist_base, 'msi')
|
152 |
+
|
153 |
+
short_version = get_python_version()
|
154 |
+
if (not self.target_version) and self.distribution.has_ext_modules():
|
155 |
+
self.target_version = short_version
|
156 |
+
|
157 |
+
if self.target_version:
|
158 |
+
self.versions = [self.target_version]
|
159 |
+
if not self.skip_build and self.distribution.has_ext_modules()\
|
160 |
+
and self.target_version != short_version:
|
161 |
+
raise DistutilsOptionError(
|
162 |
+
"target version can only be %s, or the '--skip-build'"
|
163 |
+
" option must be specified" % (short_version,))
|
164 |
+
else:
|
165 |
+
self.versions = list(self.all_versions)
|
166 |
+
|
167 |
+
self.set_undefined_options('bdist',
|
168 |
+
('dist_dir', 'dist_dir'),
|
169 |
+
('plat_name', 'plat_name'),
|
170 |
+
)
|
171 |
+
|
172 |
+
if self.pre_install_script:
|
173 |
+
raise DistutilsOptionError(
|
174 |
+
"the pre-install-script feature is not yet implemented")
|
175 |
+
|
176 |
+
if self.install_script:
|
177 |
+
for script in self.distribution.scripts:
|
178 |
+
if self.install_script == os.path.basename(script):
|
179 |
+
break
|
180 |
+
else:
|
181 |
+
raise DistutilsOptionError(
|
182 |
+
"install_script '%s' not found in scripts"
|
183 |
+
% self.install_script)
|
184 |
+
self.install_script_key = None
|
185 |
+
|
186 |
+
def run(self):
|
187 |
+
if not self.skip_build:
|
188 |
+
self.run_command('build')
|
189 |
+
|
190 |
+
install = self.reinitialize_command('install', reinit_subcommands=1)
|
191 |
+
install.prefix = self.bdist_dir
|
192 |
+
install.skip_build = self.skip_build
|
193 |
+
install.warn_dir = 0
|
194 |
+
|
195 |
+
install_lib = self.reinitialize_command('install_lib')
|
196 |
+
# we do not want to include pyc or pyo files
|
197 |
+
install_lib.compile = 0
|
198 |
+
install_lib.optimize = 0
|
199 |
+
|
200 |
+
if self.distribution.has_ext_modules():
|
201 |
+
# If we are building an installer for a Python version other
|
202 |
+
# than the one we are currently running, then we need to ensure
|
203 |
+
# our build_lib reflects the other Python version rather than ours.
|
204 |
+
# Note that for target_version!=sys.version, we must have skipped the
|
205 |
+
# build step, so there is no issue with enforcing the build of this
|
206 |
+
# version.
|
207 |
+
target_version = self.target_version
|
208 |
+
if not target_version:
|
209 |
+
assert self.skip_build, "Should have already checked this"
|
210 |
+
target_version = '%d.%d' % sys.version_info[:2]
|
211 |
+
plat_specifier = ".%s-%s" % (self.plat_name, target_version)
|
212 |
+
build = self.get_finalized_command('build')
|
213 |
+
build.build_lib = os.path.join(build.build_base,
|
214 |
+
'lib' + plat_specifier)
|
215 |
+
|
216 |
+
log.info("installing to %s", self.bdist_dir)
|
217 |
+
install.ensure_finalized()
|
218 |
+
|
219 |
+
# avoid warning of 'install_lib' about installing
|
220 |
+
# into a directory not in sys.path
|
221 |
+
sys.path.insert(0, os.path.join(self.bdist_dir, 'PURELIB'))
|
222 |
+
|
223 |
+
install.run()
|
224 |
+
|
225 |
+
del sys.path[0]
|
226 |
+
|
227 |
+
self.mkpath(self.dist_dir)
|
228 |
+
fullname = self.distribution.get_fullname()
|
229 |
+
installer_name = self.get_installer_filename(fullname)
|
230 |
+
installer_name = os.path.abspath(installer_name)
|
231 |
+
if os.path.exists(installer_name): os.unlink(installer_name)
|
232 |
+
|
233 |
+
metadata = self.distribution.metadata
|
234 |
+
author = metadata.author
|
235 |
+
if not author:
|
236 |
+
author = metadata.maintainer
|
237 |
+
if not author:
|
238 |
+
author = "UNKNOWN"
|
239 |
+
version = metadata.get_version()
|
240 |
+
# ProductVersion must be strictly numeric
|
241 |
+
# XXX need to deal with prerelease versions
|
242 |
+
sversion = "%d.%d.%d" % StrictVersion(version).version
|
243 |
+
# Prefix ProductName with Python x.y, so that
|
244 |
+
# it sorts together with the other Python packages
|
245 |
+
# in Add-Remove-Programs (APR)
|
246 |
+
fullname = self.distribution.get_fullname()
|
247 |
+
if self.target_version:
|
248 |
+
product_name = "Python %s %s" % (self.target_version, fullname)
|
249 |
+
else:
|
250 |
+
product_name = "Python %s" % (fullname)
|
251 |
+
self.db = msilib.init_database(installer_name, schema,
|
252 |
+
product_name, msilib.gen_uuid(),
|
253 |
+
sversion, author)
|
254 |
+
msilib.add_tables(self.db, sequence)
|
255 |
+
props = [('DistVersion', version)]
|
256 |
+
email = metadata.author_email or metadata.maintainer_email
|
257 |
+
if email:
|
258 |
+
props.append(("ARPCONTACT", email))
|
259 |
+
if metadata.url:
|
260 |
+
props.append(("ARPURLINFOABOUT", metadata.url))
|
261 |
+
if props:
|
262 |
+
add_data(self.db, 'Property', props)
|
263 |
+
|
264 |
+
self.add_find_python()
|
265 |
+
self.add_files()
|
266 |
+
self.add_scripts()
|
267 |
+
self.add_ui()
|
268 |
+
self.db.Commit()
|
269 |
+
|
270 |
+
if hasattr(self.distribution, 'dist_files'):
|
271 |
+
tup = 'bdist_msi', self.target_version or 'any', fullname
|
272 |
+
self.distribution.dist_files.append(tup)
|
273 |
+
|
274 |
+
if not self.keep_temp:
|
275 |
+
remove_tree(self.bdist_dir, dry_run=self.dry_run)
|
276 |
+
|
277 |
+
def add_files(self):
|
278 |
+
db = self.db
|
279 |
+
cab = msilib.CAB("distfiles")
|
280 |
+
rootdir = os.path.abspath(self.bdist_dir)
|
281 |
+
|
282 |
+
root = Directory(db, cab, None, rootdir, "TARGETDIR", "SourceDir")
|
283 |
+
f = Feature(db, "Python", "Python", "Everything",
|
284 |
+
0, 1, directory="TARGETDIR")
|
285 |
+
|
286 |
+
items = [(f, root, '')]
|
287 |
+
for version in self.versions + [self.other_version]:
|
288 |
+
target = "TARGETDIR" + version
|
289 |
+
name = default = "Python" + version
|
290 |
+
desc = "Everything"
|
291 |
+
if version is self.other_version:
|
292 |
+
title = "Python from another location"
|
293 |
+
level = 2
|
294 |
+
else:
|
295 |
+
title = "Python %s from registry" % version
|
296 |
+
level = 1
|
297 |
+
f = Feature(db, name, title, desc, 1, level, directory=target)
|
298 |
+
dir = Directory(db, cab, root, rootdir, target, default)
|
299 |
+
items.append((f, dir, version))
|
300 |
+
db.Commit()
|
301 |
+
|
302 |
+
seen = {}
|
303 |
+
for feature, dir, version in items:
|
304 |
+
todo = [dir]
|
305 |
+
while todo:
|
306 |
+
dir = todo.pop()
|
307 |
+
for file in os.listdir(dir.absolute):
|
308 |
+
afile = os.path.join(dir.absolute, file)
|
309 |
+
if os.path.isdir(afile):
|
310 |
+
short = "%s|%s" % (dir.make_short(file), file)
|
311 |
+
default = file + version
|
312 |
+
newdir = Directory(db, cab, dir, file, default, short)
|
313 |
+
todo.append(newdir)
|
314 |
+
else:
|
315 |
+
if not dir.component:
|
316 |
+
dir.start_component(dir.logical, feature, 0)
|
317 |
+
if afile not in seen:
|
318 |
+
key = seen[afile] = dir.add_file(file)
|
319 |
+
if file==self.install_script:
|
320 |
+
if self.install_script_key:
|
321 |
+
raise DistutilsOptionError(
|
322 |
+
"Multiple files with name %s" % file)
|
323 |
+
self.install_script_key = '[#%s]' % key
|
324 |
+
else:
|
325 |
+
key = seen[afile]
|
326 |
+
add_data(self.db, "DuplicateFile",
|
327 |
+
[(key + version, dir.component, key, None, dir.logical)])
|
328 |
+
db.Commit()
|
329 |
+
cab.commit(db)
|
330 |
+
|
331 |
+
def add_find_python(self):
|
332 |
+
"""Adds code to the installer to compute the location of Python.
|
333 |
+
|
334 |
+
Properties PYTHON.MACHINE.X.Y and PYTHON.USER.X.Y will be set from the
|
335 |
+
registry for each version of Python.
|
336 |
+
|
337 |
+
Properties TARGETDIRX.Y will be set from PYTHON.USER.X.Y if defined,
|
338 |
+
else from PYTHON.MACHINE.X.Y.
|
339 |
+
|
340 |
+
Properties PYTHONX.Y will be set to TARGETDIRX.Y\\python.exe"""
|
341 |
+
|
342 |
+
start = 402
|
343 |
+
for ver in self.versions:
|
344 |
+
install_path = r"SOFTWARE\Python\PythonCore\%s\InstallPath" % ver
|
345 |
+
machine_reg = "python.machine." + ver
|
346 |
+
user_reg = "python.user." + ver
|
347 |
+
machine_prop = "PYTHON.MACHINE." + ver
|
348 |
+
user_prop = "PYTHON.USER." + ver
|
349 |
+
machine_action = "PythonFromMachine" + ver
|
350 |
+
user_action = "PythonFromUser" + ver
|
351 |
+
exe_action = "PythonExe" + ver
|
352 |
+
target_dir_prop = "TARGETDIR" + ver
|
353 |
+
exe_prop = "PYTHON" + ver
|
354 |
+
if msilib.Win64:
|
355 |
+
# type: msidbLocatorTypeRawValue + msidbLocatorType64bit
|
356 |
+
Type = 2+16
|
357 |
+
else:
|
358 |
+
Type = 2
|
359 |
+
add_data(self.db, "RegLocator",
|
360 |
+
[(machine_reg, 2, install_path, None, Type),
|
361 |
+
(user_reg, 1, install_path, None, Type)])
|
362 |
+
add_data(self.db, "AppSearch",
|
363 |
+
[(machine_prop, machine_reg),
|
364 |
+
(user_prop, user_reg)])
|
365 |
+
add_data(self.db, "CustomAction",
|
366 |
+
[(machine_action, 51+256, target_dir_prop, "[" + machine_prop + "]"),
|
367 |
+
(user_action, 51+256, target_dir_prop, "[" + user_prop + "]"),
|
368 |
+
(exe_action, 51+256, exe_prop, "[" + target_dir_prop + "]\\python.exe"),
|
369 |
+
])
|
370 |
+
add_data(self.db, "InstallExecuteSequence",
|
371 |
+
[(machine_action, machine_prop, start),
|
372 |
+
(user_action, user_prop, start + 1),
|
373 |
+
(exe_action, None, start + 2),
|
374 |
+
])
|
375 |
+
add_data(self.db, "InstallUISequence",
|
376 |
+
[(machine_action, machine_prop, start),
|
377 |
+
(user_action, user_prop, start + 1),
|
378 |
+
(exe_action, None, start + 2),
|
379 |
+
])
|
380 |
+
add_data(self.db, "Condition",
|
381 |
+
[("Python" + ver, 0, "NOT TARGETDIR" + ver)])
|
382 |
+
start += 4
|
383 |
+
assert start < 500
|
384 |
+
|
385 |
+
def add_scripts(self):
|
386 |
+
if self.install_script:
|
387 |
+
start = 6800
|
388 |
+
for ver in self.versions + [self.other_version]:
|
389 |
+
install_action = "install_script." + ver
|
390 |
+
exe_prop = "PYTHON" + ver
|
391 |
+
add_data(self.db, "CustomAction",
|
392 |
+
[(install_action, 50, exe_prop, self.install_script_key)])
|
393 |
+
add_data(self.db, "InstallExecuteSequence",
|
394 |
+
[(install_action, "&Python%s=3" % ver, start)])
|
395 |
+
start += 1
|
396 |
+
# XXX pre-install scripts are currently refused in finalize_options()
|
397 |
+
# but if this feature is completed, it will also need to add
|
398 |
+
# entries for each version as the above code does
|
399 |
+
if self.pre_install_script:
|
400 |
+
scriptfn = os.path.join(self.bdist_dir, "preinstall.bat")
|
401 |
+
with open(scriptfn, "w") as f:
|
402 |
+
# The batch file will be executed with [PYTHON], so that %1
|
403 |
+
# is the path to the Python interpreter; %0 will be the path
|
404 |
+
# of the batch file.
|
405 |
+
# rem ="""
|
406 |
+
# %1 %0
|
407 |
+
# exit
|
408 |
+
# """
|
409 |
+
# <actual script>
|
410 |
+
f.write('rem ="""\n%1 %0\nexit\n"""\n')
|
411 |
+
with open(self.pre_install_script) as fin:
|
412 |
+
f.write(fin.read())
|
413 |
+
add_data(self.db, "Binary",
|
414 |
+
[("PreInstall", msilib.Binary(scriptfn))
|
415 |
+
])
|
416 |
+
add_data(self.db, "CustomAction",
|
417 |
+
[("PreInstall", 2, "PreInstall", None)
|
418 |
+
])
|
419 |
+
add_data(self.db, "InstallExecuteSequence",
|
420 |
+
[("PreInstall", "NOT Installed", 450)])
|
421 |
+
|
422 |
+
|
423 |
+
def add_ui(self):
|
424 |
+
db = self.db
|
425 |
+
x = y = 50
|
426 |
+
w = 370
|
427 |
+
h = 300
|
428 |
+
title = "[ProductName] Setup"
|
429 |
+
|
430 |
+
# see "Dialog Style Bits"
|
431 |
+
modal = 3 # visible | modal
|
432 |
+
modeless = 1 # visible
|
433 |
+
track_disk_space = 32
|
434 |
+
|
435 |
+
# UI customization properties
|
436 |
+
add_data(db, "Property",
|
437 |
+
# See "DefaultUIFont Property"
|
438 |
+
[("DefaultUIFont", "DlgFont8"),
|
439 |
+
# See "ErrorDialog Style Bit"
|
440 |
+
("ErrorDialog", "ErrorDlg"),
|
441 |
+
("Progress1", "Install"), # modified in maintenance type dlg
|
442 |
+
("Progress2", "installs"),
|
443 |
+
("MaintenanceForm_Action", "Repair"),
|
444 |
+
# possible values: ALL, JUSTME
|
445 |
+
("WhichUsers", "ALL")
|
446 |
+
])
|
447 |
+
|
448 |
+
# Fonts, see "TextStyle Table"
|
449 |
+
add_data(db, "TextStyle",
|
450 |
+
[("DlgFont8", "Tahoma", 9, None, 0),
|
451 |
+
("DlgFontBold8", "Tahoma", 8, None, 1), #bold
|
452 |
+
("VerdanaBold10", "Verdana", 10, None, 1),
|
453 |
+
("VerdanaRed9", "Verdana", 9, 255, 0),
|
454 |
+
])
|
455 |
+
|
456 |
+
# UI Sequences, see "InstallUISequence Table", "Using a Sequence Table"
|
457 |
+
# Numbers indicate sequence; see sequence.py for how these action integrate
|
458 |
+
add_data(db, "InstallUISequence",
|
459 |
+
[("PrepareDlg", "Not Privileged or Windows9x or Installed", 140),
|
460 |
+
("WhichUsersDlg", "Privileged and not Windows9x and not Installed", 141),
|
461 |
+
# In the user interface, assume all-users installation if privileged.
|
462 |
+
("SelectFeaturesDlg", "Not Installed", 1230),
|
463 |
+
# XXX no support for resume installations yet
|
464 |
+
#("ResumeDlg", "Installed AND (RESUME OR Preselected)", 1240),
|
465 |
+
("MaintenanceTypeDlg", "Installed AND NOT RESUME AND NOT Preselected", 1250),
|
466 |
+
("ProgressDlg", None, 1280)])
|
467 |
+
|
468 |
+
add_data(db, 'ActionText', text.ActionText)
|
469 |
+
add_data(db, 'UIText', text.UIText)
|
470 |
+
#####################################################################
|
471 |
+
# Standard dialogs: FatalError, UserExit, ExitDialog
|
472 |
+
fatal=PyDialog(db, "FatalError", x, y, w, h, modal, title,
|
473 |
+
"Finish", "Finish", "Finish")
|
474 |
+
fatal.title("[ProductName] Installer ended prematurely")
|
475 |
+
fatal.back("< Back", "Finish", active = 0)
|
476 |
+
fatal.cancel("Cancel", "Back", active = 0)
|
477 |
+
fatal.text("Description1", 15, 70, 320, 80, 0x30003,
|
478 |
+
"[ProductName] setup ended prematurely because of an error. Your system has not been modified. To install this program at a later time, please run the installation again.")
|
479 |
+
fatal.text("Description2", 15, 155, 320, 20, 0x30003,
|
480 |
+
"Click the Finish button to exit the Installer.")
|
481 |
+
c=fatal.next("Finish", "Cancel", name="Finish")
|
482 |
+
c.event("EndDialog", "Exit")
|
483 |
+
|
484 |
+
user_exit=PyDialog(db, "UserExit", x, y, w, h, modal, title,
|
485 |
+
"Finish", "Finish", "Finish")
|
486 |
+
user_exit.title("[ProductName] Installer was interrupted")
|
487 |
+
user_exit.back("< Back", "Finish", active = 0)
|
488 |
+
user_exit.cancel("Cancel", "Back", active = 0)
|
489 |
+
user_exit.text("Description1", 15, 70, 320, 80, 0x30003,
|
490 |
+
"[ProductName] setup was interrupted. Your system has not been modified. "
|
491 |
+
"To install this program at a later time, please run the installation again.")
|
492 |
+
user_exit.text("Description2", 15, 155, 320, 20, 0x30003,
|
493 |
+
"Click the Finish button to exit the Installer.")
|
494 |
+
c = user_exit.next("Finish", "Cancel", name="Finish")
|
495 |
+
c.event("EndDialog", "Exit")
|
496 |
+
|
497 |
+
exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title,
|
498 |
+
"Finish", "Finish", "Finish")
|
499 |
+
exit_dialog.title("Completing the [ProductName] Installer")
|
500 |
+
exit_dialog.back("< Back", "Finish", active = 0)
|
501 |
+
exit_dialog.cancel("Cancel", "Back", active = 0)
|
502 |
+
exit_dialog.text("Description", 15, 235, 320, 20, 0x30003,
|
503 |
+
"Click the Finish button to exit the Installer.")
|
504 |
+
c = exit_dialog.next("Finish", "Cancel", name="Finish")
|
505 |
+
c.event("EndDialog", "Return")
|
506 |
+
|
507 |
+
#####################################################################
|
508 |
+
# Required dialog: FilesInUse, ErrorDlg
|
509 |
+
inuse = PyDialog(db, "FilesInUse",
|
510 |
+
x, y, w, h,
|
511 |
+
19, # KeepModeless|Modal|Visible
|
512 |
+
title,
|
513 |
+
"Retry", "Retry", "Retry", bitmap=False)
|
514 |
+
inuse.text("Title", 15, 6, 200, 15, 0x30003,
|
515 |
+
r"{\DlgFontBold8}Files in Use")
|
516 |
+
inuse.text("Description", 20, 23, 280, 20, 0x30003,
|
517 |
+
"Some files that need to be updated are currently in use.")
|
518 |
+
inuse.text("Text", 20, 55, 330, 50, 3,
|
519 |
+
"The following applications are using files that need to be updated by this setup. Close these applications and then click Retry to continue the installation or Cancel to exit it.")
|
520 |
+
inuse.control("List", "ListBox", 20, 107, 330, 130, 7, "FileInUseProcess",
|
521 |
+
None, None, None)
|
522 |
+
c=inuse.back("Exit", "Ignore", name="Exit")
|
523 |
+
c.event("EndDialog", "Exit")
|
524 |
+
c=inuse.next("Ignore", "Retry", name="Ignore")
|
525 |
+
c.event("EndDialog", "Ignore")
|
526 |
+
c=inuse.cancel("Retry", "Exit", name="Retry")
|
527 |
+
c.event("EndDialog","Retry")
|
528 |
+
|
529 |
+
# See "Error Dialog". See "ICE20" for the required names of the controls.
|
530 |
+
error = Dialog(db, "ErrorDlg",
|
531 |
+
50, 10, 330, 101,
|
532 |
+
65543, # Error|Minimize|Modal|Visible
|
533 |
+
title,
|
534 |
+
"ErrorText", None, None)
|
535 |
+
error.text("ErrorText", 50,9,280,48,3, "")
|
536 |
+
#error.control("ErrorIcon", "Icon", 15, 9, 24, 24, 5242881, None, "py.ico", None, None)
|
537 |
+
error.pushbutton("N",120,72,81,21,3,"No",None).event("EndDialog","ErrorNo")
|
538 |
+
error.pushbutton("Y",240,72,81,21,3,"Yes",None).event("EndDialog","ErrorYes")
|
539 |
+
error.pushbutton("A",0,72,81,21,3,"Abort",None).event("EndDialog","ErrorAbort")
|
540 |
+
error.pushbutton("C",42,72,81,21,3,"Cancel",None).event("EndDialog","ErrorCancel")
|
541 |
+
error.pushbutton("I",81,72,81,21,3,"Ignore",None).event("EndDialog","ErrorIgnore")
|
542 |
+
error.pushbutton("O",159,72,81,21,3,"Ok",None).event("EndDialog","ErrorOk")
|
543 |
+
error.pushbutton("R",198,72,81,21,3,"Retry",None).event("EndDialog","ErrorRetry")
|
544 |
+
|
545 |
+
#####################################################################
|
546 |
+
# Global "Query Cancel" dialog
|
547 |
+
cancel = Dialog(db, "CancelDlg", 50, 10, 260, 85, 3, title,
|
548 |
+
"No", "No", "No")
|
549 |
+
cancel.text("Text", 48, 15, 194, 30, 3,
|
550 |
+
"Are you sure you want to cancel [ProductName] installation?")
|
551 |
+
#cancel.control("Icon", "Icon", 15, 15, 24, 24, 5242881, None,
|
552 |
+
# "py.ico", None, None)
|
553 |
+
c=cancel.pushbutton("Yes", 72, 57, 56, 17, 3, "Yes", "No")
|
554 |
+
c.event("EndDialog", "Exit")
|
555 |
+
|
556 |
+
c=cancel.pushbutton("No", 132, 57, 56, 17, 3, "No", "Yes")
|
557 |
+
c.event("EndDialog", "Return")
|
558 |
+
|
559 |
+
#####################################################################
|
560 |
+
# Global "Wait for costing" dialog
|
561 |
+
costing = Dialog(db, "WaitForCostingDlg", 50, 10, 260, 85, modal, title,
|
562 |
+
"Return", "Return", "Return")
|
563 |
+
costing.text("Text", 48, 15, 194, 30, 3,
|
564 |
+
"Please wait while the installer finishes determining your disk space requirements.")
|
565 |
+
c = costing.pushbutton("Return", 102, 57, 56, 17, 3, "Return", None)
|
566 |
+
c.event("EndDialog", "Exit")
|
567 |
+
|
568 |
+
#####################################################################
|
569 |
+
# Preparation dialog: no user input except cancellation
|
570 |
+
prep = PyDialog(db, "PrepareDlg", x, y, w, h, modeless, title,
|
571 |
+
"Cancel", "Cancel", "Cancel")
|
572 |
+
prep.text("Description", 15, 70, 320, 40, 0x30003,
|
573 |
+
"Please wait while the Installer prepares to guide you through the installation.")
|
574 |
+
prep.title("Welcome to the [ProductName] Installer")
|
575 |
+
c=prep.text("ActionText", 15, 110, 320, 20, 0x30003, "Pondering...")
|
576 |
+
c.mapping("ActionText", "Text")
|
577 |
+
c=prep.text("ActionData", 15, 135, 320, 30, 0x30003, None)
|
578 |
+
c.mapping("ActionData", "Text")
|
579 |
+
prep.back("Back", None, active=0)
|
580 |
+
prep.next("Next", None, active=0)
|
581 |
+
c=prep.cancel("Cancel", None)
|
582 |
+
c.event("SpawnDialog", "CancelDlg")
|
583 |
+
|
584 |
+
#####################################################################
|
585 |
+
# Feature (Python directory) selection
|
586 |
+
seldlg = PyDialog(db, "SelectFeaturesDlg", x, y, w, h, modal, title,
|
587 |
+
"Next", "Next", "Cancel")
|
588 |
+
seldlg.title("Select Python Installations")
|
589 |
+
|
590 |
+
seldlg.text("Hint", 15, 30, 300, 20, 3,
|
591 |
+
"Select the Python locations where %s should be installed."
|
592 |
+
% self.distribution.get_fullname())
|
593 |
+
|
594 |
+
seldlg.back("< Back", None, active=0)
|
595 |
+
c = seldlg.next("Next >", "Cancel")
|
596 |
+
order = 1
|
597 |
+
c.event("[TARGETDIR]", "[SourceDir]", ordering=order)
|
598 |
+
for version in self.versions + [self.other_version]:
|
599 |
+
order += 1
|
600 |
+
c.event("[TARGETDIR]", "[TARGETDIR%s]" % version,
|
601 |
+
"FEATURE_SELECTED AND &Python%s=3" % version,
|
602 |
+
ordering=order)
|
603 |
+
c.event("SpawnWaitDialog", "WaitForCostingDlg", ordering=order + 1)
|
604 |
+
c.event("EndDialog", "Return", ordering=order + 2)
|
605 |
+
c = seldlg.cancel("Cancel", "Features")
|
606 |
+
c.event("SpawnDialog", "CancelDlg")
|
607 |
+
|
608 |
+
c = seldlg.control("Features", "SelectionTree", 15, 60, 300, 120, 3,
|
609 |
+
"FEATURE", None, "PathEdit", None)
|
610 |
+
c.event("[FEATURE_SELECTED]", "1")
|
611 |
+
ver = self.other_version
|
612 |
+
install_other_cond = "FEATURE_SELECTED AND &Python%s=3" % ver
|
613 |
+
dont_install_other_cond = "FEATURE_SELECTED AND &Python%s<>3" % ver
|
614 |
+
|
615 |
+
c = seldlg.text("Other", 15, 200, 300, 15, 3,
|
616 |
+
"Provide an alternate Python location")
|
617 |
+
c.condition("Enable", install_other_cond)
|
618 |
+
c.condition("Show", install_other_cond)
|
619 |
+
c.condition("Disable", dont_install_other_cond)
|
620 |
+
c.condition("Hide", dont_install_other_cond)
|
621 |
+
|
622 |
+
c = seldlg.control("PathEdit", "PathEdit", 15, 215, 300, 16, 1,
|
623 |
+
"TARGETDIR" + ver, None, "Next", None)
|
624 |
+
c.condition("Enable", install_other_cond)
|
625 |
+
c.condition("Show", install_other_cond)
|
626 |
+
c.condition("Disable", dont_install_other_cond)
|
627 |
+
c.condition("Hide", dont_install_other_cond)
|
628 |
+
|
629 |
+
#####################################################################
|
630 |
+
# Disk cost
|
631 |
+
cost = PyDialog(db, "DiskCostDlg", x, y, w, h, modal, title,
|
632 |
+
"OK", "OK", "OK", bitmap=False)
|
633 |
+
cost.text("Title", 15, 6, 200, 15, 0x30003,
|
634 |
+
r"{\DlgFontBold8}Disk Space Requirements")
|
635 |
+
cost.text("Description", 20, 20, 280, 20, 0x30003,
|
636 |
+
"The disk space required for the installation of the selected features.")
|
637 |
+
cost.text("Text", 20, 53, 330, 60, 3,
|
638 |
+
"The highlighted volumes (if any) do not have enough disk space "
|
639 |
+
"available for the currently selected features. You can either "
|
640 |
+
"remove some files from the highlighted volumes, or choose to "
|
641 |
+
"install less features onto local drive(s), or select different "
|
642 |
+
"destination drive(s).")
|
643 |
+
cost.control("VolumeList", "VolumeCostList", 20, 100, 330, 150, 393223,
|
644 |
+
None, "{120}{70}{70}{70}{70}", None, None)
|
645 |
+
cost.xbutton("OK", "Ok", None, 0.5).event("EndDialog", "Return")
|
646 |
+
|
647 |
+
#####################################################################
|
648 |
+
# WhichUsers Dialog. Only available on NT, and for privileged users.
|
649 |
+
# This must be run before FindRelatedProducts, because that will
|
650 |
+
# take into account whether the previous installation was per-user
|
651 |
+
# or per-machine. We currently don't support going back to this
|
652 |
+
# dialog after "Next" was selected; to support this, we would need to
|
653 |
+
# find how to reset the ALLUSERS property, and how to re-run
|
654 |
+
# FindRelatedProducts.
|
655 |
+
# On Windows9x, the ALLUSERS property is ignored on the command line
|
656 |
+
# and in the Property table, but installer fails according to the documentation
|
657 |
+
# if a dialog attempts to set ALLUSERS.
|
658 |
+
whichusers = PyDialog(db, "WhichUsersDlg", x, y, w, h, modal, title,
|
659 |
+
"AdminInstall", "Next", "Cancel")
|
660 |
+
whichusers.title("Select whether to install [ProductName] for all users of this computer.")
|
661 |
+
# A radio group with two options: allusers, justme
|
662 |
+
g = whichusers.radiogroup("AdminInstall", 15, 60, 260, 50, 3,
|
663 |
+
"WhichUsers", "", "Next")
|
664 |
+
g.add("ALL", 0, 5, 150, 20, "Install for all users")
|
665 |
+
g.add("JUSTME", 0, 25, 150, 20, "Install just for me")
|
666 |
+
|
667 |
+
whichusers.back("Back", None, active=0)
|
668 |
+
|
669 |
+
c = whichusers.next("Next >", "Cancel")
|
670 |
+
c.event("[ALLUSERS]", "1", 'WhichUsers="ALL"', 1)
|
671 |
+
c.event("EndDialog", "Return", ordering = 2)
|
672 |
+
|
673 |
+
c = whichusers.cancel("Cancel", "AdminInstall")
|
674 |
+
c.event("SpawnDialog", "CancelDlg")
|
675 |
+
|
676 |
+
#####################################################################
|
677 |
+
# Installation Progress dialog (modeless)
|
678 |
+
progress = PyDialog(db, "ProgressDlg", x, y, w, h, modeless, title,
|
679 |
+
"Cancel", "Cancel", "Cancel", bitmap=False)
|
680 |
+
progress.text("Title", 20, 15, 200, 15, 0x30003,
|
681 |
+
r"{\DlgFontBold8}[Progress1] [ProductName]")
|
682 |
+
progress.text("Text", 35, 65, 300, 30, 3,
|
683 |
+
"Please wait while the Installer [Progress2] [ProductName]. "
|
684 |
+
"This may take several minutes.")
|
685 |
+
progress.text("StatusLabel", 35, 100, 35, 20, 3, "Status:")
|
686 |
+
|
687 |
+
c=progress.text("ActionText", 70, 100, w-70, 20, 3, "Pondering...")
|
688 |
+
c.mapping("ActionText", "Text")
|
689 |
+
|
690 |
+
#c=progress.text("ActionData", 35, 140, 300, 20, 3, None)
|
691 |
+
#c.mapping("ActionData", "Text")
|
692 |
+
|
693 |
+
c=progress.control("ProgressBar", "ProgressBar", 35, 120, 300, 10, 65537,
|
694 |
+
None, "Progress done", None, None)
|
695 |
+
c.mapping("SetProgress", "Progress")
|
696 |
+
|
697 |
+
progress.back("< Back", "Next", active=False)
|
698 |
+
progress.next("Next >", "Cancel", active=False)
|
699 |
+
progress.cancel("Cancel", "Back").event("SpawnDialog", "CancelDlg")
|
700 |
+
|
701 |
+
###################################################################
|
702 |
+
# Maintenance type: repair/uninstall
|
703 |
+
maint = PyDialog(db, "MaintenanceTypeDlg", x, y, w, h, modal, title,
|
704 |
+
"Next", "Next", "Cancel")
|
705 |
+
maint.title("Welcome to the [ProductName] Setup Wizard")
|
706 |
+
maint.text("BodyText", 15, 63, 330, 42, 3,
|
707 |
+
"Select whether you want to repair or remove [ProductName].")
|
708 |
+
g=maint.radiogroup("RepairRadioGroup", 15, 108, 330, 60, 3,
|
709 |
+
"MaintenanceForm_Action", "", "Next")
|
710 |
+
#g.add("Change", 0, 0, 200, 17, "&Change [ProductName]")
|
711 |
+
g.add("Repair", 0, 18, 200, 17, "&Repair [ProductName]")
|
712 |
+
g.add("Remove", 0, 36, 200, 17, "Re&move [ProductName]")
|
713 |
+
|
714 |
+
maint.back("< Back", None, active=False)
|
715 |
+
c=maint.next("Finish", "Cancel")
|
716 |
+
# Change installation: Change progress dialog to "Change", then ask
|
717 |
+
# for feature selection
|
718 |
+
#c.event("[Progress1]", "Change", 'MaintenanceForm_Action="Change"', 1)
|
719 |
+
#c.event("[Progress2]", "changes", 'MaintenanceForm_Action="Change"', 2)
|
720 |
+
|
721 |
+
# Reinstall: Change progress dialog to "Repair", then invoke reinstall
|
722 |
+
# Also set list of reinstalled features to "ALL"
|
723 |
+
c.event("[REINSTALL]", "ALL", 'MaintenanceForm_Action="Repair"', 5)
|
724 |
+
c.event("[Progress1]", "Repairing", 'MaintenanceForm_Action="Repair"', 6)
|
725 |
+
c.event("[Progress2]", "repairs", 'MaintenanceForm_Action="Repair"', 7)
|
726 |
+
c.event("Reinstall", "ALL", 'MaintenanceForm_Action="Repair"', 8)
|
727 |
+
|
728 |
+
# Uninstall: Change progress to "Remove", then invoke uninstall
|
729 |
+
# Also set list of removed features to "ALL"
|
730 |
+
c.event("[REMOVE]", "ALL", 'MaintenanceForm_Action="Remove"', 11)
|
731 |
+
c.event("[Progress1]", "Removing", 'MaintenanceForm_Action="Remove"', 12)
|
732 |
+
c.event("[Progress2]", "removes", 'MaintenanceForm_Action="Remove"', 13)
|
733 |
+
c.event("Remove", "ALL", 'MaintenanceForm_Action="Remove"', 14)
|
734 |
+
|
735 |
+
# Close dialog when maintenance action scheduled
|
736 |
+
c.event("EndDialog", "Return", 'MaintenanceForm_Action<>"Change"', 20)
|
737 |
+
#c.event("NewDialog", "SelectFeaturesDlg", 'MaintenanceForm_Action="Change"', 21)
|
738 |
+
|
739 |
+
maint.cancel("Cancel", "RepairRadioGroup").event("SpawnDialog", "CancelDlg")
|
740 |
+
|
741 |
+
def get_installer_filename(self, fullname):
|
742 |
+
# Factored out to allow overriding in subclasses
|
743 |
+
if self.target_version:
|
744 |
+
base_name = "%s.%s-py%s.msi" % (fullname, self.plat_name,
|
745 |
+
self.target_version)
|
746 |
+
else:
|
747 |
+
base_name = "%s.%s.msi" % (fullname, self.plat_name)
|
748 |
+
installer_name = os.path.join(self.dist_dir, base_name)
|
749 |
+
return installer_name
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/bdist_rpm.py
ADDED
@@ -0,0 +1,579 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.bdist_rpm
|
2 |
+
|
3 |
+
Implements the Distutils 'bdist_rpm' command (create RPM source and binary
|
4 |
+
distributions)."""
|
5 |
+
|
6 |
+
import subprocess, sys, os
|
7 |
+
from distutils.core import Command
|
8 |
+
from distutils.debug import DEBUG
|
9 |
+
from distutils.file_util import write_file
|
10 |
+
from distutils.errors import *
|
11 |
+
from distutils.sysconfig import get_python_version
|
12 |
+
from distutils import log
|
13 |
+
|
14 |
+
class bdist_rpm(Command):
|
15 |
+
|
16 |
+
description = "create an RPM distribution"
|
17 |
+
|
18 |
+
user_options = [
|
19 |
+
('bdist-base=', None,
|
20 |
+
"base directory for creating built distributions"),
|
21 |
+
('rpm-base=', None,
|
22 |
+
"base directory for creating RPMs (defaults to \"rpm\" under "
|
23 |
+
"--bdist-base; must be specified for RPM 2)"),
|
24 |
+
('dist-dir=', 'd',
|
25 |
+
"directory to put final RPM files in "
|
26 |
+
"(and .spec files if --spec-only)"),
|
27 |
+
('python=', None,
|
28 |
+
"path to Python interpreter to hard-code in the .spec file "
|
29 |
+
"(default: \"python\")"),
|
30 |
+
('fix-python', None,
|
31 |
+
"hard-code the exact path to the current Python interpreter in "
|
32 |
+
"the .spec file"),
|
33 |
+
('spec-only', None,
|
34 |
+
"only regenerate spec file"),
|
35 |
+
('source-only', None,
|
36 |
+
"only generate source RPM"),
|
37 |
+
('binary-only', None,
|
38 |
+
"only generate binary RPM"),
|
39 |
+
('use-bzip2', None,
|
40 |
+
"use bzip2 instead of gzip to create source distribution"),
|
41 |
+
|
42 |
+
# More meta-data: too RPM-specific to put in the setup script,
|
43 |
+
# but needs to go in the .spec file -- so we make these options
|
44 |
+
# to "bdist_rpm". The idea is that packagers would put this
|
45 |
+
# info in setup.cfg, although they are of course free to
|
46 |
+
# supply it on the command line.
|
47 |
+
('distribution-name=', None,
|
48 |
+
"name of the (Linux) distribution to which this "
|
49 |
+
"RPM applies (*not* the name of the module distribution!)"),
|
50 |
+
('group=', None,
|
51 |
+
"package classification [default: \"Development/Libraries\"]"),
|
52 |
+
('release=', None,
|
53 |
+
"RPM release number"),
|
54 |
+
('serial=', None,
|
55 |
+
"RPM serial number"),
|
56 |
+
('vendor=', None,
|
57 |
+
"RPM \"vendor\" (eg. \"Joe Blow <[email protected]>\") "
|
58 |
+
"[default: maintainer or author from setup script]"),
|
59 |
+
('packager=', None,
|
60 |
+
"RPM packager (eg. \"Jane Doe <[email protected]>\") "
|
61 |
+
"[default: vendor]"),
|
62 |
+
('doc-files=', None,
|
63 |
+
"list of documentation files (space or comma-separated)"),
|
64 |
+
('changelog=', None,
|
65 |
+
"RPM changelog"),
|
66 |
+
('icon=', None,
|
67 |
+
"name of icon file"),
|
68 |
+
('provides=', None,
|
69 |
+
"capabilities provided by this package"),
|
70 |
+
('requires=', None,
|
71 |
+
"capabilities required by this package"),
|
72 |
+
('conflicts=', None,
|
73 |
+
"capabilities which conflict with this package"),
|
74 |
+
('build-requires=', None,
|
75 |
+
"capabilities required to build this package"),
|
76 |
+
('obsoletes=', None,
|
77 |
+
"capabilities made obsolete by this package"),
|
78 |
+
('no-autoreq', None,
|
79 |
+
"do not automatically calculate dependencies"),
|
80 |
+
|
81 |
+
# Actions to take when building RPM
|
82 |
+
('keep-temp', 'k',
|
83 |
+
"don't clean up RPM build directory"),
|
84 |
+
('no-keep-temp', None,
|
85 |
+
"clean up RPM build directory [default]"),
|
86 |
+
('use-rpm-opt-flags', None,
|
87 |
+
"compile with RPM_OPT_FLAGS when building from source RPM"),
|
88 |
+
('no-rpm-opt-flags', None,
|
89 |
+
"do not pass any RPM CFLAGS to compiler"),
|
90 |
+
('rpm3-mode', None,
|
91 |
+
"RPM 3 compatibility mode (default)"),
|
92 |
+
('rpm2-mode', None,
|
93 |
+
"RPM 2 compatibility mode"),
|
94 |
+
|
95 |
+
# Add the hooks necessary for specifying custom scripts
|
96 |
+
('prep-script=', None,
|
97 |
+
"Specify a script for the PREP phase of RPM building"),
|
98 |
+
('build-script=', None,
|
99 |
+
"Specify a script for the BUILD phase of RPM building"),
|
100 |
+
|
101 |
+
('pre-install=', None,
|
102 |
+
"Specify a script for the pre-INSTALL phase of RPM building"),
|
103 |
+
('install-script=', None,
|
104 |
+
"Specify a script for the INSTALL phase of RPM building"),
|
105 |
+
('post-install=', None,
|
106 |
+
"Specify a script for the post-INSTALL phase of RPM building"),
|
107 |
+
|
108 |
+
('pre-uninstall=', None,
|
109 |
+
"Specify a script for the pre-UNINSTALL phase of RPM building"),
|
110 |
+
('post-uninstall=', None,
|
111 |
+
"Specify a script for the post-UNINSTALL phase of RPM building"),
|
112 |
+
|
113 |
+
('clean-script=', None,
|
114 |
+
"Specify a script for the CLEAN phase of RPM building"),
|
115 |
+
|
116 |
+
('verify-script=', None,
|
117 |
+
"Specify a script for the VERIFY phase of the RPM build"),
|
118 |
+
|
119 |
+
# Allow a packager to explicitly force an architecture
|
120 |
+
('force-arch=', None,
|
121 |
+
"Force an architecture onto the RPM build process"),
|
122 |
+
|
123 |
+
('quiet', 'q',
|
124 |
+
"Run the INSTALL phase of RPM building in quiet mode"),
|
125 |
+
]
|
126 |
+
|
127 |
+
boolean_options = ['keep-temp', 'use-rpm-opt-flags', 'rpm3-mode',
|
128 |
+
'no-autoreq', 'quiet']
|
129 |
+
|
130 |
+
negative_opt = {'no-keep-temp': 'keep-temp',
|
131 |
+
'no-rpm-opt-flags': 'use-rpm-opt-flags',
|
132 |
+
'rpm2-mode': 'rpm3-mode'}
|
133 |
+
|
134 |
+
|
135 |
+
def initialize_options(self):
|
136 |
+
self.bdist_base = None
|
137 |
+
self.rpm_base = None
|
138 |
+
self.dist_dir = None
|
139 |
+
self.python = None
|
140 |
+
self.fix_python = None
|
141 |
+
self.spec_only = None
|
142 |
+
self.binary_only = None
|
143 |
+
self.source_only = None
|
144 |
+
self.use_bzip2 = None
|
145 |
+
|
146 |
+
self.distribution_name = None
|
147 |
+
self.group = None
|
148 |
+
self.release = None
|
149 |
+
self.serial = None
|
150 |
+
self.vendor = None
|
151 |
+
self.packager = None
|
152 |
+
self.doc_files = None
|
153 |
+
self.changelog = None
|
154 |
+
self.icon = None
|
155 |
+
|
156 |
+
self.prep_script = None
|
157 |
+
self.build_script = None
|
158 |
+
self.install_script = None
|
159 |
+
self.clean_script = None
|
160 |
+
self.verify_script = None
|
161 |
+
self.pre_install = None
|
162 |
+
self.post_install = None
|
163 |
+
self.pre_uninstall = None
|
164 |
+
self.post_uninstall = None
|
165 |
+
self.prep = None
|
166 |
+
self.provides = None
|
167 |
+
self.requires = None
|
168 |
+
self.conflicts = None
|
169 |
+
self.build_requires = None
|
170 |
+
self.obsoletes = None
|
171 |
+
|
172 |
+
self.keep_temp = 0
|
173 |
+
self.use_rpm_opt_flags = 1
|
174 |
+
self.rpm3_mode = 1
|
175 |
+
self.no_autoreq = 0
|
176 |
+
|
177 |
+
self.force_arch = None
|
178 |
+
self.quiet = 0
|
179 |
+
|
180 |
+
def finalize_options(self):
|
181 |
+
self.set_undefined_options('bdist', ('bdist_base', 'bdist_base'))
|
182 |
+
if self.rpm_base is None:
|
183 |
+
if not self.rpm3_mode:
|
184 |
+
raise DistutilsOptionError(
|
185 |
+
"you must specify --rpm-base in RPM 2 mode")
|
186 |
+
self.rpm_base = os.path.join(self.bdist_base, "rpm")
|
187 |
+
|
188 |
+
if self.python is None:
|
189 |
+
if self.fix_python:
|
190 |
+
self.python = sys.executable
|
191 |
+
else:
|
192 |
+
self.python = "python3"
|
193 |
+
elif self.fix_python:
|
194 |
+
raise DistutilsOptionError(
|
195 |
+
"--python and --fix-python are mutually exclusive options")
|
196 |
+
|
197 |
+
if os.name != 'posix':
|
198 |
+
raise DistutilsPlatformError("don't know how to create RPM "
|
199 |
+
"distributions on platform %s" % os.name)
|
200 |
+
if self.binary_only and self.source_only:
|
201 |
+
raise DistutilsOptionError(
|
202 |
+
"cannot supply both '--source-only' and '--binary-only'")
|
203 |
+
|
204 |
+
# don't pass CFLAGS to pure python distributions
|
205 |
+
if not self.distribution.has_ext_modules():
|
206 |
+
self.use_rpm_opt_flags = 0
|
207 |
+
|
208 |
+
self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))
|
209 |
+
self.finalize_package_data()
|
210 |
+
|
211 |
+
def finalize_package_data(self):
|
212 |
+
self.ensure_string('group', "Development/Libraries")
|
213 |
+
self.ensure_string('vendor',
|
214 |
+
"%s <%s>" % (self.distribution.get_contact(),
|
215 |
+
self.distribution.get_contact_email()))
|
216 |
+
self.ensure_string('packager')
|
217 |
+
self.ensure_string_list('doc_files')
|
218 |
+
if isinstance(self.doc_files, list):
|
219 |
+
for readme in ('README', 'README.txt'):
|
220 |
+
if os.path.exists(readme) and readme not in self.doc_files:
|
221 |
+
self.doc_files.append(readme)
|
222 |
+
|
223 |
+
self.ensure_string('release', "1")
|
224 |
+
self.ensure_string('serial') # should it be an int?
|
225 |
+
|
226 |
+
self.ensure_string('distribution_name')
|
227 |
+
|
228 |
+
self.ensure_string('changelog')
|
229 |
+
# Format changelog correctly
|
230 |
+
self.changelog = self._format_changelog(self.changelog)
|
231 |
+
|
232 |
+
self.ensure_filename('icon')
|
233 |
+
|
234 |
+
self.ensure_filename('prep_script')
|
235 |
+
self.ensure_filename('build_script')
|
236 |
+
self.ensure_filename('install_script')
|
237 |
+
self.ensure_filename('clean_script')
|
238 |
+
self.ensure_filename('verify_script')
|
239 |
+
self.ensure_filename('pre_install')
|
240 |
+
self.ensure_filename('post_install')
|
241 |
+
self.ensure_filename('pre_uninstall')
|
242 |
+
self.ensure_filename('post_uninstall')
|
243 |
+
|
244 |
+
# XXX don't forget we punted on summaries and descriptions -- they
|
245 |
+
# should be handled here eventually!
|
246 |
+
|
247 |
+
# Now *this* is some meta-data that belongs in the setup script...
|
248 |
+
self.ensure_string_list('provides')
|
249 |
+
self.ensure_string_list('requires')
|
250 |
+
self.ensure_string_list('conflicts')
|
251 |
+
self.ensure_string_list('build_requires')
|
252 |
+
self.ensure_string_list('obsoletes')
|
253 |
+
|
254 |
+
self.ensure_string('force_arch')
|
255 |
+
|
256 |
+
def run(self):
|
257 |
+
if DEBUG:
|
258 |
+
print("before _get_package_data():")
|
259 |
+
print("vendor =", self.vendor)
|
260 |
+
print("packager =", self.packager)
|
261 |
+
print("doc_files =", self.doc_files)
|
262 |
+
print("changelog =", self.changelog)
|
263 |
+
|
264 |
+
# make directories
|
265 |
+
if self.spec_only:
|
266 |
+
spec_dir = self.dist_dir
|
267 |
+
self.mkpath(spec_dir)
|
268 |
+
else:
|
269 |
+
rpm_dir = {}
|
270 |
+
for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'):
|
271 |
+
rpm_dir[d] = os.path.join(self.rpm_base, d)
|
272 |
+
self.mkpath(rpm_dir[d])
|
273 |
+
spec_dir = rpm_dir['SPECS']
|
274 |
+
|
275 |
+
# Spec file goes into 'dist_dir' if '--spec-only specified',
|
276 |
+
# build/rpm.<plat> otherwise.
|
277 |
+
spec_path = os.path.join(spec_dir,
|
278 |
+
"%s.spec" % self.distribution.get_name())
|
279 |
+
self.execute(write_file,
|
280 |
+
(spec_path,
|
281 |
+
self._make_spec_file()),
|
282 |
+
"writing '%s'" % spec_path)
|
283 |
+
|
284 |
+
if self.spec_only: # stop if requested
|
285 |
+
return
|
286 |
+
|
287 |
+
# Make a source distribution and copy to SOURCES directory with
|
288 |
+
# optional icon.
|
289 |
+
saved_dist_files = self.distribution.dist_files[:]
|
290 |
+
sdist = self.reinitialize_command('sdist')
|
291 |
+
if self.use_bzip2:
|
292 |
+
sdist.formats = ['bztar']
|
293 |
+
else:
|
294 |
+
sdist.formats = ['gztar']
|
295 |
+
self.run_command('sdist')
|
296 |
+
self.distribution.dist_files = saved_dist_files
|
297 |
+
|
298 |
+
source = sdist.get_archive_files()[0]
|
299 |
+
source_dir = rpm_dir['SOURCES']
|
300 |
+
self.copy_file(source, source_dir)
|
301 |
+
|
302 |
+
if self.icon:
|
303 |
+
if os.path.exists(self.icon):
|
304 |
+
self.copy_file(self.icon, source_dir)
|
305 |
+
else:
|
306 |
+
raise DistutilsFileError(
|
307 |
+
"icon file '%s' does not exist" % self.icon)
|
308 |
+
|
309 |
+
# build package
|
310 |
+
log.info("building RPMs")
|
311 |
+
rpm_cmd = ['rpmbuild']
|
312 |
+
|
313 |
+
if self.source_only: # what kind of RPMs?
|
314 |
+
rpm_cmd.append('-bs')
|
315 |
+
elif self.binary_only:
|
316 |
+
rpm_cmd.append('-bb')
|
317 |
+
else:
|
318 |
+
rpm_cmd.append('-ba')
|
319 |
+
rpm_cmd.extend(['--define', '__python %s' % self.python])
|
320 |
+
if self.rpm3_mode:
|
321 |
+
rpm_cmd.extend(['--define',
|
322 |
+
'_topdir %s' % os.path.abspath(self.rpm_base)])
|
323 |
+
if not self.keep_temp:
|
324 |
+
rpm_cmd.append('--clean')
|
325 |
+
|
326 |
+
if self.quiet:
|
327 |
+
rpm_cmd.append('--quiet')
|
328 |
+
|
329 |
+
rpm_cmd.append(spec_path)
|
330 |
+
# Determine the binary rpm names that should be built out of this spec
|
331 |
+
# file
|
332 |
+
# Note that some of these may not be really built (if the file
|
333 |
+
# list is empty)
|
334 |
+
nvr_string = "%{name}-%{version}-%{release}"
|
335 |
+
src_rpm = nvr_string + ".src.rpm"
|
336 |
+
non_src_rpm = "%{arch}/" + nvr_string + ".%{arch}.rpm"
|
337 |
+
q_cmd = r"rpm -q --qf '%s %s\n' --specfile '%s'" % (
|
338 |
+
src_rpm, non_src_rpm, spec_path)
|
339 |
+
|
340 |
+
out = os.popen(q_cmd)
|
341 |
+
try:
|
342 |
+
binary_rpms = []
|
343 |
+
source_rpm = None
|
344 |
+
while True:
|
345 |
+
line = out.readline()
|
346 |
+
if not line:
|
347 |
+
break
|
348 |
+
l = line.strip().split()
|
349 |
+
assert(len(l) == 2)
|
350 |
+
binary_rpms.append(l[1])
|
351 |
+
# The source rpm is named after the first entry in the spec file
|
352 |
+
if source_rpm is None:
|
353 |
+
source_rpm = l[0]
|
354 |
+
|
355 |
+
status = out.close()
|
356 |
+
if status:
|
357 |
+
raise DistutilsExecError("Failed to execute: %s" % repr(q_cmd))
|
358 |
+
|
359 |
+
finally:
|
360 |
+
out.close()
|
361 |
+
|
362 |
+
self.spawn(rpm_cmd)
|
363 |
+
|
364 |
+
if not self.dry_run:
|
365 |
+
if self.distribution.has_ext_modules():
|
366 |
+
pyversion = get_python_version()
|
367 |
+
else:
|
368 |
+
pyversion = 'any'
|
369 |
+
|
370 |
+
if not self.binary_only:
|
371 |
+
srpm = os.path.join(rpm_dir['SRPMS'], source_rpm)
|
372 |
+
assert(os.path.exists(srpm))
|
373 |
+
self.move_file(srpm, self.dist_dir)
|
374 |
+
filename = os.path.join(self.dist_dir, source_rpm)
|
375 |
+
self.distribution.dist_files.append(
|
376 |
+
('bdist_rpm', pyversion, filename))
|
377 |
+
|
378 |
+
if not self.source_only:
|
379 |
+
for rpm in binary_rpms:
|
380 |
+
rpm = os.path.join(rpm_dir['RPMS'], rpm)
|
381 |
+
if os.path.exists(rpm):
|
382 |
+
self.move_file(rpm, self.dist_dir)
|
383 |
+
filename = os.path.join(self.dist_dir,
|
384 |
+
os.path.basename(rpm))
|
385 |
+
self.distribution.dist_files.append(
|
386 |
+
('bdist_rpm', pyversion, filename))
|
387 |
+
|
388 |
+
def _dist_path(self, path):
|
389 |
+
return os.path.join(self.dist_dir, os.path.basename(path))
|
390 |
+
|
391 |
+
def _make_spec_file(self):
|
392 |
+
"""Generate the text of an RPM spec file and return it as a
|
393 |
+
list of strings (one per line).
|
394 |
+
"""
|
395 |
+
# definitions and headers
|
396 |
+
spec_file = [
|
397 |
+
'%define name ' + self.distribution.get_name(),
|
398 |
+
'%define version ' + self.distribution.get_version().replace('-','_'),
|
399 |
+
'%define unmangled_version ' + self.distribution.get_version(),
|
400 |
+
'%define release ' + self.release.replace('-','_'),
|
401 |
+
'',
|
402 |
+
'Summary: ' + self.distribution.get_description(),
|
403 |
+
]
|
404 |
+
|
405 |
+
# Workaround for #14443 which affects some RPM based systems such as
|
406 |
+
# RHEL6 (and probably derivatives)
|
407 |
+
vendor_hook = subprocess.getoutput('rpm --eval %{__os_install_post}')
|
408 |
+
# Generate a potential replacement value for __os_install_post (whilst
|
409 |
+
# normalizing the whitespace to simplify the test for whether the
|
410 |
+
# invocation of brp-python-bytecompile passes in __python):
|
411 |
+
vendor_hook = '\n'.join([' %s \\' % line.strip()
|
412 |
+
for line in vendor_hook.splitlines()])
|
413 |
+
problem = "brp-python-bytecompile \\\n"
|
414 |
+
fixed = "brp-python-bytecompile %{__python} \\\n"
|
415 |
+
fixed_hook = vendor_hook.replace(problem, fixed)
|
416 |
+
if fixed_hook != vendor_hook:
|
417 |
+
spec_file.append('# Workaround for http://bugs.python.org/issue14443')
|
418 |
+
spec_file.append('%define __os_install_post ' + fixed_hook + '\n')
|
419 |
+
|
420 |
+
# put locale summaries into spec file
|
421 |
+
# XXX not supported for now (hard to put a dictionary
|
422 |
+
# in a config file -- arg!)
|
423 |
+
#for locale in self.summaries.keys():
|
424 |
+
# spec_file.append('Summary(%s): %s' % (locale,
|
425 |
+
# self.summaries[locale]))
|
426 |
+
|
427 |
+
spec_file.extend([
|
428 |
+
'Name: %{name}',
|
429 |
+
'Version: %{version}',
|
430 |
+
'Release: %{release}',])
|
431 |
+
|
432 |
+
# XXX yuck! this filename is available from the "sdist" command,
|
433 |
+
# but only after it has run: and we create the spec file before
|
434 |
+
# running "sdist", in case of --spec-only.
|
435 |
+
if self.use_bzip2:
|
436 |
+
spec_file.append('Source0: %{name}-%{unmangled_version}.tar.bz2')
|
437 |
+
else:
|
438 |
+
spec_file.append('Source0: %{name}-%{unmangled_version}.tar.gz')
|
439 |
+
|
440 |
+
spec_file.extend([
|
441 |
+
'License: ' + self.distribution.get_license(),
|
442 |
+
'Group: ' + self.group,
|
443 |
+
'BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot',
|
444 |
+
'Prefix: %{_prefix}', ])
|
445 |
+
|
446 |
+
if not self.force_arch:
|
447 |
+
# noarch if no extension modules
|
448 |
+
if not self.distribution.has_ext_modules():
|
449 |
+
spec_file.append('BuildArch: noarch')
|
450 |
+
else:
|
451 |
+
spec_file.append( 'BuildArch: %s' % self.force_arch )
|
452 |
+
|
453 |
+
for field in ('Vendor',
|
454 |
+
'Packager',
|
455 |
+
'Provides',
|
456 |
+
'Requires',
|
457 |
+
'Conflicts',
|
458 |
+
'Obsoletes',
|
459 |
+
):
|
460 |
+
val = getattr(self, field.lower())
|
461 |
+
if isinstance(val, list):
|
462 |
+
spec_file.append('%s: %s' % (field, ' '.join(val)))
|
463 |
+
elif val is not None:
|
464 |
+
spec_file.append('%s: %s' % (field, val))
|
465 |
+
|
466 |
+
|
467 |
+
if self.distribution.get_url() != 'UNKNOWN':
|
468 |
+
spec_file.append('Url: ' + self.distribution.get_url())
|
469 |
+
|
470 |
+
if self.distribution_name:
|
471 |
+
spec_file.append('Distribution: ' + self.distribution_name)
|
472 |
+
|
473 |
+
if self.build_requires:
|
474 |
+
spec_file.append('BuildRequires: ' +
|
475 |
+
' '.join(self.build_requires))
|
476 |
+
|
477 |
+
if self.icon:
|
478 |
+
spec_file.append('Icon: ' + os.path.basename(self.icon))
|
479 |
+
|
480 |
+
if self.no_autoreq:
|
481 |
+
spec_file.append('AutoReq: 0')
|
482 |
+
|
483 |
+
spec_file.extend([
|
484 |
+
'',
|
485 |
+
'%description',
|
486 |
+
self.distribution.get_long_description()
|
487 |
+
])
|
488 |
+
|
489 |
+
# put locale descriptions into spec file
|
490 |
+
# XXX again, suppressed because config file syntax doesn't
|
491 |
+
# easily support this ;-(
|
492 |
+
#for locale in self.descriptions.keys():
|
493 |
+
# spec_file.extend([
|
494 |
+
# '',
|
495 |
+
# '%description -l ' + locale,
|
496 |
+
# self.descriptions[locale],
|
497 |
+
# ])
|
498 |
+
|
499 |
+
# rpm scripts
|
500 |
+
# figure out default build script
|
501 |
+
def_setup_call = "%s %s" % (self.python,os.path.basename(sys.argv[0]))
|
502 |
+
def_build = "%s build" % def_setup_call
|
503 |
+
if self.use_rpm_opt_flags:
|
504 |
+
def_build = 'env CFLAGS="$RPM_OPT_FLAGS" ' + def_build
|
505 |
+
|
506 |
+
# insert contents of files
|
507 |
+
|
508 |
+
# XXX this is kind of misleading: user-supplied options are files
|
509 |
+
# that we open and interpolate into the spec file, but the defaults
|
510 |
+
# are just text that we drop in as-is. Hmmm.
|
511 |
+
|
512 |
+
install_cmd = ('%s install -O1 --root=$RPM_BUILD_ROOT '
|
513 |
+
'--record=INSTALLED_FILES') % def_setup_call
|
514 |
+
|
515 |
+
script_options = [
|
516 |
+
('prep', 'prep_script', "%setup -n %{name}-%{unmangled_version}"),
|
517 |
+
('build', 'build_script', def_build),
|
518 |
+
('install', 'install_script', install_cmd),
|
519 |
+
('clean', 'clean_script', "rm -rf $RPM_BUILD_ROOT"),
|
520 |
+
('verifyscript', 'verify_script', None),
|
521 |
+
('pre', 'pre_install', None),
|
522 |
+
('post', 'post_install', None),
|
523 |
+
('preun', 'pre_uninstall', None),
|
524 |
+
('postun', 'post_uninstall', None),
|
525 |
+
]
|
526 |
+
|
527 |
+
for (rpm_opt, attr, default) in script_options:
|
528 |
+
# Insert contents of file referred to, if no file is referred to
|
529 |
+
# use 'default' as contents of script
|
530 |
+
val = getattr(self, attr)
|
531 |
+
if val or default:
|
532 |
+
spec_file.extend([
|
533 |
+
'',
|
534 |
+
'%' + rpm_opt,])
|
535 |
+
if val:
|
536 |
+
with open(val) as f:
|
537 |
+
spec_file.extend(f.read().split('\n'))
|
538 |
+
else:
|
539 |
+
spec_file.append(default)
|
540 |
+
|
541 |
+
|
542 |
+
# files section
|
543 |
+
spec_file.extend([
|
544 |
+
'',
|
545 |
+
'%files -f INSTALLED_FILES',
|
546 |
+
'%defattr(-,root,root)',
|
547 |
+
])
|
548 |
+
|
549 |
+
if self.doc_files:
|
550 |
+
spec_file.append('%doc ' + ' '.join(self.doc_files))
|
551 |
+
|
552 |
+
if self.changelog:
|
553 |
+
spec_file.extend([
|
554 |
+
'',
|
555 |
+
'%changelog',])
|
556 |
+
spec_file.extend(self.changelog)
|
557 |
+
|
558 |
+
return spec_file
|
559 |
+
|
560 |
+
def _format_changelog(self, changelog):
|
561 |
+
"""Format the changelog correctly and convert it to a list of strings
|
562 |
+
"""
|
563 |
+
if not changelog:
|
564 |
+
return changelog
|
565 |
+
new_changelog = []
|
566 |
+
for line in changelog.strip().split('\n'):
|
567 |
+
line = line.strip()
|
568 |
+
if line[0] == '*':
|
569 |
+
new_changelog.extend(['', line])
|
570 |
+
elif line[0] == '-':
|
571 |
+
new_changelog.append(line)
|
572 |
+
else:
|
573 |
+
new_changelog.append(' ' + line)
|
574 |
+
|
575 |
+
# strip trailing newline inserted by first changelog entry
|
576 |
+
if not new_changelog[0]:
|
577 |
+
del new_changelog[0]
|
578 |
+
|
579 |
+
return new_changelog
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/bdist_wininst.py
ADDED
@@ -0,0 +1,377 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.bdist_wininst
|
2 |
+
|
3 |
+
Implements the Distutils 'bdist_wininst' command: create a windows installer
|
4 |
+
exe-program."""
|
5 |
+
|
6 |
+
import os
|
7 |
+
import sys
|
8 |
+
import warnings
|
9 |
+
from distutils.core import Command
|
10 |
+
from distutils.util import get_platform
|
11 |
+
from distutils.dir_util import remove_tree
|
12 |
+
from distutils.errors import *
|
13 |
+
from distutils.sysconfig import get_python_version
|
14 |
+
from distutils import log
|
15 |
+
|
16 |
+
class bdist_wininst(Command):
|
17 |
+
|
18 |
+
description = "create an executable installer for MS Windows"
|
19 |
+
|
20 |
+
user_options = [('bdist-dir=', None,
|
21 |
+
"temporary directory for creating the distribution"),
|
22 |
+
('plat-name=', 'p',
|
23 |
+
"platform name to embed in generated filenames "
|
24 |
+
"(default: %s)" % get_platform()),
|
25 |
+
('keep-temp', 'k',
|
26 |
+
"keep the pseudo-installation tree around after " +
|
27 |
+
"creating the distribution archive"),
|
28 |
+
('target-version=', None,
|
29 |
+
"require a specific python version" +
|
30 |
+
" on the target system"),
|
31 |
+
('no-target-compile', 'c',
|
32 |
+
"do not compile .py to .pyc on the target system"),
|
33 |
+
('no-target-optimize', 'o',
|
34 |
+
"do not compile .py to .pyo (optimized) "
|
35 |
+
"on the target system"),
|
36 |
+
('dist-dir=', 'd',
|
37 |
+
"directory to put final built distributions in"),
|
38 |
+
('bitmap=', 'b',
|
39 |
+
"bitmap to use for the installer instead of python-powered logo"),
|
40 |
+
('title=', 't',
|
41 |
+
"title to display on the installer background instead of default"),
|
42 |
+
('skip-build', None,
|
43 |
+
"skip rebuilding everything (for testing/debugging)"),
|
44 |
+
('install-script=', None,
|
45 |
+
"basename of installation script to be run after "
|
46 |
+
"installation or before deinstallation"),
|
47 |
+
('pre-install-script=', None,
|
48 |
+
"Fully qualified filename of a script to be run before "
|
49 |
+
"any files are installed. This script need not be in the "
|
50 |
+
"distribution"),
|
51 |
+
('user-access-control=', None,
|
52 |
+
"specify Vista's UAC handling - 'none'/default=no "
|
53 |
+
"handling, 'auto'=use UAC if target Python installed for "
|
54 |
+
"all users, 'force'=always use UAC"),
|
55 |
+
]
|
56 |
+
|
57 |
+
boolean_options = ['keep-temp', 'no-target-compile', 'no-target-optimize',
|
58 |
+
'skip-build']
|
59 |
+
|
60 |
+
# bpo-10945: bdist_wininst requires mbcs encoding only available on Windows
|
61 |
+
_unsupported = (sys.platform != "win32")
|
62 |
+
|
63 |
+
def __init__(self, *args, **kw):
|
64 |
+
super().__init__(*args, **kw)
|
65 |
+
warnings.warn("bdist_wininst command is deprecated since Python 3.8, "
|
66 |
+
"use bdist_wheel (wheel packages) instead",
|
67 |
+
DeprecationWarning, 2)
|
68 |
+
|
69 |
+
def initialize_options(self):
|
70 |
+
self.bdist_dir = None
|
71 |
+
self.plat_name = None
|
72 |
+
self.keep_temp = 0
|
73 |
+
self.no_target_compile = 0
|
74 |
+
self.no_target_optimize = 0
|
75 |
+
self.target_version = None
|
76 |
+
self.dist_dir = None
|
77 |
+
self.bitmap = None
|
78 |
+
self.title = None
|
79 |
+
self.skip_build = None
|
80 |
+
self.install_script = None
|
81 |
+
self.pre_install_script = None
|
82 |
+
self.user_access_control = None
|
83 |
+
|
84 |
+
|
85 |
+
def finalize_options(self):
|
86 |
+
self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
|
87 |
+
|
88 |
+
if self.bdist_dir is None:
|
89 |
+
if self.skip_build and self.plat_name:
|
90 |
+
# If build is skipped and plat_name is overridden, bdist will
|
91 |
+
# not see the correct 'plat_name' - so set that up manually.
|
92 |
+
bdist = self.distribution.get_command_obj('bdist')
|
93 |
+
bdist.plat_name = self.plat_name
|
94 |
+
# next the command will be initialized using that name
|
95 |
+
bdist_base = self.get_finalized_command('bdist').bdist_base
|
96 |
+
self.bdist_dir = os.path.join(bdist_base, 'wininst')
|
97 |
+
|
98 |
+
if not self.target_version:
|
99 |
+
self.target_version = ""
|
100 |
+
|
101 |
+
if not self.skip_build and self.distribution.has_ext_modules():
|
102 |
+
short_version = get_python_version()
|
103 |
+
if self.target_version and self.target_version != short_version:
|
104 |
+
raise DistutilsOptionError(
|
105 |
+
"target version can only be %s, or the '--skip-build'" \
|
106 |
+
" option must be specified" % (short_version,))
|
107 |
+
self.target_version = short_version
|
108 |
+
|
109 |
+
self.set_undefined_options('bdist',
|
110 |
+
('dist_dir', 'dist_dir'),
|
111 |
+
('plat_name', 'plat_name'),
|
112 |
+
)
|
113 |
+
|
114 |
+
if self.install_script:
|
115 |
+
for script in self.distribution.scripts:
|
116 |
+
if self.install_script == os.path.basename(script):
|
117 |
+
break
|
118 |
+
else:
|
119 |
+
raise DistutilsOptionError(
|
120 |
+
"install_script '%s' not found in scripts"
|
121 |
+
% self.install_script)
|
122 |
+
|
123 |
+
def run(self):
|
124 |
+
if (sys.platform != "win32" and
|
125 |
+
(self.distribution.has_ext_modules() or
|
126 |
+
self.distribution.has_c_libraries())):
|
127 |
+
raise DistutilsPlatformError \
|
128 |
+
("distribution contains extensions and/or C libraries; "
|
129 |
+
"must be compiled on a Windows 32 platform")
|
130 |
+
|
131 |
+
if not self.skip_build:
|
132 |
+
self.run_command('build')
|
133 |
+
|
134 |
+
install = self.reinitialize_command('install', reinit_subcommands=1)
|
135 |
+
install.root = self.bdist_dir
|
136 |
+
install.skip_build = self.skip_build
|
137 |
+
install.warn_dir = 0
|
138 |
+
install.plat_name = self.plat_name
|
139 |
+
|
140 |
+
install_lib = self.reinitialize_command('install_lib')
|
141 |
+
# we do not want to include pyc or pyo files
|
142 |
+
install_lib.compile = 0
|
143 |
+
install_lib.optimize = 0
|
144 |
+
|
145 |
+
if self.distribution.has_ext_modules():
|
146 |
+
# If we are building an installer for a Python version other
|
147 |
+
# than the one we are currently running, then we need to ensure
|
148 |
+
# our build_lib reflects the other Python version rather than ours.
|
149 |
+
# Note that for target_version!=sys.version, we must have skipped the
|
150 |
+
# build step, so there is no issue with enforcing the build of this
|
151 |
+
# version.
|
152 |
+
target_version = self.target_version
|
153 |
+
if not target_version:
|
154 |
+
assert self.skip_build, "Should have already checked this"
|
155 |
+
target_version = '%d.%d' % sys.version_info[:2]
|
156 |
+
plat_specifier = ".%s-%s" % (self.plat_name, target_version)
|
157 |
+
build = self.get_finalized_command('build')
|
158 |
+
build.build_lib = os.path.join(build.build_base,
|
159 |
+
'lib' + plat_specifier)
|
160 |
+
|
161 |
+
# Use a custom scheme for the zip-file, because we have to decide
|
162 |
+
# at installation time which scheme to use.
|
163 |
+
for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'):
|
164 |
+
value = key.upper()
|
165 |
+
if key == 'headers':
|
166 |
+
value = value + '/Include/$dist_name'
|
167 |
+
setattr(install,
|
168 |
+
'install_' + key,
|
169 |
+
value)
|
170 |
+
|
171 |
+
log.info("installing to %s", self.bdist_dir)
|
172 |
+
install.ensure_finalized()
|
173 |
+
|
174 |
+
# avoid warning of 'install_lib' about installing
|
175 |
+
# into a directory not in sys.path
|
176 |
+
sys.path.insert(0, os.path.join(self.bdist_dir, 'PURELIB'))
|
177 |
+
|
178 |
+
install.run()
|
179 |
+
|
180 |
+
del sys.path[0]
|
181 |
+
|
182 |
+
# And make an archive relative to the root of the
|
183 |
+
# pseudo-installation tree.
|
184 |
+
from tempfile import mktemp
|
185 |
+
archive_basename = mktemp()
|
186 |
+
fullname = self.distribution.get_fullname()
|
187 |
+
arcname = self.make_archive(archive_basename, "zip",
|
188 |
+
root_dir=self.bdist_dir)
|
189 |
+
# create an exe containing the zip-file
|
190 |
+
self.create_exe(arcname, fullname, self.bitmap)
|
191 |
+
if self.distribution.has_ext_modules():
|
192 |
+
pyversion = get_python_version()
|
193 |
+
else:
|
194 |
+
pyversion = 'any'
|
195 |
+
self.distribution.dist_files.append(('bdist_wininst', pyversion,
|
196 |
+
self.get_installer_filename(fullname)))
|
197 |
+
# remove the zip-file again
|
198 |
+
log.debug("removing temporary file '%s'", arcname)
|
199 |
+
os.remove(arcname)
|
200 |
+
|
201 |
+
if not self.keep_temp:
|
202 |
+
remove_tree(self.bdist_dir, dry_run=self.dry_run)
|
203 |
+
|
204 |
+
def get_inidata(self):
|
205 |
+
# Return data describing the installation.
|
206 |
+
lines = []
|
207 |
+
metadata = self.distribution.metadata
|
208 |
+
|
209 |
+
# Write the [metadata] section.
|
210 |
+
lines.append("[metadata]")
|
211 |
+
|
212 |
+
# 'info' will be displayed in the installer's dialog box,
|
213 |
+
# describing the items to be installed.
|
214 |
+
info = (metadata.long_description or '') + '\n'
|
215 |
+
|
216 |
+
# Escape newline characters
|
217 |
+
def escape(s):
|
218 |
+
return s.replace("\n", "\\n")
|
219 |
+
|
220 |
+
for name in ["author", "author_email", "description", "maintainer",
|
221 |
+
"maintainer_email", "name", "url", "version"]:
|
222 |
+
data = getattr(metadata, name, "")
|
223 |
+
if data:
|
224 |
+
info = info + ("\n %s: %s" % \
|
225 |
+
(name.capitalize(), escape(data)))
|
226 |
+
lines.append("%s=%s" % (name, escape(data)))
|
227 |
+
|
228 |
+
# The [setup] section contains entries controlling
|
229 |
+
# the installer runtime.
|
230 |
+
lines.append("\n[Setup]")
|
231 |
+
if self.install_script:
|
232 |
+
lines.append("install_script=%s" % self.install_script)
|
233 |
+
lines.append("info=%s" % escape(info))
|
234 |
+
lines.append("target_compile=%d" % (not self.no_target_compile))
|
235 |
+
lines.append("target_optimize=%d" % (not self.no_target_optimize))
|
236 |
+
if self.target_version:
|
237 |
+
lines.append("target_version=%s" % self.target_version)
|
238 |
+
if self.user_access_control:
|
239 |
+
lines.append("user_access_control=%s" % self.user_access_control)
|
240 |
+
|
241 |
+
title = self.title or self.distribution.get_fullname()
|
242 |
+
lines.append("title=%s" % escape(title))
|
243 |
+
import time
|
244 |
+
import distutils
|
245 |
+
build_info = "Built %s with distutils-%s" % \
|
246 |
+
(time.ctime(time.time()), distutils.__version__)
|
247 |
+
lines.append("build_info=%s" % build_info)
|
248 |
+
return "\n".join(lines)
|
249 |
+
|
250 |
+
def create_exe(self, arcname, fullname, bitmap=None):
|
251 |
+
import struct
|
252 |
+
|
253 |
+
self.mkpath(self.dist_dir)
|
254 |
+
|
255 |
+
cfgdata = self.get_inidata()
|
256 |
+
|
257 |
+
installer_name = self.get_installer_filename(fullname)
|
258 |
+
self.announce("creating %s" % installer_name)
|
259 |
+
|
260 |
+
if bitmap:
|
261 |
+
with open(bitmap, "rb") as f:
|
262 |
+
bitmapdata = f.read()
|
263 |
+
bitmaplen = len(bitmapdata)
|
264 |
+
else:
|
265 |
+
bitmaplen = 0
|
266 |
+
|
267 |
+
with open(installer_name, "wb") as file:
|
268 |
+
file.write(self.get_exe_bytes())
|
269 |
+
if bitmap:
|
270 |
+
file.write(bitmapdata)
|
271 |
+
|
272 |
+
# Convert cfgdata from unicode to ascii, mbcs encoded
|
273 |
+
if isinstance(cfgdata, str):
|
274 |
+
cfgdata = cfgdata.encode("mbcs")
|
275 |
+
|
276 |
+
# Append the pre-install script
|
277 |
+
cfgdata = cfgdata + b"\0"
|
278 |
+
if self.pre_install_script:
|
279 |
+
# We need to normalize newlines, so we open in text mode and
|
280 |
+
# convert back to bytes. "latin-1" simply avoids any possible
|
281 |
+
# failures.
|
282 |
+
with open(self.pre_install_script, "r",
|
283 |
+
encoding="latin-1") as script:
|
284 |
+
script_data = script.read().encode("latin-1")
|
285 |
+
cfgdata = cfgdata + script_data + b"\n\0"
|
286 |
+
else:
|
287 |
+
# empty pre-install script
|
288 |
+
cfgdata = cfgdata + b"\0"
|
289 |
+
file.write(cfgdata)
|
290 |
+
|
291 |
+
# The 'magic number' 0x1234567B is used to make sure that the
|
292 |
+
# binary layout of 'cfgdata' is what the wininst.exe binary
|
293 |
+
# expects. If the layout changes, increment that number, make
|
294 |
+
# the corresponding changes to the wininst.exe sources, and
|
295 |
+
# recompile them.
|
296 |
+
header = struct.pack("<iii",
|
297 |
+
0x1234567B, # tag
|
298 |
+
len(cfgdata), # length
|
299 |
+
bitmaplen, # number of bytes in bitmap
|
300 |
+
)
|
301 |
+
file.write(header)
|
302 |
+
with open(arcname, "rb") as f:
|
303 |
+
file.write(f.read())
|
304 |
+
|
305 |
+
def get_installer_filename(self, fullname):
|
306 |
+
# Factored out to allow overriding in subclasses
|
307 |
+
if self.target_version:
|
308 |
+
# if we create an installer for a specific python version,
|
309 |
+
# it's better to include this in the name
|
310 |
+
installer_name = os.path.join(self.dist_dir,
|
311 |
+
"%s.%s-py%s.exe" %
|
312 |
+
(fullname, self.plat_name, self.target_version))
|
313 |
+
else:
|
314 |
+
installer_name = os.path.join(self.dist_dir,
|
315 |
+
"%s.%s.exe" % (fullname, self.plat_name))
|
316 |
+
return installer_name
|
317 |
+
|
318 |
+
def get_exe_bytes(self):
|
319 |
+
# If a target-version other than the current version has been
|
320 |
+
# specified, then using the MSVC version from *this* build is no good.
|
321 |
+
# Without actually finding and executing the target version and parsing
|
322 |
+
# its sys.version, we just hard-code our knowledge of old versions.
|
323 |
+
# NOTE: Possible alternative is to allow "--target-version" to
|
324 |
+
# specify a Python executable rather than a simple version string.
|
325 |
+
# We can then execute this program to obtain any info we need, such
|
326 |
+
# as the real sys.version string for the build.
|
327 |
+
cur_version = get_python_version()
|
328 |
+
|
329 |
+
# If the target version is *later* than us, then we assume they
|
330 |
+
# use what we use
|
331 |
+
# string compares seem wrong, but are what sysconfig.py itself uses
|
332 |
+
if self.target_version and self.target_version < cur_version:
|
333 |
+
if self.target_version < "2.4":
|
334 |
+
bv = '6.0'
|
335 |
+
elif self.target_version == "2.4":
|
336 |
+
bv = '7.1'
|
337 |
+
elif self.target_version == "2.5":
|
338 |
+
bv = '8.0'
|
339 |
+
elif self.target_version <= "3.2":
|
340 |
+
bv = '9.0'
|
341 |
+
elif self.target_version <= "3.4":
|
342 |
+
bv = '10.0'
|
343 |
+
else:
|
344 |
+
bv = '14.0'
|
345 |
+
else:
|
346 |
+
# for current version - use authoritative check.
|
347 |
+
try:
|
348 |
+
from msvcrt import CRT_ASSEMBLY_VERSION
|
349 |
+
except ImportError:
|
350 |
+
# cross-building, so assume the latest version
|
351 |
+
bv = '14.0'
|
352 |
+
else:
|
353 |
+
# as far as we know, CRT is binary compatible based on
|
354 |
+
# the first field, so assume 'x.0' until proven otherwise
|
355 |
+
major = CRT_ASSEMBLY_VERSION.partition('.')[0]
|
356 |
+
bv = major + '.0'
|
357 |
+
|
358 |
+
|
359 |
+
# wininst-x.y.exe is in the same directory as this file
|
360 |
+
directory = os.path.dirname(__file__)
|
361 |
+
# we must use a wininst-x.y.exe built with the same C compiler
|
362 |
+
# used for python. XXX What about mingw, borland, and so on?
|
363 |
+
|
364 |
+
# if plat_name starts with "win" but is not "win32"
|
365 |
+
# we want to strip "win" and leave the rest (e.g. -amd64)
|
366 |
+
# for all other cases, we don't want any suffix
|
367 |
+
if self.plat_name != 'win32' and self.plat_name[:3] == 'win':
|
368 |
+
sfix = self.plat_name[3:]
|
369 |
+
else:
|
370 |
+
sfix = ''
|
371 |
+
|
372 |
+
filename = os.path.join(directory, "wininst-%s%s.exe" % (bv, sfix))
|
373 |
+
f = open(filename, "rb")
|
374 |
+
try:
|
375 |
+
return f.read()
|
376 |
+
finally:
|
377 |
+
f.close()
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/build.py
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.build
|
2 |
+
|
3 |
+
Implements the Distutils 'build' command."""
|
4 |
+
|
5 |
+
import sys, os
|
6 |
+
from distutils.core import Command
|
7 |
+
from distutils.errors import DistutilsOptionError
|
8 |
+
from distutils.util import get_platform
|
9 |
+
|
10 |
+
|
11 |
+
def show_compilers():
|
12 |
+
from distutils.ccompiler import show_compilers
|
13 |
+
show_compilers()
|
14 |
+
|
15 |
+
|
16 |
+
class build(Command):
|
17 |
+
|
18 |
+
description = "build everything needed to install"
|
19 |
+
|
20 |
+
user_options = [
|
21 |
+
('build-base=', 'b',
|
22 |
+
"base directory for build library"),
|
23 |
+
('build-purelib=', None,
|
24 |
+
"build directory for platform-neutral distributions"),
|
25 |
+
('build-platlib=', None,
|
26 |
+
"build directory for platform-specific distributions"),
|
27 |
+
('build-lib=', None,
|
28 |
+
"build directory for all distribution (defaults to either " +
|
29 |
+
"build-purelib or build-platlib"),
|
30 |
+
('build-scripts=', None,
|
31 |
+
"build directory for scripts"),
|
32 |
+
('build-temp=', 't',
|
33 |
+
"temporary build directory"),
|
34 |
+
('plat-name=', 'p',
|
35 |
+
"platform name to build for, if supported "
|
36 |
+
"(default: %s)" % get_platform()),
|
37 |
+
('compiler=', 'c',
|
38 |
+
"specify the compiler type"),
|
39 |
+
('parallel=', 'j',
|
40 |
+
"number of parallel build jobs"),
|
41 |
+
('debug', 'g',
|
42 |
+
"compile extensions and libraries with debugging information"),
|
43 |
+
('force', 'f',
|
44 |
+
"forcibly build everything (ignore file timestamps)"),
|
45 |
+
('executable=', 'e',
|
46 |
+
"specify final destination interpreter path (build.py)"),
|
47 |
+
]
|
48 |
+
|
49 |
+
boolean_options = ['debug', 'force']
|
50 |
+
|
51 |
+
help_options = [
|
52 |
+
('help-compiler', None,
|
53 |
+
"list available compilers", show_compilers),
|
54 |
+
]
|
55 |
+
|
56 |
+
def initialize_options(self):
|
57 |
+
self.build_base = 'build'
|
58 |
+
# these are decided only after 'build_base' has its final value
|
59 |
+
# (unless overridden by the user or client)
|
60 |
+
self.build_purelib = None
|
61 |
+
self.build_platlib = None
|
62 |
+
self.build_lib = None
|
63 |
+
self.build_temp = None
|
64 |
+
self.build_scripts = None
|
65 |
+
self.compiler = None
|
66 |
+
self.plat_name = None
|
67 |
+
self.debug = None
|
68 |
+
self.force = 0
|
69 |
+
self.executable = None
|
70 |
+
self.parallel = None
|
71 |
+
|
72 |
+
def finalize_options(self):
|
73 |
+
if self.plat_name is None:
|
74 |
+
self.plat_name = get_platform()
|
75 |
+
else:
|
76 |
+
# plat-name only supported for windows (other platforms are
|
77 |
+
# supported via ./configure flags, if at all). Avoid misleading
|
78 |
+
# other platforms.
|
79 |
+
if os.name != 'nt':
|
80 |
+
raise DistutilsOptionError(
|
81 |
+
"--plat-name only supported on Windows (try "
|
82 |
+
"using './configure --help' on your platform)")
|
83 |
+
|
84 |
+
plat_specifier = ".%s-%d.%d" % (self.plat_name, *sys.version_info[:2])
|
85 |
+
|
86 |
+
# Make it so Python 2.x and Python 2.x with --with-pydebug don't
|
87 |
+
# share the same build directories. Doing so confuses the build
|
88 |
+
# process for C modules
|
89 |
+
if hasattr(sys, 'gettotalrefcount'):
|
90 |
+
plat_specifier += '-pydebug'
|
91 |
+
|
92 |
+
# 'build_purelib' and 'build_platlib' just default to 'lib' and
|
93 |
+
# 'lib.<plat>' under the base build directory. We only use one of
|
94 |
+
# them for a given distribution, though --
|
95 |
+
if self.build_purelib is None:
|
96 |
+
self.build_purelib = os.path.join(self.build_base, 'lib')
|
97 |
+
if self.build_platlib is None:
|
98 |
+
self.build_platlib = os.path.join(self.build_base,
|
99 |
+
'lib' + plat_specifier)
|
100 |
+
|
101 |
+
# 'build_lib' is the actual directory that we will use for this
|
102 |
+
# particular module distribution -- if user didn't supply it, pick
|
103 |
+
# one of 'build_purelib' or 'build_platlib'.
|
104 |
+
if self.build_lib is None:
|
105 |
+
if self.distribution.has_ext_modules():
|
106 |
+
self.build_lib = self.build_platlib
|
107 |
+
else:
|
108 |
+
self.build_lib = self.build_purelib
|
109 |
+
|
110 |
+
# 'build_temp' -- temporary directory for compiler turds,
|
111 |
+
# "build/temp.<plat>"
|
112 |
+
if self.build_temp is None:
|
113 |
+
self.build_temp = os.path.join(self.build_base,
|
114 |
+
'temp' + plat_specifier)
|
115 |
+
if self.build_scripts is None:
|
116 |
+
self.build_scripts = os.path.join(self.build_base,
|
117 |
+
'scripts-%d.%d' % sys.version_info[:2])
|
118 |
+
|
119 |
+
if self.executable is None and sys.executable:
|
120 |
+
self.executable = os.path.normpath(sys.executable)
|
121 |
+
|
122 |
+
if isinstance(self.parallel, str):
|
123 |
+
try:
|
124 |
+
self.parallel = int(self.parallel)
|
125 |
+
except ValueError:
|
126 |
+
raise DistutilsOptionError("parallel should be an integer")
|
127 |
+
|
128 |
+
def run(self):
|
129 |
+
# Run all relevant sub-commands. This will be some subset of:
|
130 |
+
# - build_py - pure Python modules
|
131 |
+
# - build_clib - standalone C libraries
|
132 |
+
# - build_ext - Python extensions
|
133 |
+
# - build_scripts - (Python) scripts
|
134 |
+
for cmd_name in self.get_sub_commands():
|
135 |
+
self.run_command(cmd_name)
|
136 |
+
|
137 |
+
|
138 |
+
# -- Predicates for the sub-command list ---------------------------
|
139 |
+
|
140 |
+
def has_pure_modules(self):
|
141 |
+
return self.distribution.has_pure_modules()
|
142 |
+
|
143 |
+
def has_c_libraries(self):
|
144 |
+
return self.distribution.has_c_libraries()
|
145 |
+
|
146 |
+
def has_ext_modules(self):
|
147 |
+
return self.distribution.has_ext_modules()
|
148 |
+
|
149 |
+
def has_scripts(self):
|
150 |
+
return self.distribution.has_scripts()
|
151 |
+
|
152 |
+
|
153 |
+
sub_commands = [('build_py', has_pure_modules),
|
154 |
+
('build_clib', has_c_libraries),
|
155 |
+
('build_ext', has_ext_modules),
|
156 |
+
('build_scripts', has_scripts),
|
157 |
+
]
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/build_clib.py
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.build_clib
|
2 |
+
|
3 |
+
Implements the Distutils 'build_clib' command, to build a C/C++ library
|
4 |
+
that is included in the module distribution and needed by an extension
|
5 |
+
module."""
|
6 |
+
|
7 |
+
|
8 |
+
# XXX this module has *lots* of code ripped-off quite transparently from
|
9 |
+
# build_ext.py -- not surprisingly really, as the work required to build
|
10 |
+
# a static library from a collection of C source files is not really all
|
11 |
+
# that different from what's required to build a shared object file from
|
12 |
+
# a collection of C source files. Nevertheless, I haven't done the
|
13 |
+
# necessary refactoring to account for the overlap in code between the
|
14 |
+
# two modules, mainly because a number of subtle details changed in the
|
15 |
+
# cut 'n paste. Sigh.
|
16 |
+
|
17 |
+
import os
|
18 |
+
from distutils.core import Command
|
19 |
+
from distutils.errors import *
|
20 |
+
from distutils.sysconfig import customize_compiler
|
21 |
+
from distutils import log
|
22 |
+
|
23 |
+
def show_compilers():
|
24 |
+
from distutils.ccompiler import show_compilers
|
25 |
+
show_compilers()
|
26 |
+
|
27 |
+
|
28 |
+
class build_clib(Command):
|
29 |
+
|
30 |
+
description = "build C/C++ libraries used by Python extensions"
|
31 |
+
|
32 |
+
user_options = [
|
33 |
+
('build-clib=', 'b',
|
34 |
+
"directory to build C/C++ libraries to"),
|
35 |
+
('build-temp=', 't',
|
36 |
+
"directory to put temporary build by-products"),
|
37 |
+
('debug', 'g',
|
38 |
+
"compile with debugging information"),
|
39 |
+
('force', 'f',
|
40 |
+
"forcibly build everything (ignore file timestamps)"),
|
41 |
+
('compiler=', 'c',
|
42 |
+
"specify the compiler type"),
|
43 |
+
]
|
44 |
+
|
45 |
+
boolean_options = ['debug', 'force']
|
46 |
+
|
47 |
+
help_options = [
|
48 |
+
('help-compiler', None,
|
49 |
+
"list available compilers", show_compilers),
|
50 |
+
]
|
51 |
+
|
52 |
+
def initialize_options(self):
|
53 |
+
self.build_clib = None
|
54 |
+
self.build_temp = None
|
55 |
+
|
56 |
+
# List of libraries to build
|
57 |
+
self.libraries = None
|
58 |
+
|
59 |
+
# Compilation options for all libraries
|
60 |
+
self.include_dirs = None
|
61 |
+
self.define = None
|
62 |
+
self.undef = None
|
63 |
+
self.debug = None
|
64 |
+
self.force = 0
|
65 |
+
self.compiler = None
|
66 |
+
|
67 |
+
|
68 |
+
def finalize_options(self):
|
69 |
+
# This might be confusing: both build-clib and build-temp default
|
70 |
+
# to build-temp as defined by the "build" command. This is because
|
71 |
+
# I think that C libraries are really just temporary build
|
72 |
+
# by-products, at least from the point of view of building Python
|
73 |
+
# extensions -- but I want to keep my options open.
|
74 |
+
self.set_undefined_options('build',
|
75 |
+
('build_temp', 'build_clib'),
|
76 |
+
('build_temp', 'build_temp'),
|
77 |
+
('compiler', 'compiler'),
|
78 |
+
('debug', 'debug'),
|
79 |
+
('force', 'force'))
|
80 |
+
|
81 |
+
self.libraries = self.distribution.libraries
|
82 |
+
if self.libraries:
|
83 |
+
self.check_library_list(self.libraries)
|
84 |
+
|
85 |
+
if self.include_dirs is None:
|
86 |
+
self.include_dirs = self.distribution.include_dirs or []
|
87 |
+
if isinstance(self.include_dirs, str):
|
88 |
+
self.include_dirs = self.include_dirs.split(os.pathsep)
|
89 |
+
|
90 |
+
# XXX same as for build_ext -- what about 'self.define' and
|
91 |
+
# 'self.undef' ?
|
92 |
+
|
93 |
+
|
94 |
+
def run(self):
|
95 |
+
if not self.libraries:
|
96 |
+
return
|
97 |
+
|
98 |
+
# Yech -- this is cut 'n pasted from build_ext.py!
|
99 |
+
from distutils.ccompiler import new_compiler
|
100 |
+
self.compiler = new_compiler(compiler=self.compiler,
|
101 |
+
dry_run=self.dry_run,
|
102 |
+
force=self.force)
|
103 |
+
customize_compiler(self.compiler)
|
104 |
+
|
105 |
+
if self.include_dirs is not None:
|
106 |
+
self.compiler.set_include_dirs(self.include_dirs)
|
107 |
+
if self.define is not None:
|
108 |
+
# 'define' option is a list of (name,value) tuples
|
109 |
+
for (name,value) in self.define:
|
110 |
+
self.compiler.define_macro(name, value)
|
111 |
+
if self.undef is not None:
|
112 |
+
for macro in self.undef:
|
113 |
+
self.compiler.undefine_macro(macro)
|
114 |
+
|
115 |
+
self.build_libraries(self.libraries)
|
116 |
+
|
117 |
+
|
118 |
+
def check_library_list(self, libraries):
|
119 |
+
"""Ensure that the list of libraries is valid.
|
120 |
+
|
121 |
+
`library` is presumably provided as a command option 'libraries'.
|
122 |
+
This method checks that it is a list of 2-tuples, where the tuples
|
123 |
+
are (library_name, build_info_dict).
|
124 |
+
|
125 |
+
Raise DistutilsSetupError if the structure is invalid anywhere;
|
126 |
+
just returns otherwise.
|
127 |
+
"""
|
128 |
+
if not isinstance(libraries, list):
|
129 |
+
raise DistutilsSetupError(
|
130 |
+
"'libraries' option must be a list of tuples")
|
131 |
+
|
132 |
+
for lib in libraries:
|
133 |
+
if not isinstance(lib, tuple) and len(lib) != 2:
|
134 |
+
raise DistutilsSetupError(
|
135 |
+
"each element of 'libraries' must a 2-tuple")
|
136 |
+
|
137 |
+
name, build_info = lib
|
138 |
+
|
139 |
+
if not isinstance(name, str):
|
140 |
+
raise DistutilsSetupError(
|
141 |
+
"first element of each tuple in 'libraries' "
|
142 |
+
"must be a string (the library name)")
|
143 |
+
|
144 |
+
if '/' in name or (os.sep != '/' and os.sep in name):
|
145 |
+
raise DistutilsSetupError("bad library name '%s': "
|
146 |
+
"may not contain directory separators" % lib[0])
|
147 |
+
|
148 |
+
if not isinstance(build_info, dict):
|
149 |
+
raise DistutilsSetupError(
|
150 |
+
"second element of each tuple in 'libraries' "
|
151 |
+
"must be a dictionary (build info)")
|
152 |
+
|
153 |
+
|
154 |
+
def get_library_names(self):
|
155 |
+
# Assume the library list is valid -- 'check_library_list()' is
|
156 |
+
# called from 'finalize_options()', so it should be!
|
157 |
+
if not self.libraries:
|
158 |
+
return None
|
159 |
+
|
160 |
+
lib_names = []
|
161 |
+
for (lib_name, build_info) in self.libraries:
|
162 |
+
lib_names.append(lib_name)
|
163 |
+
return lib_names
|
164 |
+
|
165 |
+
|
166 |
+
def get_source_files(self):
|
167 |
+
self.check_library_list(self.libraries)
|
168 |
+
filenames = []
|
169 |
+
for (lib_name, build_info) in self.libraries:
|
170 |
+
sources = build_info.get('sources')
|
171 |
+
if sources is None or not isinstance(sources, (list, tuple)):
|
172 |
+
raise DistutilsSetupError(
|
173 |
+
"in 'libraries' option (library '%s'), "
|
174 |
+
"'sources' must be present and must be "
|
175 |
+
"a list of source filenames" % lib_name)
|
176 |
+
|
177 |
+
filenames.extend(sources)
|
178 |
+
return filenames
|
179 |
+
|
180 |
+
|
181 |
+
def build_libraries(self, libraries):
|
182 |
+
for (lib_name, build_info) in libraries:
|
183 |
+
sources = build_info.get('sources')
|
184 |
+
if sources is None or not isinstance(sources, (list, tuple)):
|
185 |
+
raise DistutilsSetupError(
|
186 |
+
"in 'libraries' option (library '%s'), "
|
187 |
+
"'sources' must be present and must be "
|
188 |
+
"a list of source filenames" % lib_name)
|
189 |
+
sources = list(sources)
|
190 |
+
|
191 |
+
log.info("building '%s' library", lib_name)
|
192 |
+
|
193 |
+
# First, compile the source code to object files in the library
|
194 |
+
# directory. (This should probably change to putting object
|
195 |
+
# files in a temporary build directory.)
|
196 |
+
macros = build_info.get('macros')
|
197 |
+
include_dirs = build_info.get('include_dirs')
|
198 |
+
objects = self.compiler.compile(sources,
|
199 |
+
output_dir=self.build_temp,
|
200 |
+
macros=macros,
|
201 |
+
include_dirs=include_dirs,
|
202 |
+
debug=self.debug)
|
203 |
+
|
204 |
+
# Now "link" the object files together into a static library.
|
205 |
+
# (On Unix at least, this isn't really linking -- it just
|
206 |
+
# builds an archive. Whatever.)
|
207 |
+
self.compiler.create_static_lib(objects, lib_name,
|
208 |
+
output_dir=self.build_clib,
|
209 |
+
debug=self.debug)
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py
ADDED
@@ -0,0 +1,755 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.build_ext
|
2 |
+
|
3 |
+
Implements the Distutils 'build_ext' command, for building extension
|
4 |
+
modules (currently limited to C extensions, should accommodate C++
|
5 |
+
extensions ASAP)."""
|
6 |
+
|
7 |
+
import contextlib
|
8 |
+
import os
|
9 |
+
import re
|
10 |
+
import sys
|
11 |
+
from distutils.core import Command
|
12 |
+
from distutils.errors import *
|
13 |
+
from distutils.sysconfig import customize_compiler, get_python_version
|
14 |
+
from distutils.sysconfig import get_config_h_filename
|
15 |
+
from distutils.dep_util import newer_group
|
16 |
+
from distutils.extension import Extension
|
17 |
+
from distutils.util import get_platform
|
18 |
+
from distutils import log
|
19 |
+
from . import py37compat
|
20 |
+
|
21 |
+
from site import USER_BASE
|
22 |
+
|
23 |
+
# An extension name is just a dot-separated list of Python NAMEs (ie.
|
24 |
+
# the same as a fully-qualified module name).
|
25 |
+
extension_name_re = re.compile \
|
26 |
+
(r'^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$')
|
27 |
+
|
28 |
+
|
29 |
+
def show_compilers ():
|
30 |
+
from distutils.ccompiler import show_compilers
|
31 |
+
show_compilers()
|
32 |
+
|
33 |
+
|
34 |
+
class build_ext(Command):
|
35 |
+
|
36 |
+
description = "build C/C++ extensions (compile/link to build directory)"
|
37 |
+
|
38 |
+
# XXX thoughts on how to deal with complex command-line options like
|
39 |
+
# these, i.e. how to make it so fancy_getopt can suck them off the
|
40 |
+
# command line and make it look like setup.py defined the appropriate
|
41 |
+
# lists of tuples of what-have-you.
|
42 |
+
# - each command needs a callback to process its command-line options
|
43 |
+
# - Command.__init__() needs access to its share of the whole
|
44 |
+
# command line (must ultimately come from
|
45 |
+
# Distribution.parse_command_line())
|
46 |
+
# - it then calls the current command class' option-parsing
|
47 |
+
# callback to deal with weird options like -D, which have to
|
48 |
+
# parse the option text and churn out some custom data
|
49 |
+
# structure
|
50 |
+
# - that data structure (in this case, a list of 2-tuples)
|
51 |
+
# will then be present in the command object by the time
|
52 |
+
# we get to finalize_options() (i.e. the constructor
|
53 |
+
# takes care of both command-line and client options
|
54 |
+
# in between initialize_options() and finalize_options())
|
55 |
+
|
56 |
+
sep_by = " (separated by '%s')" % os.pathsep
|
57 |
+
user_options = [
|
58 |
+
('build-lib=', 'b',
|
59 |
+
"directory for compiled extension modules"),
|
60 |
+
('build-temp=', 't',
|
61 |
+
"directory for temporary files (build by-products)"),
|
62 |
+
('plat-name=', 'p',
|
63 |
+
"platform name to cross-compile for, if supported "
|
64 |
+
"(default: %s)" % get_platform()),
|
65 |
+
('inplace', 'i',
|
66 |
+
"ignore build-lib and put compiled extensions into the source " +
|
67 |
+
"directory alongside your pure Python modules"),
|
68 |
+
('include-dirs=', 'I',
|
69 |
+
"list of directories to search for header files" + sep_by),
|
70 |
+
('define=', 'D',
|
71 |
+
"C preprocessor macros to define"),
|
72 |
+
('undef=', 'U',
|
73 |
+
"C preprocessor macros to undefine"),
|
74 |
+
('libraries=', 'l',
|
75 |
+
"external C libraries to link with"),
|
76 |
+
('library-dirs=', 'L',
|
77 |
+
"directories to search for external C libraries" + sep_by),
|
78 |
+
('rpath=', 'R',
|
79 |
+
"directories to search for shared C libraries at runtime"),
|
80 |
+
('link-objects=', 'O',
|
81 |
+
"extra explicit link objects to include in the link"),
|
82 |
+
('debug', 'g',
|
83 |
+
"compile/link with debugging information"),
|
84 |
+
('force', 'f',
|
85 |
+
"forcibly build everything (ignore file timestamps)"),
|
86 |
+
('compiler=', 'c',
|
87 |
+
"specify the compiler type"),
|
88 |
+
('parallel=', 'j',
|
89 |
+
"number of parallel build jobs"),
|
90 |
+
('swig-cpp', None,
|
91 |
+
"make SWIG create C++ files (default is C)"),
|
92 |
+
('swig-opts=', None,
|
93 |
+
"list of SWIG command line options"),
|
94 |
+
('swig=', None,
|
95 |
+
"path to the SWIG executable"),
|
96 |
+
('user', None,
|
97 |
+
"add user include, library and rpath")
|
98 |
+
]
|
99 |
+
|
100 |
+
boolean_options = ['inplace', 'debug', 'force', 'swig-cpp', 'user']
|
101 |
+
|
102 |
+
help_options = [
|
103 |
+
('help-compiler', None,
|
104 |
+
"list available compilers", show_compilers),
|
105 |
+
]
|
106 |
+
|
107 |
+
def initialize_options(self):
|
108 |
+
self.extensions = None
|
109 |
+
self.build_lib = None
|
110 |
+
self.plat_name = None
|
111 |
+
self.build_temp = None
|
112 |
+
self.inplace = 0
|
113 |
+
self.package = None
|
114 |
+
|
115 |
+
self.include_dirs = None
|
116 |
+
self.define = None
|
117 |
+
self.undef = None
|
118 |
+
self.libraries = None
|
119 |
+
self.library_dirs = None
|
120 |
+
self.rpath = None
|
121 |
+
self.link_objects = None
|
122 |
+
self.debug = None
|
123 |
+
self.force = None
|
124 |
+
self.compiler = None
|
125 |
+
self.swig = None
|
126 |
+
self.swig_cpp = None
|
127 |
+
self.swig_opts = None
|
128 |
+
self.user = None
|
129 |
+
self.parallel = None
|
130 |
+
|
131 |
+
def finalize_options(self):
|
132 |
+
from distutils import sysconfig
|
133 |
+
|
134 |
+
self.set_undefined_options('build',
|
135 |
+
('build_lib', 'build_lib'),
|
136 |
+
('build_temp', 'build_temp'),
|
137 |
+
('compiler', 'compiler'),
|
138 |
+
('debug', 'debug'),
|
139 |
+
('force', 'force'),
|
140 |
+
('parallel', 'parallel'),
|
141 |
+
('plat_name', 'plat_name'),
|
142 |
+
)
|
143 |
+
|
144 |
+
if self.package is None:
|
145 |
+
self.package = self.distribution.ext_package
|
146 |
+
|
147 |
+
self.extensions = self.distribution.ext_modules
|
148 |
+
|
149 |
+
# Make sure Python's include directories (for Python.h, pyconfig.h,
|
150 |
+
# etc.) are in the include search path.
|
151 |
+
py_include = sysconfig.get_python_inc()
|
152 |
+
plat_py_include = sysconfig.get_python_inc(plat_specific=1)
|
153 |
+
if self.include_dirs is None:
|
154 |
+
self.include_dirs = self.distribution.include_dirs or []
|
155 |
+
if isinstance(self.include_dirs, str):
|
156 |
+
self.include_dirs = self.include_dirs.split(os.pathsep)
|
157 |
+
|
158 |
+
# If in a virtualenv, add its include directory
|
159 |
+
# Issue 16116
|
160 |
+
if sys.exec_prefix != sys.base_exec_prefix:
|
161 |
+
self.include_dirs.append(os.path.join(sys.exec_prefix, 'include'))
|
162 |
+
|
163 |
+
# Put the Python "system" include dir at the end, so that
|
164 |
+
# any local include dirs take precedence.
|
165 |
+
self.include_dirs.extend(py_include.split(os.path.pathsep))
|
166 |
+
if plat_py_include != py_include:
|
167 |
+
self.include_dirs.extend(
|
168 |
+
plat_py_include.split(os.path.pathsep))
|
169 |
+
|
170 |
+
self.ensure_string_list('libraries')
|
171 |
+
self.ensure_string_list('link_objects')
|
172 |
+
|
173 |
+
# Life is easier if we're not forever checking for None, so
|
174 |
+
# simplify these options to empty lists if unset
|
175 |
+
if self.libraries is None:
|
176 |
+
self.libraries = []
|
177 |
+
if self.library_dirs is None:
|
178 |
+
self.library_dirs = []
|
179 |
+
elif isinstance(self.library_dirs, str):
|
180 |
+
self.library_dirs = self.library_dirs.split(os.pathsep)
|
181 |
+
|
182 |
+
if self.rpath is None:
|
183 |
+
self.rpath = []
|
184 |
+
elif isinstance(self.rpath, str):
|
185 |
+
self.rpath = self.rpath.split(os.pathsep)
|
186 |
+
|
187 |
+
# for extensions under windows use different directories
|
188 |
+
# for Release and Debug builds.
|
189 |
+
# also Python's library directory must be appended to library_dirs
|
190 |
+
if os.name == 'nt':
|
191 |
+
# the 'libs' directory is for binary installs - we assume that
|
192 |
+
# must be the *native* platform. But we don't really support
|
193 |
+
# cross-compiling via a binary install anyway, so we let it go.
|
194 |
+
self.library_dirs.append(os.path.join(sys.exec_prefix, 'libs'))
|
195 |
+
if sys.base_exec_prefix != sys.prefix: # Issue 16116
|
196 |
+
self.library_dirs.append(os.path.join(sys.base_exec_prefix, 'libs'))
|
197 |
+
if self.debug:
|
198 |
+
self.build_temp = os.path.join(self.build_temp, "Debug")
|
199 |
+
else:
|
200 |
+
self.build_temp = os.path.join(self.build_temp, "Release")
|
201 |
+
|
202 |
+
# Append the source distribution include and library directories,
|
203 |
+
# this allows distutils on windows to work in the source tree
|
204 |
+
self.include_dirs.append(os.path.dirname(get_config_h_filename()))
|
205 |
+
self.library_dirs.append(sys.base_exec_prefix)
|
206 |
+
|
207 |
+
# Use the .lib files for the correct architecture
|
208 |
+
if self.plat_name == 'win32':
|
209 |
+
suffix = 'win32'
|
210 |
+
else:
|
211 |
+
# win-amd64
|
212 |
+
suffix = self.plat_name[4:]
|
213 |
+
new_lib = os.path.join(sys.exec_prefix, 'PCbuild')
|
214 |
+
if suffix:
|
215 |
+
new_lib = os.path.join(new_lib, suffix)
|
216 |
+
self.library_dirs.append(new_lib)
|
217 |
+
|
218 |
+
# For extensions under Cygwin, Python's library directory must be
|
219 |
+
# appended to library_dirs
|
220 |
+
if sys.platform[:6] == 'cygwin':
|
221 |
+
if not sysconfig.python_build:
|
222 |
+
# building third party extensions
|
223 |
+
self.library_dirs.append(os.path.join(sys.prefix, "lib",
|
224 |
+
"python" + get_python_version(),
|
225 |
+
"config"))
|
226 |
+
else:
|
227 |
+
# building python standard extensions
|
228 |
+
self.library_dirs.append('.')
|
229 |
+
|
230 |
+
# For building extensions with a shared Python library,
|
231 |
+
# Python's library directory must be appended to library_dirs
|
232 |
+
# See Issues: #1600860, #4366
|
233 |
+
if (sysconfig.get_config_var('Py_ENABLE_SHARED')):
|
234 |
+
if not sysconfig.python_build:
|
235 |
+
# building third party extensions
|
236 |
+
self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
|
237 |
+
else:
|
238 |
+
# building python standard extensions
|
239 |
+
self.library_dirs.append('.')
|
240 |
+
|
241 |
+
# The argument parsing will result in self.define being a string, but
|
242 |
+
# it has to be a list of 2-tuples. All the preprocessor symbols
|
243 |
+
# specified by the 'define' option will be set to '1'. Multiple
|
244 |
+
# symbols can be separated with commas.
|
245 |
+
|
246 |
+
if self.define:
|
247 |
+
defines = self.define.split(',')
|
248 |
+
self.define = [(symbol, '1') for symbol in defines]
|
249 |
+
|
250 |
+
# The option for macros to undefine is also a string from the
|
251 |
+
# option parsing, but has to be a list. Multiple symbols can also
|
252 |
+
# be separated with commas here.
|
253 |
+
if self.undef:
|
254 |
+
self.undef = self.undef.split(',')
|
255 |
+
|
256 |
+
if self.swig_opts is None:
|
257 |
+
self.swig_opts = []
|
258 |
+
else:
|
259 |
+
self.swig_opts = self.swig_opts.split(' ')
|
260 |
+
|
261 |
+
# Finally add the user include and library directories if requested
|
262 |
+
if self.user:
|
263 |
+
user_include = os.path.join(USER_BASE, "include")
|
264 |
+
user_lib = os.path.join(USER_BASE, "lib")
|
265 |
+
if os.path.isdir(user_include):
|
266 |
+
self.include_dirs.append(user_include)
|
267 |
+
if os.path.isdir(user_lib):
|
268 |
+
self.library_dirs.append(user_lib)
|
269 |
+
self.rpath.append(user_lib)
|
270 |
+
|
271 |
+
if isinstance(self.parallel, str):
|
272 |
+
try:
|
273 |
+
self.parallel = int(self.parallel)
|
274 |
+
except ValueError:
|
275 |
+
raise DistutilsOptionError("parallel should be an integer")
|
276 |
+
|
277 |
+
def run(self):
|
278 |
+
from distutils.ccompiler import new_compiler
|
279 |
+
|
280 |
+
# 'self.extensions', as supplied by setup.py, is a list of
|
281 |
+
# Extension instances. See the documentation for Extension (in
|
282 |
+
# distutils.extension) for details.
|
283 |
+
#
|
284 |
+
# For backwards compatibility with Distutils 0.8.2 and earlier, we
|
285 |
+
# also allow the 'extensions' list to be a list of tuples:
|
286 |
+
# (ext_name, build_info)
|
287 |
+
# where build_info is a dictionary containing everything that
|
288 |
+
# Extension instances do except the name, with a few things being
|
289 |
+
# differently named. We convert these 2-tuples to Extension
|
290 |
+
# instances as needed.
|
291 |
+
|
292 |
+
if not self.extensions:
|
293 |
+
return
|
294 |
+
|
295 |
+
# If we were asked to build any C/C++ libraries, make sure that the
|
296 |
+
# directory where we put them is in the library search path for
|
297 |
+
# linking extensions.
|
298 |
+
if self.distribution.has_c_libraries():
|
299 |
+
build_clib = self.get_finalized_command('build_clib')
|
300 |
+
self.libraries.extend(build_clib.get_library_names() or [])
|
301 |
+
self.library_dirs.append(build_clib.build_clib)
|
302 |
+
|
303 |
+
# Setup the CCompiler object that we'll use to do all the
|
304 |
+
# compiling and linking
|
305 |
+
self.compiler = new_compiler(compiler=self.compiler,
|
306 |
+
verbose=self.verbose,
|
307 |
+
dry_run=self.dry_run,
|
308 |
+
force=self.force)
|
309 |
+
customize_compiler(self.compiler)
|
310 |
+
# If we are cross-compiling, init the compiler now (if we are not
|
311 |
+
# cross-compiling, init would not hurt, but people may rely on
|
312 |
+
# late initialization of compiler even if they shouldn't...)
|
313 |
+
if os.name == 'nt' and self.plat_name != get_platform():
|
314 |
+
self.compiler.initialize(self.plat_name)
|
315 |
+
|
316 |
+
# And make sure that any compile/link-related options (which might
|
317 |
+
# come from the command-line or from the setup script) are set in
|
318 |
+
# that CCompiler object -- that way, they automatically apply to
|
319 |
+
# all compiling and linking done here.
|
320 |
+
if self.include_dirs is not None:
|
321 |
+
self.compiler.set_include_dirs(self.include_dirs)
|
322 |
+
if self.define is not None:
|
323 |
+
# 'define' option is a list of (name,value) tuples
|
324 |
+
for (name, value) in self.define:
|
325 |
+
self.compiler.define_macro(name, value)
|
326 |
+
if self.undef is not None:
|
327 |
+
for macro in self.undef:
|
328 |
+
self.compiler.undefine_macro(macro)
|
329 |
+
if self.libraries is not None:
|
330 |
+
self.compiler.set_libraries(self.libraries)
|
331 |
+
if self.library_dirs is not None:
|
332 |
+
self.compiler.set_library_dirs(self.library_dirs)
|
333 |
+
if self.rpath is not None:
|
334 |
+
self.compiler.set_runtime_library_dirs(self.rpath)
|
335 |
+
if self.link_objects is not None:
|
336 |
+
self.compiler.set_link_objects(self.link_objects)
|
337 |
+
|
338 |
+
# Now actually compile and link everything.
|
339 |
+
self.build_extensions()
|
340 |
+
|
341 |
+
def check_extensions_list(self, extensions):
|
342 |
+
"""Ensure that the list of extensions (presumably provided as a
|
343 |
+
command option 'extensions') is valid, i.e. it is a list of
|
344 |
+
Extension objects. We also support the old-style list of 2-tuples,
|
345 |
+
where the tuples are (ext_name, build_info), which are converted to
|
346 |
+
Extension instances here.
|
347 |
+
|
348 |
+
Raise DistutilsSetupError if the structure is invalid anywhere;
|
349 |
+
just returns otherwise.
|
350 |
+
"""
|
351 |
+
if not isinstance(extensions, list):
|
352 |
+
raise DistutilsSetupError(
|
353 |
+
"'ext_modules' option must be a list of Extension instances")
|
354 |
+
|
355 |
+
for i, ext in enumerate(extensions):
|
356 |
+
if isinstance(ext, Extension):
|
357 |
+
continue # OK! (assume type-checking done
|
358 |
+
# by Extension constructor)
|
359 |
+
|
360 |
+
if not isinstance(ext, tuple) or len(ext) != 2:
|
361 |
+
raise DistutilsSetupError(
|
362 |
+
"each element of 'ext_modules' option must be an "
|
363 |
+
"Extension instance or 2-tuple")
|
364 |
+
|
365 |
+
ext_name, build_info = ext
|
366 |
+
|
367 |
+
log.warn("old-style (ext_name, build_info) tuple found in "
|
368 |
+
"ext_modules for extension '%s' "
|
369 |
+
"-- please convert to Extension instance", ext_name)
|
370 |
+
|
371 |
+
if not (isinstance(ext_name, str) and
|
372 |
+
extension_name_re.match(ext_name)):
|
373 |
+
raise DistutilsSetupError(
|
374 |
+
"first element of each tuple in 'ext_modules' "
|
375 |
+
"must be the extension name (a string)")
|
376 |
+
|
377 |
+
if not isinstance(build_info, dict):
|
378 |
+
raise DistutilsSetupError(
|
379 |
+
"second element of each tuple in 'ext_modules' "
|
380 |
+
"must be a dictionary (build info)")
|
381 |
+
|
382 |
+
# OK, the (ext_name, build_info) dict is type-safe: convert it
|
383 |
+
# to an Extension instance.
|
384 |
+
ext = Extension(ext_name, build_info['sources'])
|
385 |
+
|
386 |
+
# Easy stuff: one-to-one mapping from dict elements to
|
387 |
+
# instance attributes.
|
388 |
+
for key in ('include_dirs', 'library_dirs', 'libraries',
|
389 |
+
'extra_objects', 'extra_compile_args',
|
390 |
+
'extra_link_args'):
|
391 |
+
val = build_info.get(key)
|
392 |
+
if val is not None:
|
393 |
+
setattr(ext, key, val)
|
394 |
+
|
395 |
+
# Medium-easy stuff: same syntax/semantics, different names.
|
396 |
+
ext.runtime_library_dirs = build_info.get('rpath')
|
397 |
+
if 'def_file' in build_info:
|
398 |
+
log.warn("'def_file' element of build info dict "
|
399 |
+
"no longer supported")
|
400 |
+
|
401 |
+
# Non-trivial stuff: 'macros' split into 'define_macros'
|
402 |
+
# and 'undef_macros'.
|
403 |
+
macros = build_info.get('macros')
|
404 |
+
if macros:
|
405 |
+
ext.define_macros = []
|
406 |
+
ext.undef_macros = []
|
407 |
+
for macro in macros:
|
408 |
+
if not (isinstance(macro, tuple) and len(macro) in (1, 2)):
|
409 |
+
raise DistutilsSetupError(
|
410 |
+
"'macros' element of build info dict "
|
411 |
+
"must be 1- or 2-tuple")
|
412 |
+
if len(macro) == 1:
|
413 |
+
ext.undef_macros.append(macro[0])
|
414 |
+
elif len(macro) == 2:
|
415 |
+
ext.define_macros.append(macro)
|
416 |
+
|
417 |
+
extensions[i] = ext
|
418 |
+
|
419 |
+
def get_source_files(self):
|
420 |
+
self.check_extensions_list(self.extensions)
|
421 |
+
filenames = []
|
422 |
+
|
423 |
+
# Wouldn't it be neat if we knew the names of header files too...
|
424 |
+
for ext in self.extensions:
|
425 |
+
filenames.extend(ext.sources)
|
426 |
+
return filenames
|
427 |
+
|
428 |
+
def get_outputs(self):
|
429 |
+
# Sanity check the 'extensions' list -- can't assume this is being
|
430 |
+
# done in the same run as a 'build_extensions()' call (in fact, we
|
431 |
+
# can probably assume that it *isn't*!).
|
432 |
+
self.check_extensions_list(self.extensions)
|
433 |
+
|
434 |
+
# And build the list of output (built) filenames. Note that this
|
435 |
+
# ignores the 'inplace' flag, and assumes everything goes in the
|
436 |
+
# "build" tree.
|
437 |
+
outputs = []
|
438 |
+
for ext in self.extensions:
|
439 |
+
outputs.append(self.get_ext_fullpath(ext.name))
|
440 |
+
return outputs
|
441 |
+
|
442 |
+
def build_extensions(self):
|
443 |
+
# First, sanity-check the 'extensions' list
|
444 |
+
self.check_extensions_list(self.extensions)
|
445 |
+
if self.parallel:
|
446 |
+
self._build_extensions_parallel()
|
447 |
+
else:
|
448 |
+
self._build_extensions_serial()
|
449 |
+
|
450 |
+
def _build_extensions_parallel(self):
|
451 |
+
workers = self.parallel
|
452 |
+
if self.parallel is True:
|
453 |
+
workers = os.cpu_count() # may return None
|
454 |
+
try:
|
455 |
+
from concurrent.futures import ThreadPoolExecutor
|
456 |
+
except ImportError:
|
457 |
+
workers = None
|
458 |
+
|
459 |
+
if workers is None:
|
460 |
+
self._build_extensions_serial()
|
461 |
+
return
|
462 |
+
|
463 |
+
with ThreadPoolExecutor(max_workers=workers) as executor:
|
464 |
+
futures = [executor.submit(self.build_extension, ext)
|
465 |
+
for ext in self.extensions]
|
466 |
+
for ext, fut in zip(self.extensions, futures):
|
467 |
+
with self._filter_build_errors(ext):
|
468 |
+
fut.result()
|
469 |
+
|
470 |
+
def _build_extensions_serial(self):
|
471 |
+
for ext in self.extensions:
|
472 |
+
with self._filter_build_errors(ext):
|
473 |
+
self.build_extension(ext)
|
474 |
+
|
475 |
+
@contextlib.contextmanager
|
476 |
+
def _filter_build_errors(self, ext):
|
477 |
+
try:
|
478 |
+
yield
|
479 |
+
except (CCompilerError, DistutilsError, CompileError) as e:
|
480 |
+
if not ext.optional:
|
481 |
+
raise
|
482 |
+
self.warn('building extension "%s" failed: %s' %
|
483 |
+
(ext.name, e))
|
484 |
+
|
485 |
+
def build_extension(self, ext):
|
486 |
+
sources = ext.sources
|
487 |
+
if sources is None or not isinstance(sources, (list, tuple)):
|
488 |
+
raise DistutilsSetupError(
|
489 |
+
"in 'ext_modules' option (extension '%s'), "
|
490 |
+
"'sources' must be present and must be "
|
491 |
+
"a list of source filenames" % ext.name)
|
492 |
+
# sort to make the resulting .so file build reproducible
|
493 |
+
sources = sorted(sources)
|
494 |
+
|
495 |
+
ext_path = self.get_ext_fullpath(ext.name)
|
496 |
+
depends = sources + ext.depends
|
497 |
+
if not (self.force or newer_group(depends, ext_path, 'newer')):
|
498 |
+
log.debug("skipping '%s' extension (up-to-date)", ext.name)
|
499 |
+
return
|
500 |
+
else:
|
501 |
+
log.info("building '%s' extension", ext.name)
|
502 |
+
|
503 |
+
# First, scan the sources for SWIG definition files (.i), run
|
504 |
+
# SWIG on 'em to create .c files, and modify the sources list
|
505 |
+
# accordingly.
|
506 |
+
sources = self.swig_sources(sources, ext)
|
507 |
+
|
508 |
+
# Next, compile the source code to object files.
|
509 |
+
|
510 |
+
# XXX not honouring 'define_macros' or 'undef_macros' -- the
|
511 |
+
# CCompiler API needs to change to accommodate this, and I
|
512 |
+
# want to do one thing at a time!
|
513 |
+
|
514 |
+
# Two possible sources for extra compiler arguments:
|
515 |
+
# - 'extra_compile_args' in Extension object
|
516 |
+
# - CFLAGS environment variable (not particularly
|
517 |
+
# elegant, but people seem to expect it and I
|
518 |
+
# guess it's useful)
|
519 |
+
# The environment variable should take precedence, and
|
520 |
+
# any sensible compiler will give precedence to later
|
521 |
+
# command line args. Hence we combine them in order:
|
522 |
+
extra_args = ext.extra_compile_args or []
|
523 |
+
|
524 |
+
macros = ext.define_macros[:]
|
525 |
+
for undef in ext.undef_macros:
|
526 |
+
macros.append((undef,))
|
527 |
+
|
528 |
+
objects = self.compiler.compile(sources,
|
529 |
+
output_dir=self.build_temp,
|
530 |
+
macros=macros,
|
531 |
+
include_dirs=ext.include_dirs,
|
532 |
+
debug=self.debug,
|
533 |
+
extra_postargs=extra_args,
|
534 |
+
depends=ext.depends)
|
535 |
+
|
536 |
+
# XXX outdated variable, kept here in case third-part code
|
537 |
+
# needs it.
|
538 |
+
self._built_objects = objects[:]
|
539 |
+
|
540 |
+
# Now link the object files together into a "shared object" --
|
541 |
+
# of course, first we have to figure out all the other things
|
542 |
+
# that go into the mix.
|
543 |
+
if ext.extra_objects:
|
544 |
+
objects.extend(ext.extra_objects)
|
545 |
+
extra_args = ext.extra_link_args or []
|
546 |
+
|
547 |
+
# Detect target language, if not provided
|
548 |
+
language = ext.language or self.compiler.detect_language(sources)
|
549 |
+
|
550 |
+
self.compiler.link_shared_object(
|
551 |
+
objects, ext_path,
|
552 |
+
libraries=self.get_libraries(ext),
|
553 |
+
library_dirs=ext.library_dirs,
|
554 |
+
runtime_library_dirs=ext.runtime_library_dirs,
|
555 |
+
extra_postargs=extra_args,
|
556 |
+
export_symbols=self.get_export_symbols(ext),
|
557 |
+
debug=self.debug,
|
558 |
+
build_temp=self.build_temp,
|
559 |
+
target_lang=language)
|
560 |
+
|
561 |
+
def swig_sources(self, sources, extension):
|
562 |
+
"""Walk the list of source files in 'sources', looking for SWIG
|
563 |
+
interface (.i) files. Run SWIG on all that are found, and
|
564 |
+
return a modified 'sources' list with SWIG source files replaced
|
565 |
+
by the generated C (or C++) files.
|
566 |
+
"""
|
567 |
+
new_sources = []
|
568 |
+
swig_sources = []
|
569 |
+
swig_targets = {}
|
570 |
+
|
571 |
+
# XXX this drops generated C/C++ files into the source tree, which
|
572 |
+
# is fine for developers who want to distribute the generated
|
573 |
+
# source -- but there should be an option to put SWIG output in
|
574 |
+
# the temp dir.
|
575 |
+
|
576 |
+
if self.swig_cpp:
|
577 |
+
log.warn("--swig-cpp is deprecated - use --swig-opts=-c++")
|
578 |
+
|
579 |
+
if self.swig_cpp or ('-c++' in self.swig_opts) or \
|
580 |
+
('-c++' in extension.swig_opts):
|
581 |
+
target_ext = '.cpp'
|
582 |
+
else:
|
583 |
+
target_ext = '.c'
|
584 |
+
|
585 |
+
for source in sources:
|
586 |
+
(base, ext) = os.path.splitext(source)
|
587 |
+
if ext == ".i": # SWIG interface file
|
588 |
+
new_sources.append(base + '_wrap' + target_ext)
|
589 |
+
swig_sources.append(source)
|
590 |
+
swig_targets[source] = new_sources[-1]
|
591 |
+
else:
|
592 |
+
new_sources.append(source)
|
593 |
+
|
594 |
+
if not swig_sources:
|
595 |
+
return new_sources
|
596 |
+
|
597 |
+
swig = self.swig or self.find_swig()
|
598 |
+
swig_cmd = [swig, "-python"]
|
599 |
+
swig_cmd.extend(self.swig_opts)
|
600 |
+
if self.swig_cpp:
|
601 |
+
swig_cmd.append("-c++")
|
602 |
+
|
603 |
+
# Do not override commandline arguments
|
604 |
+
if not self.swig_opts:
|
605 |
+
for o in extension.swig_opts:
|
606 |
+
swig_cmd.append(o)
|
607 |
+
|
608 |
+
for source in swig_sources:
|
609 |
+
target = swig_targets[source]
|
610 |
+
log.info("swigging %s to %s", source, target)
|
611 |
+
self.spawn(swig_cmd + ["-o", target, source])
|
612 |
+
|
613 |
+
return new_sources
|
614 |
+
|
615 |
+
def find_swig(self):
|
616 |
+
"""Return the name of the SWIG executable. On Unix, this is
|
617 |
+
just "swig" -- it should be in the PATH. Tries a bit harder on
|
618 |
+
Windows.
|
619 |
+
"""
|
620 |
+
if os.name == "posix":
|
621 |
+
return "swig"
|
622 |
+
elif os.name == "nt":
|
623 |
+
# Look for SWIG in its standard installation directory on
|
624 |
+
# Windows (or so I presume!). If we find it there, great;
|
625 |
+
# if not, act like Unix and assume it's in the PATH.
|
626 |
+
for vers in ("1.3", "1.2", "1.1"):
|
627 |
+
fn = os.path.join("c:\\swig%s" % vers, "swig.exe")
|
628 |
+
if os.path.isfile(fn):
|
629 |
+
return fn
|
630 |
+
else:
|
631 |
+
return "swig.exe"
|
632 |
+
else:
|
633 |
+
raise DistutilsPlatformError(
|
634 |
+
"I don't know how to find (much less run) SWIG "
|
635 |
+
"on platform '%s'" % os.name)
|
636 |
+
|
637 |
+
# -- Name generators -----------------------------------------------
|
638 |
+
# (extension names, filenames, whatever)
|
639 |
+
def get_ext_fullpath(self, ext_name):
|
640 |
+
"""Returns the path of the filename for a given extension.
|
641 |
+
|
642 |
+
The file is located in `build_lib` or directly in the package
|
643 |
+
(inplace option).
|
644 |
+
"""
|
645 |
+
fullname = self.get_ext_fullname(ext_name)
|
646 |
+
modpath = fullname.split('.')
|
647 |
+
filename = self.get_ext_filename(modpath[-1])
|
648 |
+
|
649 |
+
if not self.inplace:
|
650 |
+
# no further work needed
|
651 |
+
# returning :
|
652 |
+
# build_dir/package/path/filename
|
653 |
+
filename = os.path.join(*modpath[:-1]+[filename])
|
654 |
+
return os.path.join(self.build_lib, filename)
|
655 |
+
|
656 |
+
# the inplace option requires to find the package directory
|
657 |
+
# using the build_py command for that
|
658 |
+
package = '.'.join(modpath[0:-1])
|
659 |
+
build_py = self.get_finalized_command('build_py')
|
660 |
+
package_dir = os.path.abspath(build_py.get_package_dir(package))
|
661 |
+
|
662 |
+
# returning
|
663 |
+
# package_dir/filename
|
664 |
+
return os.path.join(package_dir, filename)
|
665 |
+
|
666 |
+
def get_ext_fullname(self, ext_name):
|
667 |
+
"""Returns the fullname of a given extension name.
|
668 |
+
|
669 |
+
Adds the `package.` prefix"""
|
670 |
+
if self.package is None:
|
671 |
+
return ext_name
|
672 |
+
else:
|
673 |
+
return self.package + '.' + ext_name
|
674 |
+
|
675 |
+
def get_ext_filename(self, ext_name):
|
676 |
+
r"""Convert the name of an extension (eg. "foo.bar") into the name
|
677 |
+
of the file from which it will be loaded (eg. "foo/bar.so", or
|
678 |
+
"foo\bar.pyd").
|
679 |
+
"""
|
680 |
+
from distutils.sysconfig import get_config_var
|
681 |
+
ext_path = ext_name.split('.')
|
682 |
+
ext_suffix = get_config_var('EXT_SUFFIX')
|
683 |
+
return os.path.join(*ext_path) + ext_suffix
|
684 |
+
|
685 |
+
def get_export_symbols(self, ext):
|
686 |
+
"""Return the list of symbols that a shared extension has to
|
687 |
+
export. This either uses 'ext.export_symbols' or, if it's not
|
688 |
+
provided, "PyInit_" + module_name. Only relevant on Windows, where
|
689 |
+
the .pyd file (DLL) must export the module "PyInit_" function.
|
690 |
+
"""
|
691 |
+
name = ext.name.split('.')[-1]
|
692 |
+
try:
|
693 |
+
# Unicode module name support as defined in PEP-489
|
694 |
+
# https://www.python.org/dev/peps/pep-0489/#export-hook-name
|
695 |
+
name.encode('ascii')
|
696 |
+
except UnicodeEncodeError:
|
697 |
+
suffix = 'U_' + name.encode('punycode').replace(b'-', b'_').decode('ascii')
|
698 |
+
else:
|
699 |
+
suffix = "_" + name
|
700 |
+
|
701 |
+
initfunc_name = "PyInit" + suffix
|
702 |
+
if initfunc_name not in ext.export_symbols:
|
703 |
+
ext.export_symbols.append(initfunc_name)
|
704 |
+
return ext.export_symbols
|
705 |
+
|
706 |
+
def get_libraries(self, ext):
|
707 |
+
"""Return the list of libraries to link against when building a
|
708 |
+
shared extension. On most platforms, this is just 'ext.libraries';
|
709 |
+
on Windows, we add the Python library (eg. python20.dll).
|
710 |
+
"""
|
711 |
+
# The python library is always needed on Windows. For MSVC, this
|
712 |
+
# is redundant, since the library is mentioned in a pragma in
|
713 |
+
# pyconfig.h that MSVC groks. The other Windows compilers all seem
|
714 |
+
# to need it mentioned explicitly, though, so that's what we do.
|
715 |
+
# Append '_d' to the python import library on debug builds.
|
716 |
+
if sys.platform == "win32":
|
717 |
+
from distutils._msvccompiler import MSVCCompiler
|
718 |
+
if not isinstance(self.compiler, MSVCCompiler):
|
719 |
+
template = "python%d%d"
|
720 |
+
if self.debug:
|
721 |
+
template = template + '_d'
|
722 |
+
pythonlib = (template %
|
723 |
+
(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
|
724 |
+
# don't extend ext.libraries, it may be shared with other
|
725 |
+
# extensions, it is a reference to the original list
|
726 |
+
return ext.libraries + [pythonlib]
|
727 |
+
else:
|
728 |
+
# On Android only the main executable and LD_PRELOADs are considered
|
729 |
+
# to be RTLD_GLOBAL, all the dependencies of the main executable
|
730 |
+
# remain RTLD_LOCAL and so the shared libraries must be linked with
|
731 |
+
# libpython when python is built with a shared python library (issue
|
732 |
+
# bpo-21536).
|
733 |
+
# On Cygwin (and if required, other POSIX-like platforms based on
|
734 |
+
# Windows like MinGW) it is simply necessary that all symbols in
|
735 |
+
# shared libraries are resolved at link time.
|
736 |
+
from distutils.sysconfig import get_config_var
|
737 |
+
link_libpython = False
|
738 |
+
if get_config_var('Py_ENABLE_SHARED'):
|
739 |
+
# A native build on an Android device or on Cygwin
|
740 |
+
if hasattr(sys, 'getandroidapilevel'):
|
741 |
+
link_libpython = True
|
742 |
+
elif sys.platform == 'cygwin':
|
743 |
+
link_libpython = True
|
744 |
+
elif '_PYTHON_HOST_PLATFORM' in os.environ:
|
745 |
+
# We are cross-compiling for one of the relevant platforms
|
746 |
+
if get_config_var('ANDROID_API_LEVEL') != 0:
|
747 |
+
link_libpython = True
|
748 |
+
elif get_config_var('MACHDEP') == 'cygwin':
|
749 |
+
link_libpython = True
|
750 |
+
|
751 |
+
if link_libpython:
|
752 |
+
ldversion = get_config_var('LDVERSION')
|
753 |
+
return ext.libraries + ['python' + ldversion]
|
754 |
+
|
755 |
+
return ext.libraries + py37compat.pythonlib()
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/build_py.py
ADDED
@@ -0,0 +1,392 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.build_py
|
2 |
+
|
3 |
+
Implements the Distutils 'build_py' command."""
|
4 |
+
|
5 |
+
import os
|
6 |
+
import importlib.util
|
7 |
+
import sys
|
8 |
+
import glob
|
9 |
+
|
10 |
+
from distutils.core import Command
|
11 |
+
from distutils.errors import *
|
12 |
+
from distutils.util import convert_path
|
13 |
+
from distutils import log
|
14 |
+
|
15 |
+
class build_py (Command):
|
16 |
+
|
17 |
+
description = "\"build\" pure Python modules (copy to build directory)"
|
18 |
+
|
19 |
+
user_options = [
|
20 |
+
('build-lib=', 'd', "directory to \"build\" (copy) to"),
|
21 |
+
('compile', 'c', "compile .py to .pyc"),
|
22 |
+
('no-compile', None, "don't compile .py files [default]"),
|
23 |
+
('optimize=', 'O',
|
24 |
+
"also compile with optimization: -O1 for \"python -O\", "
|
25 |
+
"-O2 for \"python -OO\", and -O0 to disable [default: -O0]"),
|
26 |
+
('force', 'f', "forcibly build everything (ignore file timestamps)"),
|
27 |
+
]
|
28 |
+
|
29 |
+
boolean_options = ['compile', 'force']
|
30 |
+
negative_opt = {'no-compile' : 'compile'}
|
31 |
+
|
32 |
+
def initialize_options(self):
|
33 |
+
self.build_lib = None
|
34 |
+
self.py_modules = None
|
35 |
+
self.package = None
|
36 |
+
self.package_data = None
|
37 |
+
self.package_dir = None
|
38 |
+
self.compile = 0
|
39 |
+
self.optimize = 0
|
40 |
+
self.force = None
|
41 |
+
|
42 |
+
def finalize_options(self):
|
43 |
+
self.set_undefined_options('build',
|
44 |
+
('build_lib', 'build_lib'),
|
45 |
+
('force', 'force'))
|
46 |
+
|
47 |
+
# Get the distribution options that are aliases for build_py
|
48 |
+
# options -- list of packages and list of modules.
|
49 |
+
self.packages = self.distribution.packages
|
50 |
+
self.py_modules = self.distribution.py_modules
|
51 |
+
self.package_data = self.distribution.package_data
|
52 |
+
self.package_dir = {}
|
53 |
+
if self.distribution.package_dir:
|
54 |
+
for name, path in self.distribution.package_dir.items():
|
55 |
+
self.package_dir[name] = convert_path(path)
|
56 |
+
self.data_files = self.get_data_files()
|
57 |
+
|
58 |
+
# Ick, copied straight from install_lib.py (fancy_getopt needs a
|
59 |
+
# type system! Hell, *everything* needs a type system!!!)
|
60 |
+
if not isinstance(self.optimize, int):
|
61 |
+
try:
|
62 |
+
self.optimize = int(self.optimize)
|
63 |
+
assert 0 <= self.optimize <= 2
|
64 |
+
except (ValueError, AssertionError):
|
65 |
+
raise DistutilsOptionError("optimize must be 0, 1, or 2")
|
66 |
+
|
67 |
+
def run(self):
|
68 |
+
# XXX copy_file by default preserves atime and mtime. IMHO this is
|
69 |
+
# the right thing to do, but perhaps it should be an option -- in
|
70 |
+
# particular, a site administrator might want installed files to
|
71 |
+
# reflect the time of installation rather than the last
|
72 |
+
# modification time before the installed release.
|
73 |
+
|
74 |
+
# XXX copy_file by default preserves mode, which appears to be the
|
75 |
+
# wrong thing to do: if a file is read-only in the working
|
76 |
+
# directory, we want it to be installed read/write so that the next
|
77 |
+
# installation of the same module distribution can overwrite it
|
78 |
+
# without problems. (This might be a Unix-specific issue.) Thus
|
79 |
+
# we turn off 'preserve_mode' when copying to the build directory,
|
80 |
+
# since the build directory is supposed to be exactly what the
|
81 |
+
# installation will look like (ie. we preserve mode when
|
82 |
+
# installing).
|
83 |
+
|
84 |
+
# Two options control which modules will be installed: 'packages'
|
85 |
+
# and 'py_modules'. The former lets us work with whole packages, not
|
86 |
+
# specifying individual modules at all; the latter is for
|
87 |
+
# specifying modules one-at-a-time.
|
88 |
+
|
89 |
+
if self.py_modules:
|
90 |
+
self.build_modules()
|
91 |
+
if self.packages:
|
92 |
+
self.build_packages()
|
93 |
+
self.build_package_data()
|
94 |
+
|
95 |
+
self.byte_compile(self.get_outputs(include_bytecode=0))
|
96 |
+
|
97 |
+
def get_data_files(self):
|
98 |
+
"""Generate list of '(package,src_dir,build_dir,filenames)' tuples"""
|
99 |
+
data = []
|
100 |
+
if not self.packages:
|
101 |
+
return data
|
102 |
+
for package in self.packages:
|
103 |
+
# Locate package source directory
|
104 |
+
src_dir = self.get_package_dir(package)
|
105 |
+
|
106 |
+
# Compute package build directory
|
107 |
+
build_dir = os.path.join(*([self.build_lib] + package.split('.')))
|
108 |
+
|
109 |
+
# Length of path to strip from found files
|
110 |
+
plen = 0
|
111 |
+
if src_dir:
|
112 |
+
plen = len(src_dir)+1
|
113 |
+
|
114 |
+
# Strip directory from globbed filenames
|
115 |
+
filenames = [
|
116 |
+
file[plen:] for file in self.find_data_files(package, src_dir)
|
117 |
+
]
|
118 |
+
data.append((package, src_dir, build_dir, filenames))
|
119 |
+
return data
|
120 |
+
|
121 |
+
def find_data_files(self, package, src_dir):
|
122 |
+
"""Return filenames for package's data files in 'src_dir'"""
|
123 |
+
globs = (self.package_data.get('', [])
|
124 |
+
+ self.package_data.get(package, []))
|
125 |
+
files = []
|
126 |
+
for pattern in globs:
|
127 |
+
# Each pattern has to be converted to a platform-specific path
|
128 |
+
filelist = glob.glob(os.path.join(glob.escape(src_dir), convert_path(pattern)))
|
129 |
+
# Files that match more than one pattern are only added once
|
130 |
+
files.extend([fn for fn in filelist if fn not in files
|
131 |
+
and os.path.isfile(fn)])
|
132 |
+
return files
|
133 |
+
|
134 |
+
def build_package_data(self):
|
135 |
+
"""Copy data files into build directory"""
|
136 |
+
lastdir = None
|
137 |
+
for package, src_dir, build_dir, filenames in self.data_files:
|
138 |
+
for filename in filenames:
|
139 |
+
target = os.path.join(build_dir, filename)
|
140 |
+
self.mkpath(os.path.dirname(target))
|
141 |
+
self.copy_file(os.path.join(src_dir, filename), target,
|
142 |
+
preserve_mode=False)
|
143 |
+
|
144 |
+
def get_package_dir(self, package):
|
145 |
+
"""Return the directory, relative to the top of the source
|
146 |
+
distribution, where package 'package' should be found
|
147 |
+
(at least according to the 'package_dir' option, if any)."""
|
148 |
+
path = package.split('.')
|
149 |
+
|
150 |
+
if not self.package_dir:
|
151 |
+
if path:
|
152 |
+
return os.path.join(*path)
|
153 |
+
else:
|
154 |
+
return ''
|
155 |
+
else:
|
156 |
+
tail = []
|
157 |
+
while path:
|
158 |
+
try:
|
159 |
+
pdir = self.package_dir['.'.join(path)]
|
160 |
+
except KeyError:
|
161 |
+
tail.insert(0, path[-1])
|
162 |
+
del path[-1]
|
163 |
+
else:
|
164 |
+
tail.insert(0, pdir)
|
165 |
+
return os.path.join(*tail)
|
166 |
+
else:
|
167 |
+
# Oops, got all the way through 'path' without finding a
|
168 |
+
# match in package_dir. If package_dir defines a directory
|
169 |
+
# for the root (nameless) package, then fallback on it;
|
170 |
+
# otherwise, we might as well have not consulted
|
171 |
+
# package_dir at all, as we just use the directory implied
|
172 |
+
# by 'tail' (which should be the same as the original value
|
173 |
+
# of 'path' at this point).
|
174 |
+
pdir = self.package_dir.get('')
|
175 |
+
if pdir is not None:
|
176 |
+
tail.insert(0, pdir)
|
177 |
+
|
178 |
+
if tail:
|
179 |
+
return os.path.join(*tail)
|
180 |
+
else:
|
181 |
+
return ''
|
182 |
+
|
183 |
+
def check_package(self, package, package_dir):
|
184 |
+
# Empty dir name means current directory, which we can probably
|
185 |
+
# assume exists. Also, os.path.exists and isdir don't know about
|
186 |
+
# my "empty string means current dir" convention, so we have to
|
187 |
+
# circumvent them.
|
188 |
+
if package_dir != "":
|
189 |
+
if not os.path.exists(package_dir):
|
190 |
+
raise DistutilsFileError(
|
191 |
+
"package directory '%s' does not exist" % package_dir)
|
192 |
+
if not os.path.isdir(package_dir):
|
193 |
+
raise DistutilsFileError(
|
194 |
+
"supposed package directory '%s' exists, "
|
195 |
+
"but is not a directory" % package_dir)
|
196 |
+
|
197 |
+
# Require __init__.py for all but the "root package"
|
198 |
+
if package:
|
199 |
+
init_py = os.path.join(package_dir, "__init__.py")
|
200 |
+
if os.path.isfile(init_py):
|
201 |
+
return init_py
|
202 |
+
else:
|
203 |
+
log.warn(("package init file '%s' not found " +
|
204 |
+
"(or not a regular file)"), init_py)
|
205 |
+
|
206 |
+
# Either not in a package at all (__init__.py not expected), or
|
207 |
+
# __init__.py doesn't exist -- so don't return the filename.
|
208 |
+
return None
|
209 |
+
|
210 |
+
def check_module(self, module, module_file):
|
211 |
+
if not os.path.isfile(module_file):
|
212 |
+
log.warn("file %s (for module %s) not found", module_file, module)
|
213 |
+
return False
|
214 |
+
else:
|
215 |
+
return True
|
216 |
+
|
217 |
+
def find_package_modules(self, package, package_dir):
|
218 |
+
self.check_package(package, package_dir)
|
219 |
+
module_files = glob.glob(os.path.join(glob.escape(package_dir), "*.py"))
|
220 |
+
modules = []
|
221 |
+
setup_script = os.path.abspath(self.distribution.script_name)
|
222 |
+
|
223 |
+
for f in module_files:
|
224 |
+
abs_f = os.path.abspath(f)
|
225 |
+
if abs_f != setup_script:
|
226 |
+
module = os.path.splitext(os.path.basename(f))[0]
|
227 |
+
modules.append((package, module, f))
|
228 |
+
else:
|
229 |
+
self.debug_print("excluding %s" % setup_script)
|
230 |
+
return modules
|
231 |
+
|
232 |
+
def find_modules(self):
|
233 |
+
"""Finds individually-specified Python modules, ie. those listed by
|
234 |
+
module name in 'self.py_modules'. Returns a list of tuples (package,
|
235 |
+
module_base, filename): 'package' is a tuple of the path through
|
236 |
+
package-space to the module; 'module_base' is the bare (no
|
237 |
+
packages, no dots) module name, and 'filename' is the path to the
|
238 |
+
".py" file (relative to the distribution root) that implements the
|
239 |
+
module.
|
240 |
+
"""
|
241 |
+
# Map package names to tuples of useful info about the package:
|
242 |
+
# (package_dir, checked)
|
243 |
+
# package_dir - the directory where we'll find source files for
|
244 |
+
# this package
|
245 |
+
# checked - true if we have checked that the package directory
|
246 |
+
# is valid (exists, contains __init__.py, ... ?)
|
247 |
+
packages = {}
|
248 |
+
|
249 |
+
# List of (package, module, filename) tuples to return
|
250 |
+
modules = []
|
251 |
+
|
252 |
+
# We treat modules-in-packages almost the same as toplevel modules,
|
253 |
+
# just the "package" for a toplevel is empty (either an empty
|
254 |
+
# string or empty list, depending on context). Differences:
|
255 |
+
# - don't check for __init__.py in directory for empty package
|
256 |
+
for module in self.py_modules:
|
257 |
+
path = module.split('.')
|
258 |
+
package = '.'.join(path[0:-1])
|
259 |
+
module_base = path[-1]
|
260 |
+
|
261 |
+
try:
|
262 |
+
(package_dir, checked) = packages[package]
|
263 |
+
except KeyError:
|
264 |
+
package_dir = self.get_package_dir(package)
|
265 |
+
checked = 0
|
266 |
+
|
267 |
+
if not checked:
|
268 |
+
init_py = self.check_package(package, package_dir)
|
269 |
+
packages[package] = (package_dir, 1)
|
270 |
+
if init_py:
|
271 |
+
modules.append((package, "__init__", init_py))
|
272 |
+
|
273 |
+
# XXX perhaps we should also check for just .pyc files
|
274 |
+
# (so greedy closed-source bastards can distribute Python
|
275 |
+
# modules too)
|
276 |
+
module_file = os.path.join(package_dir, module_base + ".py")
|
277 |
+
if not self.check_module(module, module_file):
|
278 |
+
continue
|
279 |
+
|
280 |
+
modules.append((package, module_base, module_file))
|
281 |
+
|
282 |
+
return modules
|
283 |
+
|
284 |
+
def find_all_modules(self):
|
285 |
+
"""Compute the list of all modules that will be built, whether
|
286 |
+
they are specified one-module-at-a-time ('self.py_modules') or
|
287 |
+
by whole packages ('self.packages'). Return a list of tuples
|
288 |
+
(package, module, module_file), just like 'find_modules()' and
|
289 |
+
'find_package_modules()' do."""
|
290 |
+
modules = []
|
291 |
+
if self.py_modules:
|
292 |
+
modules.extend(self.find_modules())
|
293 |
+
if self.packages:
|
294 |
+
for package in self.packages:
|
295 |
+
package_dir = self.get_package_dir(package)
|
296 |
+
m = self.find_package_modules(package, package_dir)
|
297 |
+
modules.extend(m)
|
298 |
+
return modules
|
299 |
+
|
300 |
+
def get_source_files(self):
|
301 |
+
return [module[-1] for module in self.find_all_modules()]
|
302 |
+
|
303 |
+
def get_module_outfile(self, build_dir, package, module):
|
304 |
+
outfile_path = [build_dir] + list(package) + [module + ".py"]
|
305 |
+
return os.path.join(*outfile_path)
|
306 |
+
|
307 |
+
def get_outputs(self, include_bytecode=1):
|
308 |
+
modules = self.find_all_modules()
|
309 |
+
outputs = []
|
310 |
+
for (package, module, module_file) in modules:
|
311 |
+
package = package.split('.')
|
312 |
+
filename = self.get_module_outfile(self.build_lib, package, module)
|
313 |
+
outputs.append(filename)
|
314 |
+
if include_bytecode:
|
315 |
+
if self.compile:
|
316 |
+
outputs.append(importlib.util.cache_from_source(
|
317 |
+
filename, optimization=''))
|
318 |
+
if self.optimize > 0:
|
319 |
+
outputs.append(importlib.util.cache_from_source(
|
320 |
+
filename, optimization=self.optimize))
|
321 |
+
|
322 |
+
outputs += [
|
323 |
+
os.path.join(build_dir, filename)
|
324 |
+
for package, src_dir, build_dir, filenames in self.data_files
|
325 |
+
for filename in filenames
|
326 |
+
]
|
327 |
+
|
328 |
+
return outputs
|
329 |
+
|
330 |
+
def build_module(self, module, module_file, package):
|
331 |
+
if isinstance(package, str):
|
332 |
+
package = package.split('.')
|
333 |
+
elif not isinstance(package, (list, tuple)):
|
334 |
+
raise TypeError(
|
335 |
+
"'package' must be a string (dot-separated), list, or tuple")
|
336 |
+
|
337 |
+
# Now put the module source file into the "build" area -- this is
|
338 |
+
# easy, we just copy it somewhere under self.build_lib (the build
|
339 |
+
# directory for Python source).
|
340 |
+
outfile = self.get_module_outfile(self.build_lib, package, module)
|
341 |
+
dir = os.path.dirname(outfile)
|
342 |
+
self.mkpath(dir)
|
343 |
+
return self.copy_file(module_file, outfile, preserve_mode=0)
|
344 |
+
|
345 |
+
def build_modules(self):
|
346 |
+
modules = self.find_modules()
|
347 |
+
for (package, module, module_file) in modules:
|
348 |
+
# Now "build" the module -- ie. copy the source file to
|
349 |
+
# self.build_lib (the build directory for Python source).
|
350 |
+
# (Actually, it gets copied to the directory for this package
|
351 |
+
# under self.build_lib.)
|
352 |
+
self.build_module(module, module_file, package)
|
353 |
+
|
354 |
+
def build_packages(self):
|
355 |
+
for package in self.packages:
|
356 |
+
# Get list of (package, module, module_file) tuples based on
|
357 |
+
# scanning the package directory. 'package' is only included
|
358 |
+
# in the tuple so that 'find_modules()' and
|
359 |
+
# 'find_package_tuples()' have a consistent interface; it's
|
360 |
+
# ignored here (apart from a sanity check). Also, 'module' is
|
361 |
+
# the *unqualified* module name (ie. no dots, no package -- we
|
362 |
+
# already know its package!), and 'module_file' is the path to
|
363 |
+
# the .py file, relative to the current directory
|
364 |
+
# (ie. including 'package_dir').
|
365 |
+
package_dir = self.get_package_dir(package)
|
366 |
+
modules = self.find_package_modules(package, package_dir)
|
367 |
+
|
368 |
+
# Now loop over the modules we found, "building" each one (just
|
369 |
+
# copy it to self.build_lib).
|
370 |
+
for (package_, module, module_file) in modules:
|
371 |
+
assert package == package_
|
372 |
+
self.build_module(module, module_file, package)
|
373 |
+
|
374 |
+
def byte_compile(self, files):
|
375 |
+
if sys.dont_write_bytecode:
|
376 |
+
self.warn('byte-compiling is disabled, skipping.')
|
377 |
+
return
|
378 |
+
|
379 |
+
from distutils.util import byte_compile
|
380 |
+
prefix = self.build_lib
|
381 |
+
if prefix[-1] != os.sep:
|
382 |
+
prefix = prefix + os.sep
|
383 |
+
|
384 |
+
# XXX this code is essentially the same as the 'byte_compile()
|
385 |
+
# method of the "install_lib" command, except for the determination
|
386 |
+
# of the 'prefix' string. Hmmm.
|
387 |
+
if self.compile:
|
388 |
+
byte_compile(files, optimize=0,
|
389 |
+
force=self.force, prefix=prefix, dry_run=self.dry_run)
|
390 |
+
if self.optimize > 0:
|
391 |
+
byte_compile(files, optimize=self.optimize,
|
392 |
+
force=self.force, prefix=prefix, dry_run=self.dry_run)
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/build_scripts.py
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.build_scripts
|
2 |
+
|
3 |
+
Implements the Distutils 'build_scripts' command."""
|
4 |
+
|
5 |
+
import os, re
|
6 |
+
from stat import ST_MODE
|
7 |
+
from distutils import sysconfig
|
8 |
+
from distutils.core import Command
|
9 |
+
from distutils.dep_util import newer
|
10 |
+
from distutils.util import convert_path
|
11 |
+
from distutils import log
|
12 |
+
import tokenize
|
13 |
+
|
14 |
+
# check if Python is called on the first line with this expression
|
15 |
+
first_line_re = re.compile(b'^#!.*python[0-9.]*([ \t].*)?$')
|
16 |
+
|
17 |
+
class build_scripts(Command):
|
18 |
+
|
19 |
+
description = "\"build\" scripts (copy and fixup #! line)"
|
20 |
+
|
21 |
+
user_options = [
|
22 |
+
('build-dir=', 'd', "directory to \"build\" (copy) to"),
|
23 |
+
('force', 'f', "forcibly build everything (ignore file timestamps"),
|
24 |
+
('executable=', 'e', "specify final destination interpreter path"),
|
25 |
+
]
|
26 |
+
|
27 |
+
boolean_options = ['force']
|
28 |
+
|
29 |
+
|
30 |
+
def initialize_options(self):
|
31 |
+
self.build_dir = None
|
32 |
+
self.scripts = None
|
33 |
+
self.force = None
|
34 |
+
self.executable = None
|
35 |
+
self.outfiles = None
|
36 |
+
|
37 |
+
def finalize_options(self):
|
38 |
+
self.set_undefined_options('build',
|
39 |
+
('build_scripts', 'build_dir'),
|
40 |
+
('force', 'force'),
|
41 |
+
('executable', 'executable'))
|
42 |
+
self.scripts = self.distribution.scripts
|
43 |
+
|
44 |
+
def get_source_files(self):
|
45 |
+
return self.scripts
|
46 |
+
|
47 |
+
def run(self):
|
48 |
+
if not self.scripts:
|
49 |
+
return
|
50 |
+
self.copy_scripts()
|
51 |
+
|
52 |
+
|
53 |
+
def copy_scripts(self):
|
54 |
+
r"""Copy each script listed in 'self.scripts'; if it's marked as a
|
55 |
+
Python script in the Unix way (first line matches 'first_line_re',
|
56 |
+
ie. starts with "\#!" and contains "python"), then adjust the first
|
57 |
+
line to refer to the current Python interpreter as we copy.
|
58 |
+
"""
|
59 |
+
self.mkpath(self.build_dir)
|
60 |
+
outfiles = []
|
61 |
+
updated_files = []
|
62 |
+
for script in self.scripts:
|
63 |
+
adjust = False
|
64 |
+
script = convert_path(script)
|
65 |
+
outfile = os.path.join(self.build_dir, os.path.basename(script))
|
66 |
+
outfiles.append(outfile)
|
67 |
+
|
68 |
+
if not self.force and not newer(script, outfile):
|
69 |
+
log.debug("not copying %s (up-to-date)", script)
|
70 |
+
continue
|
71 |
+
|
72 |
+
# Always open the file, but ignore failures in dry-run mode --
|
73 |
+
# that way, we'll get accurate feedback if we can read the
|
74 |
+
# script.
|
75 |
+
try:
|
76 |
+
f = open(script, "rb")
|
77 |
+
except OSError:
|
78 |
+
if not self.dry_run:
|
79 |
+
raise
|
80 |
+
f = None
|
81 |
+
else:
|
82 |
+
encoding, lines = tokenize.detect_encoding(f.readline)
|
83 |
+
f.seek(0)
|
84 |
+
first_line = f.readline()
|
85 |
+
if not first_line:
|
86 |
+
self.warn("%s is an empty file (skipping)" % script)
|
87 |
+
continue
|
88 |
+
|
89 |
+
match = first_line_re.match(first_line)
|
90 |
+
if match:
|
91 |
+
adjust = True
|
92 |
+
post_interp = match.group(1) or b''
|
93 |
+
|
94 |
+
if adjust:
|
95 |
+
log.info("copying and adjusting %s -> %s", script,
|
96 |
+
self.build_dir)
|
97 |
+
updated_files.append(outfile)
|
98 |
+
if not self.dry_run:
|
99 |
+
if not sysconfig.python_build:
|
100 |
+
executable = self.executable
|
101 |
+
else:
|
102 |
+
executable = os.path.join(
|
103 |
+
sysconfig.get_config_var("BINDIR"),
|
104 |
+
"python%s%s" % (sysconfig.get_config_var("VERSION"),
|
105 |
+
sysconfig.get_config_var("EXE")))
|
106 |
+
executable = os.fsencode(executable)
|
107 |
+
shebang = b"#!" + executable + post_interp + b"\n"
|
108 |
+
# Python parser starts to read a script using UTF-8 until
|
109 |
+
# it gets a #coding:xxx cookie. The shebang has to be the
|
110 |
+
# first line of a file, the #coding:xxx cookie cannot be
|
111 |
+
# written before. So the shebang has to be decodable from
|
112 |
+
# UTF-8.
|
113 |
+
try:
|
114 |
+
shebang.decode('utf-8')
|
115 |
+
except UnicodeDecodeError:
|
116 |
+
raise ValueError(
|
117 |
+
"The shebang ({!r}) is not decodable "
|
118 |
+
"from utf-8".format(shebang))
|
119 |
+
# If the script is encoded to a custom encoding (use a
|
120 |
+
# #coding:xxx cookie), the shebang has to be decodable from
|
121 |
+
# the script encoding too.
|
122 |
+
try:
|
123 |
+
shebang.decode(encoding)
|
124 |
+
except UnicodeDecodeError:
|
125 |
+
raise ValueError(
|
126 |
+
"The shebang ({!r}) is not decodable "
|
127 |
+
"from the script encoding ({})"
|
128 |
+
.format(shebang, encoding))
|
129 |
+
with open(outfile, "wb") as outf:
|
130 |
+
outf.write(shebang)
|
131 |
+
outf.writelines(f.readlines())
|
132 |
+
if f:
|
133 |
+
f.close()
|
134 |
+
else:
|
135 |
+
if f:
|
136 |
+
f.close()
|
137 |
+
updated_files.append(outfile)
|
138 |
+
self.copy_file(script, outfile)
|
139 |
+
|
140 |
+
if os.name == 'posix':
|
141 |
+
for file in outfiles:
|
142 |
+
if self.dry_run:
|
143 |
+
log.info("changing mode of %s", file)
|
144 |
+
else:
|
145 |
+
oldmode = os.stat(file)[ST_MODE] & 0o7777
|
146 |
+
newmode = (oldmode | 0o555) & 0o7777
|
147 |
+
if newmode != oldmode:
|
148 |
+
log.info("changing mode of %s from %o to %o",
|
149 |
+
file, oldmode, newmode)
|
150 |
+
os.chmod(file, newmode)
|
151 |
+
# XXX should we modify self.outfiles?
|
152 |
+
return outfiles, updated_files
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/check.py
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.check
|
2 |
+
|
3 |
+
Implements the Distutils 'check' command.
|
4 |
+
"""
|
5 |
+
from distutils.core import Command
|
6 |
+
from distutils.errors import DistutilsSetupError
|
7 |
+
|
8 |
+
try:
|
9 |
+
# docutils is installed
|
10 |
+
from docutils.utils import Reporter
|
11 |
+
from docutils.parsers.rst import Parser
|
12 |
+
from docutils import frontend
|
13 |
+
from docutils import nodes
|
14 |
+
|
15 |
+
class SilentReporter(Reporter):
|
16 |
+
|
17 |
+
def __init__(self, source, report_level, halt_level, stream=None,
|
18 |
+
debug=0, encoding='ascii', error_handler='replace'):
|
19 |
+
self.messages = []
|
20 |
+
Reporter.__init__(self, source, report_level, halt_level, stream,
|
21 |
+
debug, encoding, error_handler)
|
22 |
+
|
23 |
+
def system_message(self, level, message, *children, **kwargs):
|
24 |
+
self.messages.append((level, message, children, kwargs))
|
25 |
+
return nodes.system_message(message, level=level,
|
26 |
+
type=self.levels[level],
|
27 |
+
*children, **kwargs)
|
28 |
+
|
29 |
+
HAS_DOCUTILS = True
|
30 |
+
except Exception:
|
31 |
+
# Catch all exceptions because exceptions besides ImportError probably
|
32 |
+
# indicate that docutils is not ported to Py3k.
|
33 |
+
HAS_DOCUTILS = False
|
34 |
+
|
35 |
+
class check(Command):
|
36 |
+
"""This command checks the meta-data of the package.
|
37 |
+
"""
|
38 |
+
description = ("perform some checks on the package")
|
39 |
+
user_options = [('metadata', 'm', 'Verify meta-data'),
|
40 |
+
('restructuredtext', 'r',
|
41 |
+
('Checks if long string meta-data syntax '
|
42 |
+
'are reStructuredText-compliant')),
|
43 |
+
('strict', 's',
|
44 |
+
'Will exit with an error if a check fails')]
|
45 |
+
|
46 |
+
boolean_options = ['metadata', 'restructuredtext', 'strict']
|
47 |
+
|
48 |
+
def initialize_options(self):
|
49 |
+
"""Sets default values for options."""
|
50 |
+
self.restructuredtext = 0
|
51 |
+
self.metadata = 1
|
52 |
+
self.strict = 0
|
53 |
+
self._warnings = 0
|
54 |
+
|
55 |
+
def finalize_options(self):
|
56 |
+
pass
|
57 |
+
|
58 |
+
def warn(self, msg):
|
59 |
+
"""Counts the number of warnings that occurs."""
|
60 |
+
self._warnings += 1
|
61 |
+
return Command.warn(self, msg)
|
62 |
+
|
63 |
+
def run(self):
|
64 |
+
"""Runs the command."""
|
65 |
+
# perform the various tests
|
66 |
+
if self.metadata:
|
67 |
+
self.check_metadata()
|
68 |
+
if self.restructuredtext:
|
69 |
+
if HAS_DOCUTILS:
|
70 |
+
self.check_restructuredtext()
|
71 |
+
elif self.strict:
|
72 |
+
raise DistutilsSetupError('The docutils package is needed.')
|
73 |
+
|
74 |
+
# let's raise an error in strict mode, if we have at least
|
75 |
+
# one warning
|
76 |
+
if self.strict and self._warnings > 0:
|
77 |
+
raise DistutilsSetupError('Please correct your package.')
|
78 |
+
|
79 |
+
def check_metadata(self):
|
80 |
+
"""Ensures that all required elements of meta-data are supplied.
|
81 |
+
|
82 |
+
Required fields:
|
83 |
+
name, version, URL
|
84 |
+
|
85 |
+
Recommended fields:
|
86 |
+
(author and author_email) or (maintainer and maintainer_email))
|
87 |
+
|
88 |
+
Warns if any are missing.
|
89 |
+
"""
|
90 |
+
metadata = self.distribution.metadata
|
91 |
+
|
92 |
+
missing = []
|
93 |
+
for attr in ('name', 'version', 'url'):
|
94 |
+
if not (hasattr(metadata, attr) and getattr(metadata, attr)):
|
95 |
+
missing.append(attr)
|
96 |
+
|
97 |
+
if missing:
|
98 |
+
self.warn("missing required meta-data: %s" % ', '.join(missing))
|
99 |
+
if metadata.author:
|
100 |
+
if not metadata.author_email:
|
101 |
+
self.warn("missing meta-data: if 'author' supplied, " +
|
102 |
+
"'author_email' should be supplied too")
|
103 |
+
elif metadata.maintainer:
|
104 |
+
if not metadata.maintainer_email:
|
105 |
+
self.warn("missing meta-data: if 'maintainer' supplied, " +
|
106 |
+
"'maintainer_email' should be supplied too")
|
107 |
+
else:
|
108 |
+
self.warn("missing meta-data: either (author and author_email) " +
|
109 |
+
"or (maintainer and maintainer_email) " +
|
110 |
+
"should be supplied")
|
111 |
+
|
112 |
+
def check_restructuredtext(self):
|
113 |
+
"""Checks if the long string fields are reST-compliant."""
|
114 |
+
data = self.distribution.get_long_description()
|
115 |
+
for warning in self._check_rst_data(data):
|
116 |
+
line = warning[-1].get('line')
|
117 |
+
if line is None:
|
118 |
+
warning = warning[1]
|
119 |
+
else:
|
120 |
+
warning = '%s (line %s)' % (warning[1], line)
|
121 |
+
self.warn(warning)
|
122 |
+
|
123 |
+
def _check_rst_data(self, data):
|
124 |
+
"""Returns warnings when the provided data doesn't compile."""
|
125 |
+
# the include and csv_table directives need this to be a path
|
126 |
+
source_path = self.distribution.script_name or 'setup.py'
|
127 |
+
parser = Parser()
|
128 |
+
settings = frontend.OptionParser(components=(Parser,)).get_default_values()
|
129 |
+
settings.tab_width = 4
|
130 |
+
settings.pep_references = None
|
131 |
+
settings.rfc_references = None
|
132 |
+
reporter = SilentReporter(source_path,
|
133 |
+
settings.report_level,
|
134 |
+
settings.halt_level,
|
135 |
+
stream=settings.warning_stream,
|
136 |
+
debug=settings.debug,
|
137 |
+
encoding=settings.error_encoding,
|
138 |
+
error_handler=settings.error_encoding_error_handler)
|
139 |
+
|
140 |
+
document = nodes.document(settings, reporter, source=source_path)
|
141 |
+
document.note_source(source_path, -1)
|
142 |
+
try:
|
143 |
+
parser.parse(data, document)
|
144 |
+
except AttributeError as e:
|
145 |
+
reporter.messages.append(
|
146 |
+
(-1, 'Could not finish the parsing: %s.' % e, '', {}))
|
147 |
+
|
148 |
+
return reporter.messages
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/clean.py
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.clean
|
2 |
+
|
3 |
+
Implements the Distutils 'clean' command."""
|
4 |
+
|
5 |
+
# contributed by Bastian Kleineidam <[email protected]>, added 2000-03-18
|
6 |
+
|
7 |
+
import os
|
8 |
+
from distutils.core import Command
|
9 |
+
from distutils.dir_util import remove_tree
|
10 |
+
from distutils import log
|
11 |
+
|
12 |
+
class clean(Command):
|
13 |
+
|
14 |
+
description = "clean up temporary files from 'build' command"
|
15 |
+
user_options = [
|
16 |
+
('build-base=', 'b',
|
17 |
+
"base build directory (default: 'build.build-base')"),
|
18 |
+
('build-lib=', None,
|
19 |
+
"build directory for all modules (default: 'build.build-lib')"),
|
20 |
+
('build-temp=', 't',
|
21 |
+
"temporary build directory (default: 'build.build-temp')"),
|
22 |
+
('build-scripts=', None,
|
23 |
+
"build directory for scripts (default: 'build.build-scripts')"),
|
24 |
+
('bdist-base=', None,
|
25 |
+
"temporary directory for built distributions"),
|
26 |
+
('all', 'a',
|
27 |
+
"remove all build output, not just temporary by-products")
|
28 |
+
]
|
29 |
+
|
30 |
+
boolean_options = ['all']
|
31 |
+
|
32 |
+
def initialize_options(self):
|
33 |
+
self.build_base = None
|
34 |
+
self.build_lib = None
|
35 |
+
self.build_temp = None
|
36 |
+
self.build_scripts = None
|
37 |
+
self.bdist_base = None
|
38 |
+
self.all = None
|
39 |
+
|
40 |
+
def finalize_options(self):
|
41 |
+
self.set_undefined_options('build',
|
42 |
+
('build_base', 'build_base'),
|
43 |
+
('build_lib', 'build_lib'),
|
44 |
+
('build_scripts', 'build_scripts'),
|
45 |
+
('build_temp', 'build_temp'))
|
46 |
+
self.set_undefined_options('bdist',
|
47 |
+
('bdist_base', 'bdist_base'))
|
48 |
+
|
49 |
+
def run(self):
|
50 |
+
# remove the build/temp.<plat> directory (unless it's already
|
51 |
+
# gone)
|
52 |
+
if os.path.exists(self.build_temp):
|
53 |
+
remove_tree(self.build_temp, dry_run=self.dry_run)
|
54 |
+
else:
|
55 |
+
log.debug("'%s' does not exist -- can't clean it",
|
56 |
+
self.build_temp)
|
57 |
+
|
58 |
+
if self.all:
|
59 |
+
# remove build directories
|
60 |
+
for directory in (self.build_lib,
|
61 |
+
self.bdist_base,
|
62 |
+
self.build_scripts):
|
63 |
+
if os.path.exists(directory):
|
64 |
+
remove_tree(directory, dry_run=self.dry_run)
|
65 |
+
else:
|
66 |
+
log.warn("'%s' does not exist -- can't clean it",
|
67 |
+
directory)
|
68 |
+
|
69 |
+
# just for the heck of it, try to remove the base build directory:
|
70 |
+
# we might have emptied it right now, but if not we don't care
|
71 |
+
if not self.dry_run:
|
72 |
+
try:
|
73 |
+
os.rmdir(self.build_base)
|
74 |
+
log.info("removing '%s'", self.build_base)
|
75 |
+
except OSError:
|
76 |
+
pass
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/config.py
ADDED
@@ -0,0 +1,344 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.config
|
2 |
+
|
3 |
+
Implements the Distutils 'config' command, a (mostly) empty command class
|
4 |
+
that exists mainly to be sub-classed by specific module distributions and
|
5 |
+
applications. The idea is that while every "config" command is different,
|
6 |
+
at least they're all named the same, and users always see "config" in the
|
7 |
+
list of standard commands. Also, this is a good place to put common
|
8 |
+
configure-like tasks: "try to compile this C code", or "figure out where
|
9 |
+
this header file lives".
|
10 |
+
"""
|
11 |
+
|
12 |
+
import os, re
|
13 |
+
|
14 |
+
from distutils.core import Command
|
15 |
+
from distutils.errors import DistutilsExecError
|
16 |
+
from distutils.sysconfig import customize_compiler
|
17 |
+
from distutils import log
|
18 |
+
|
19 |
+
LANG_EXT = {"c": ".c", "c++": ".cxx"}
|
20 |
+
|
21 |
+
class config(Command):
|
22 |
+
|
23 |
+
description = "prepare to build"
|
24 |
+
|
25 |
+
user_options = [
|
26 |
+
('compiler=', None,
|
27 |
+
"specify the compiler type"),
|
28 |
+
('cc=', None,
|
29 |
+
"specify the compiler executable"),
|
30 |
+
('include-dirs=', 'I',
|
31 |
+
"list of directories to search for header files"),
|
32 |
+
('define=', 'D',
|
33 |
+
"C preprocessor macros to define"),
|
34 |
+
('undef=', 'U',
|
35 |
+
"C preprocessor macros to undefine"),
|
36 |
+
('libraries=', 'l',
|
37 |
+
"external C libraries to link with"),
|
38 |
+
('library-dirs=', 'L',
|
39 |
+
"directories to search for external C libraries"),
|
40 |
+
|
41 |
+
('noisy', None,
|
42 |
+
"show every action (compile, link, run, ...) taken"),
|
43 |
+
('dump-source', None,
|
44 |
+
"dump generated source files before attempting to compile them"),
|
45 |
+
]
|
46 |
+
|
47 |
+
|
48 |
+
# The three standard command methods: since the "config" command
|
49 |
+
# does nothing by default, these are empty.
|
50 |
+
|
51 |
+
def initialize_options(self):
|
52 |
+
self.compiler = None
|
53 |
+
self.cc = None
|
54 |
+
self.include_dirs = None
|
55 |
+
self.libraries = None
|
56 |
+
self.library_dirs = None
|
57 |
+
|
58 |
+
# maximal output for now
|
59 |
+
self.noisy = 1
|
60 |
+
self.dump_source = 1
|
61 |
+
|
62 |
+
# list of temporary files generated along-the-way that we have
|
63 |
+
# to clean at some point
|
64 |
+
self.temp_files = []
|
65 |
+
|
66 |
+
def finalize_options(self):
|
67 |
+
if self.include_dirs is None:
|
68 |
+
self.include_dirs = self.distribution.include_dirs or []
|
69 |
+
elif isinstance(self.include_dirs, str):
|
70 |
+
self.include_dirs = self.include_dirs.split(os.pathsep)
|
71 |
+
|
72 |
+
if self.libraries is None:
|
73 |
+
self.libraries = []
|
74 |
+
elif isinstance(self.libraries, str):
|
75 |
+
self.libraries = [self.libraries]
|
76 |
+
|
77 |
+
if self.library_dirs is None:
|
78 |
+
self.library_dirs = []
|
79 |
+
elif isinstance(self.library_dirs, str):
|
80 |
+
self.library_dirs = self.library_dirs.split(os.pathsep)
|
81 |
+
|
82 |
+
def run(self):
|
83 |
+
pass
|
84 |
+
|
85 |
+
# Utility methods for actual "config" commands. The interfaces are
|
86 |
+
# loosely based on Autoconf macros of similar names. Sub-classes
|
87 |
+
# may use these freely.
|
88 |
+
|
89 |
+
def _check_compiler(self):
|
90 |
+
"""Check that 'self.compiler' really is a CCompiler object;
|
91 |
+
if not, make it one.
|
92 |
+
"""
|
93 |
+
# We do this late, and only on-demand, because this is an expensive
|
94 |
+
# import.
|
95 |
+
from distutils.ccompiler import CCompiler, new_compiler
|
96 |
+
if not isinstance(self.compiler, CCompiler):
|
97 |
+
self.compiler = new_compiler(compiler=self.compiler,
|
98 |
+
dry_run=self.dry_run, force=1)
|
99 |
+
customize_compiler(self.compiler)
|
100 |
+
if self.include_dirs:
|
101 |
+
self.compiler.set_include_dirs(self.include_dirs)
|
102 |
+
if self.libraries:
|
103 |
+
self.compiler.set_libraries(self.libraries)
|
104 |
+
if self.library_dirs:
|
105 |
+
self.compiler.set_library_dirs(self.library_dirs)
|
106 |
+
|
107 |
+
def _gen_temp_sourcefile(self, body, headers, lang):
|
108 |
+
filename = "_configtest" + LANG_EXT[lang]
|
109 |
+
with open(filename, "w") as file:
|
110 |
+
if headers:
|
111 |
+
for header in headers:
|
112 |
+
file.write("#include <%s>\n" % header)
|
113 |
+
file.write("\n")
|
114 |
+
file.write(body)
|
115 |
+
if body[-1] != "\n":
|
116 |
+
file.write("\n")
|
117 |
+
return filename
|
118 |
+
|
119 |
+
def _preprocess(self, body, headers, include_dirs, lang):
|
120 |
+
src = self._gen_temp_sourcefile(body, headers, lang)
|
121 |
+
out = "_configtest.i"
|
122 |
+
self.temp_files.extend([src, out])
|
123 |
+
self.compiler.preprocess(src, out, include_dirs=include_dirs)
|
124 |
+
return (src, out)
|
125 |
+
|
126 |
+
def _compile(self, body, headers, include_dirs, lang):
|
127 |
+
src = self._gen_temp_sourcefile(body, headers, lang)
|
128 |
+
if self.dump_source:
|
129 |
+
dump_file(src, "compiling '%s':" % src)
|
130 |
+
(obj,) = self.compiler.object_filenames([src])
|
131 |
+
self.temp_files.extend([src, obj])
|
132 |
+
self.compiler.compile([src], include_dirs=include_dirs)
|
133 |
+
return (src, obj)
|
134 |
+
|
135 |
+
def _link(self, body, headers, include_dirs, libraries, library_dirs,
|
136 |
+
lang):
|
137 |
+
(src, obj) = self._compile(body, headers, include_dirs, lang)
|
138 |
+
prog = os.path.splitext(os.path.basename(src))[0]
|
139 |
+
self.compiler.link_executable([obj], prog,
|
140 |
+
libraries=libraries,
|
141 |
+
library_dirs=library_dirs,
|
142 |
+
target_lang=lang)
|
143 |
+
|
144 |
+
if self.compiler.exe_extension is not None:
|
145 |
+
prog = prog + self.compiler.exe_extension
|
146 |
+
self.temp_files.append(prog)
|
147 |
+
|
148 |
+
return (src, obj, prog)
|
149 |
+
|
150 |
+
def _clean(self, *filenames):
|
151 |
+
if not filenames:
|
152 |
+
filenames = self.temp_files
|
153 |
+
self.temp_files = []
|
154 |
+
log.info("removing: %s", ' '.join(filenames))
|
155 |
+
for filename in filenames:
|
156 |
+
try:
|
157 |
+
os.remove(filename)
|
158 |
+
except OSError:
|
159 |
+
pass
|
160 |
+
|
161 |
+
|
162 |
+
# XXX these ignore the dry-run flag: what to do, what to do? even if
|
163 |
+
# you want a dry-run build, you still need some sort of configuration
|
164 |
+
# info. My inclination is to make it up to the real config command to
|
165 |
+
# consult 'dry_run', and assume a default (minimal) configuration if
|
166 |
+
# true. The problem with trying to do it here is that you'd have to
|
167 |
+
# return either true or false from all the 'try' methods, neither of
|
168 |
+
# which is correct.
|
169 |
+
|
170 |
+
# XXX need access to the header search path and maybe default macros.
|
171 |
+
|
172 |
+
def try_cpp(self, body=None, headers=None, include_dirs=None, lang="c"):
|
173 |
+
"""Construct a source file from 'body' (a string containing lines
|
174 |
+
of C/C++ code) and 'headers' (a list of header files to include)
|
175 |
+
and run it through the preprocessor. Return true if the
|
176 |
+
preprocessor succeeded, false if there were any errors.
|
177 |
+
('body' probably isn't of much use, but what the heck.)
|
178 |
+
"""
|
179 |
+
from distutils.ccompiler import CompileError
|
180 |
+
self._check_compiler()
|
181 |
+
ok = True
|
182 |
+
try:
|
183 |
+
self._preprocess(body, headers, include_dirs, lang)
|
184 |
+
except CompileError:
|
185 |
+
ok = False
|
186 |
+
|
187 |
+
self._clean()
|
188 |
+
return ok
|
189 |
+
|
190 |
+
def search_cpp(self, pattern, body=None, headers=None, include_dirs=None,
|
191 |
+
lang="c"):
|
192 |
+
"""Construct a source file (just like 'try_cpp()'), run it through
|
193 |
+
the preprocessor, and return true if any line of the output matches
|
194 |
+
'pattern'. 'pattern' should either be a compiled regex object or a
|
195 |
+
string containing a regex. If both 'body' and 'headers' are None,
|
196 |
+
preprocesses an empty file -- which can be useful to determine the
|
197 |
+
symbols the preprocessor and compiler set by default.
|
198 |
+
"""
|
199 |
+
self._check_compiler()
|
200 |
+
src, out = self._preprocess(body, headers, include_dirs, lang)
|
201 |
+
|
202 |
+
if isinstance(pattern, str):
|
203 |
+
pattern = re.compile(pattern)
|
204 |
+
|
205 |
+
with open(out) as file:
|
206 |
+
match = False
|
207 |
+
while True:
|
208 |
+
line = file.readline()
|
209 |
+
if line == '':
|
210 |
+
break
|
211 |
+
if pattern.search(line):
|
212 |
+
match = True
|
213 |
+
break
|
214 |
+
|
215 |
+
self._clean()
|
216 |
+
return match
|
217 |
+
|
218 |
+
def try_compile(self, body, headers=None, include_dirs=None, lang="c"):
|
219 |
+
"""Try to compile a source file built from 'body' and 'headers'.
|
220 |
+
Return true on success, false otherwise.
|
221 |
+
"""
|
222 |
+
from distutils.ccompiler import CompileError
|
223 |
+
self._check_compiler()
|
224 |
+
try:
|
225 |
+
self._compile(body, headers, include_dirs, lang)
|
226 |
+
ok = True
|
227 |
+
except CompileError:
|
228 |
+
ok = False
|
229 |
+
|
230 |
+
log.info(ok and "success!" or "failure.")
|
231 |
+
self._clean()
|
232 |
+
return ok
|
233 |
+
|
234 |
+
def try_link(self, body, headers=None, include_dirs=None, libraries=None,
|
235 |
+
library_dirs=None, lang="c"):
|
236 |
+
"""Try to compile and link a source file, built from 'body' and
|
237 |
+
'headers', to executable form. Return true on success, false
|
238 |
+
otherwise.
|
239 |
+
"""
|
240 |
+
from distutils.ccompiler import CompileError, LinkError
|
241 |
+
self._check_compiler()
|
242 |
+
try:
|
243 |
+
self._link(body, headers, include_dirs,
|
244 |
+
libraries, library_dirs, lang)
|
245 |
+
ok = True
|
246 |
+
except (CompileError, LinkError):
|
247 |
+
ok = False
|
248 |
+
|
249 |
+
log.info(ok and "success!" or "failure.")
|
250 |
+
self._clean()
|
251 |
+
return ok
|
252 |
+
|
253 |
+
def try_run(self, body, headers=None, include_dirs=None, libraries=None,
|
254 |
+
library_dirs=None, lang="c"):
|
255 |
+
"""Try to compile, link to an executable, and run a program
|
256 |
+
built from 'body' and 'headers'. Return true on success, false
|
257 |
+
otherwise.
|
258 |
+
"""
|
259 |
+
from distutils.ccompiler import CompileError, LinkError
|
260 |
+
self._check_compiler()
|
261 |
+
try:
|
262 |
+
src, obj, exe = self._link(body, headers, include_dirs,
|
263 |
+
libraries, library_dirs, lang)
|
264 |
+
self.spawn([exe])
|
265 |
+
ok = True
|
266 |
+
except (CompileError, LinkError, DistutilsExecError):
|
267 |
+
ok = False
|
268 |
+
|
269 |
+
log.info(ok and "success!" or "failure.")
|
270 |
+
self._clean()
|
271 |
+
return ok
|
272 |
+
|
273 |
+
|
274 |
+
# -- High-level methods --------------------------------------------
|
275 |
+
# (these are the ones that are actually likely to be useful
|
276 |
+
# when implementing a real-world config command!)
|
277 |
+
|
278 |
+
def check_func(self, func, headers=None, include_dirs=None,
|
279 |
+
libraries=None, library_dirs=None, decl=0, call=0):
|
280 |
+
"""Determine if function 'func' is available by constructing a
|
281 |
+
source file that refers to 'func', and compiles and links it.
|
282 |
+
If everything succeeds, returns true; otherwise returns false.
|
283 |
+
|
284 |
+
The constructed source file starts out by including the header
|
285 |
+
files listed in 'headers'. If 'decl' is true, it then declares
|
286 |
+
'func' (as "int func()"); you probably shouldn't supply 'headers'
|
287 |
+
and set 'decl' true in the same call, or you might get errors about
|
288 |
+
a conflicting declarations for 'func'. Finally, the constructed
|
289 |
+
'main()' function either references 'func' or (if 'call' is true)
|
290 |
+
calls it. 'libraries' and 'library_dirs' are used when
|
291 |
+
linking.
|
292 |
+
"""
|
293 |
+
self._check_compiler()
|
294 |
+
body = []
|
295 |
+
if decl:
|
296 |
+
body.append("int %s ();" % func)
|
297 |
+
body.append("int main () {")
|
298 |
+
if call:
|
299 |
+
body.append(" %s();" % func)
|
300 |
+
else:
|
301 |
+
body.append(" %s;" % func)
|
302 |
+
body.append("}")
|
303 |
+
body = "\n".join(body) + "\n"
|
304 |
+
|
305 |
+
return self.try_link(body, headers, include_dirs,
|
306 |
+
libraries, library_dirs)
|
307 |
+
|
308 |
+
def check_lib(self, library, library_dirs=None, headers=None,
|
309 |
+
include_dirs=None, other_libraries=[]):
|
310 |
+
"""Determine if 'library' is available to be linked against,
|
311 |
+
without actually checking that any particular symbols are provided
|
312 |
+
by it. 'headers' will be used in constructing the source file to
|
313 |
+
be compiled, but the only effect of this is to check if all the
|
314 |
+
header files listed are available. Any libraries listed in
|
315 |
+
'other_libraries' will be included in the link, in case 'library'
|
316 |
+
has symbols that depend on other libraries.
|
317 |
+
"""
|
318 |
+
self._check_compiler()
|
319 |
+
return self.try_link("int main (void) { }", headers, include_dirs,
|
320 |
+
[library] + other_libraries, library_dirs)
|
321 |
+
|
322 |
+
def check_header(self, header, include_dirs=None, library_dirs=None,
|
323 |
+
lang="c"):
|
324 |
+
"""Determine if the system header file named by 'header_file'
|
325 |
+
exists and can be found by the preprocessor; return true if so,
|
326 |
+
false otherwise.
|
327 |
+
"""
|
328 |
+
return self.try_cpp(body="/* No body */", headers=[header],
|
329 |
+
include_dirs=include_dirs)
|
330 |
+
|
331 |
+
def dump_file(filename, head=None):
|
332 |
+
"""Dumps a file content into log.info.
|
333 |
+
|
334 |
+
If head is not None, will be dumped before the file content.
|
335 |
+
"""
|
336 |
+
if head is None:
|
337 |
+
log.info('%s', filename)
|
338 |
+
else:
|
339 |
+
log.info(head)
|
340 |
+
file = open(filename)
|
341 |
+
try:
|
342 |
+
log.info(file.read())
|
343 |
+
finally:
|
344 |
+
file.close()
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/install.py
ADDED
@@ -0,0 +1,721 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.install
|
2 |
+
|
3 |
+
Implements the Distutils 'install' command."""
|
4 |
+
|
5 |
+
import sys
|
6 |
+
import os
|
7 |
+
import contextlib
|
8 |
+
import sysconfig
|
9 |
+
import itertools
|
10 |
+
|
11 |
+
from distutils import log
|
12 |
+
from distutils.core import Command
|
13 |
+
from distutils.debug import DEBUG
|
14 |
+
from distutils.sysconfig import get_config_vars
|
15 |
+
from distutils.errors import DistutilsPlatformError
|
16 |
+
from distutils.file_util import write_file
|
17 |
+
from distutils.util import convert_path, subst_vars, change_root
|
18 |
+
from distutils.util import get_platform
|
19 |
+
from distutils.errors import DistutilsOptionError
|
20 |
+
|
21 |
+
from site import USER_BASE
|
22 |
+
from site import USER_SITE
|
23 |
+
HAS_USER_SITE = True
|
24 |
+
|
25 |
+
WINDOWS_SCHEME = {
|
26 |
+
'purelib': '{base}/Lib/site-packages',
|
27 |
+
'platlib': '{base}/Lib/site-packages',
|
28 |
+
'headers': '{base}/Include/{dist_name}',
|
29 |
+
'scripts': '{base}/Scripts',
|
30 |
+
'data' : '{base}',
|
31 |
+
}
|
32 |
+
|
33 |
+
INSTALL_SCHEMES = {
|
34 |
+
'posix_prefix': {
|
35 |
+
'purelib': '{base}/lib/{implementation_lower}{py_version_short}/site-packages',
|
36 |
+
'platlib': '{platbase}/{platlibdir}/{implementation_lower}{py_version_short}/site-packages',
|
37 |
+
'headers': '{base}/include/{implementation_lower}{py_version_short}{abiflags}/{dist_name}',
|
38 |
+
'scripts': '{base}/bin',
|
39 |
+
'data' : '{base}',
|
40 |
+
},
|
41 |
+
'posix_home': {
|
42 |
+
'purelib': '{base}/lib/{implementation_lower}',
|
43 |
+
'platlib': '{base}/{platlibdir}/{implementation_lower}',
|
44 |
+
'headers': '{base}/include/{implementation_lower}/{dist_name}',
|
45 |
+
'scripts': '{base}/bin',
|
46 |
+
'data' : '{base}',
|
47 |
+
},
|
48 |
+
'nt': WINDOWS_SCHEME,
|
49 |
+
'pypy': {
|
50 |
+
'purelib': '{base}/site-packages',
|
51 |
+
'platlib': '{base}/site-packages',
|
52 |
+
'headers': '{base}/include/{dist_name}',
|
53 |
+
'scripts': '{base}/bin',
|
54 |
+
'data' : '{base}',
|
55 |
+
},
|
56 |
+
'pypy_nt': {
|
57 |
+
'purelib': '{base}/site-packages',
|
58 |
+
'platlib': '{base}/site-packages',
|
59 |
+
'headers': '{base}/include/{dist_name}',
|
60 |
+
'scripts': '{base}/Scripts',
|
61 |
+
'data' : '{base}',
|
62 |
+
},
|
63 |
+
}
|
64 |
+
|
65 |
+
# user site schemes
|
66 |
+
if HAS_USER_SITE:
|
67 |
+
INSTALL_SCHEMES['nt_user'] = {
|
68 |
+
'purelib': '{usersite}',
|
69 |
+
'platlib': '{usersite}',
|
70 |
+
'headers': '{userbase}/{implementation}{py_version_nodot}/Include/{dist_name}',
|
71 |
+
'scripts': '{userbase}/{implementation}{py_version_nodot}/Scripts',
|
72 |
+
'data' : '{userbase}',
|
73 |
+
}
|
74 |
+
|
75 |
+
INSTALL_SCHEMES['posix_user'] = {
|
76 |
+
'purelib': '{usersite}',
|
77 |
+
'platlib': '{usersite}',
|
78 |
+
'headers':
|
79 |
+
'{userbase}/include/{implementation_lower}{py_version_short}{abiflags}/{dist_name}',
|
80 |
+
'scripts': '{userbase}/bin',
|
81 |
+
'data' : '{userbase}',
|
82 |
+
}
|
83 |
+
|
84 |
+
# The keys to an installation scheme; if any new types of files are to be
|
85 |
+
# installed, be sure to add an entry to every installation scheme above,
|
86 |
+
# and to SCHEME_KEYS here.
|
87 |
+
SCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data')
|
88 |
+
|
89 |
+
|
90 |
+
def _load_sysconfig_schemes():
|
91 |
+
with contextlib.suppress(AttributeError):
|
92 |
+
return {
|
93 |
+
scheme: sysconfig.get_paths(scheme, expand=False)
|
94 |
+
for scheme in sysconfig.get_scheme_names()
|
95 |
+
}
|
96 |
+
|
97 |
+
|
98 |
+
def _load_schemes():
|
99 |
+
"""
|
100 |
+
Extend default schemes with schemes from sysconfig.
|
101 |
+
"""
|
102 |
+
|
103 |
+
sysconfig_schemes = _load_sysconfig_schemes() or {}
|
104 |
+
|
105 |
+
return {
|
106 |
+
scheme: {
|
107 |
+
**INSTALL_SCHEMES.get(scheme, {}),
|
108 |
+
**sysconfig_schemes.get(scheme, {}),
|
109 |
+
}
|
110 |
+
for scheme in set(itertools.chain(INSTALL_SCHEMES, sysconfig_schemes))
|
111 |
+
}
|
112 |
+
|
113 |
+
|
114 |
+
def _get_implementation():
|
115 |
+
if hasattr(sys, 'pypy_version_info'):
|
116 |
+
return 'PyPy'
|
117 |
+
else:
|
118 |
+
return 'Python'
|
119 |
+
|
120 |
+
|
121 |
+
class install(Command):
|
122 |
+
|
123 |
+
description = "install everything from build directory"
|
124 |
+
|
125 |
+
user_options = [
|
126 |
+
# Select installation scheme and set base director(y|ies)
|
127 |
+
('prefix=', None,
|
128 |
+
"installation prefix"),
|
129 |
+
('exec-prefix=', None,
|
130 |
+
"(Unix only) prefix for platform-specific files"),
|
131 |
+
('home=', None,
|
132 |
+
"(Unix only) home directory to install under"),
|
133 |
+
|
134 |
+
# Or, just set the base director(y|ies)
|
135 |
+
('install-base=', None,
|
136 |
+
"base installation directory (instead of --prefix or --home)"),
|
137 |
+
('install-platbase=', None,
|
138 |
+
"base installation directory for platform-specific files " +
|
139 |
+
"(instead of --exec-prefix or --home)"),
|
140 |
+
('root=', None,
|
141 |
+
"install everything relative to this alternate root directory"),
|
142 |
+
|
143 |
+
# Or, explicitly set the installation scheme
|
144 |
+
('install-purelib=', None,
|
145 |
+
"installation directory for pure Python module distributions"),
|
146 |
+
('install-platlib=', None,
|
147 |
+
"installation directory for non-pure module distributions"),
|
148 |
+
('install-lib=', None,
|
149 |
+
"installation directory for all module distributions " +
|
150 |
+
"(overrides --install-purelib and --install-platlib)"),
|
151 |
+
|
152 |
+
('install-headers=', None,
|
153 |
+
"installation directory for C/C++ headers"),
|
154 |
+
('install-scripts=', None,
|
155 |
+
"installation directory for Python scripts"),
|
156 |
+
('install-data=', None,
|
157 |
+
"installation directory for data files"),
|
158 |
+
|
159 |
+
# Byte-compilation options -- see install_lib.py for details, as
|
160 |
+
# these are duplicated from there (but only install_lib does
|
161 |
+
# anything with them).
|
162 |
+
('compile', 'c', "compile .py to .pyc [default]"),
|
163 |
+
('no-compile', None, "don't compile .py files"),
|
164 |
+
('optimize=', 'O',
|
165 |
+
"also compile with optimization: -O1 for \"python -O\", "
|
166 |
+
"-O2 for \"python -OO\", and -O0 to disable [default: -O0]"),
|
167 |
+
|
168 |
+
# Miscellaneous control options
|
169 |
+
('force', 'f',
|
170 |
+
"force installation (overwrite any existing files)"),
|
171 |
+
('skip-build', None,
|
172 |
+
"skip rebuilding everything (for testing/debugging)"),
|
173 |
+
|
174 |
+
# Where to install documentation (eventually!)
|
175 |
+
#('doc-format=', None, "format of documentation to generate"),
|
176 |
+
#('install-man=', None, "directory for Unix man pages"),
|
177 |
+
#('install-html=', None, "directory for HTML documentation"),
|
178 |
+
#('install-info=', None, "directory for GNU info files"),
|
179 |
+
|
180 |
+
('record=', None,
|
181 |
+
"filename in which to record list of installed files"),
|
182 |
+
]
|
183 |
+
|
184 |
+
boolean_options = ['compile', 'force', 'skip-build']
|
185 |
+
|
186 |
+
if HAS_USER_SITE:
|
187 |
+
user_options.append(('user', None,
|
188 |
+
"install in user site-package '%s'" % USER_SITE))
|
189 |
+
boolean_options.append('user')
|
190 |
+
|
191 |
+
negative_opt = {'no-compile' : 'compile'}
|
192 |
+
|
193 |
+
|
194 |
+
def initialize_options(self):
|
195 |
+
"""Initializes options."""
|
196 |
+
# High-level options: these select both an installation base
|
197 |
+
# and scheme.
|
198 |
+
self.prefix = None
|
199 |
+
self.exec_prefix = None
|
200 |
+
self.home = None
|
201 |
+
self.user = 0
|
202 |
+
|
203 |
+
# These select only the installation base; it's up to the user to
|
204 |
+
# specify the installation scheme (currently, that means supplying
|
205 |
+
# the --install-{platlib,purelib,scripts,data} options).
|
206 |
+
self.install_base = None
|
207 |
+
self.install_platbase = None
|
208 |
+
self.root = None
|
209 |
+
|
210 |
+
# These options are the actual installation directories; if not
|
211 |
+
# supplied by the user, they are filled in using the installation
|
212 |
+
# scheme implied by prefix/exec-prefix/home and the contents of
|
213 |
+
# that installation scheme.
|
214 |
+
self.install_purelib = None # for pure module distributions
|
215 |
+
self.install_platlib = None # non-pure (dists w/ extensions)
|
216 |
+
self.install_headers = None # for C/C++ headers
|
217 |
+
self.install_lib = None # set to either purelib or platlib
|
218 |
+
self.install_scripts = None
|
219 |
+
self.install_data = None
|
220 |
+
self.install_userbase = USER_BASE
|
221 |
+
self.install_usersite = USER_SITE
|
222 |
+
|
223 |
+
self.compile = None
|
224 |
+
self.optimize = None
|
225 |
+
|
226 |
+
# Deprecated
|
227 |
+
# These two are for putting non-packagized distributions into their
|
228 |
+
# own directory and creating a .pth file if it makes sense.
|
229 |
+
# 'extra_path' comes from the setup file; 'install_path_file' can
|
230 |
+
# be turned off if it makes no sense to install a .pth file. (But
|
231 |
+
# better to install it uselessly than to guess wrong and not
|
232 |
+
# install it when it's necessary and would be used!) Currently,
|
233 |
+
# 'install_path_file' is always true unless some outsider meddles
|
234 |
+
# with it.
|
235 |
+
self.extra_path = None
|
236 |
+
self.install_path_file = 1
|
237 |
+
|
238 |
+
# 'force' forces installation, even if target files are not
|
239 |
+
# out-of-date. 'skip_build' skips running the "build" command,
|
240 |
+
# handy if you know it's not necessary. 'warn_dir' (which is *not*
|
241 |
+
# a user option, it's just there so the bdist_* commands can turn
|
242 |
+
# it off) determines whether we warn about installing to a
|
243 |
+
# directory not in sys.path.
|
244 |
+
self.force = 0
|
245 |
+
self.skip_build = 0
|
246 |
+
self.warn_dir = 1
|
247 |
+
|
248 |
+
# These are only here as a conduit from the 'build' command to the
|
249 |
+
# 'install_*' commands that do the real work. ('build_base' isn't
|
250 |
+
# actually used anywhere, but it might be useful in future.) They
|
251 |
+
# are not user options, because if the user told the install
|
252 |
+
# command where the build directory is, that wouldn't affect the
|
253 |
+
# build command.
|
254 |
+
self.build_base = None
|
255 |
+
self.build_lib = None
|
256 |
+
|
257 |
+
# Not defined yet because we don't know anything about
|
258 |
+
# documentation yet.
|
259 |
+
#self.install_man = None
|
260 |
+
#self.install_html = None
|
261 |
+
#self.install_info = None
|
262 |
+
|
263 |
+
self.record = None
|
264 |
+
|
265 |
+
|
266 |
+
# -- Option finalizing methods -------------------------------------
|
267 |
+
# (This is rather more involved than for most commands,
|
268 |
+
# because this is where the policy for installing third-
|
269 |
+
# party Python modules on various platforms given a wide
|
270 |
+
# array of user input is decided. Yes, it's quite complex!)
|
271 |
+
|
272 |
+
def finalize_options(self):
|
273 |
+
"""Finalizes options."""
|
274 |
+
# This method (and its helpers, like 'finalize_unix()',
|
275 |
+
# 'finalize_other()', and 'select_scheme()') is where the default
|
276 |
+
# installation directories for modules, extension modules, and
|
277 |
+
# anything else we care to install from a Python module
|
278 |
+
# distribution. Thus, this code makes a pretty important policy
|
279 |
+
# statement about how third-party stuff is added to a Python
|
280 |
+
# installation! Note that the actual work of installation is done
|
281 |
+
# by the relatively simple 'install_*' commands; they just take
|
282 |
+
# their orders from the installation directory options determined
|
283 |
+
# here.
|
284 |
+
|
285 |
+
# Check for errors/inconsistencies in the options; first, stuff
|
286 |
+
# that's wrong on any platform.
|
287 |
+
|
288 |
+
if ((self.prefix or self.exec_prefix or self.home) and
|
289 |
+
(self.install_base or self.install_platbase)):
|
290 |
+
raise DistutilsOptionError(
|
291 |
+
"must supply either prefix/exec-prefix/home or " +
|
292 |
+
"install-base/install-platbase -- not both")
|
293 |
+
|
294 |
+
if self.home and (self.prefix or self.exec_prefix):
|
295 |
+
raise DistutilsOptionError(
|
296 |
+
"must supply either home or prefix/exec-prefix -- not both")
|
297 |
+
|
298 |
+
if self.user and (self.prefix or self.exec_prefix or self.home or
|
299 |
+
self.install_base or self.install_platbase):
|
300 |
+
raise DistutilsOptionError("can't combine user with prefix, "
|
301 |
+
"exec_prefix/home, or install_(plat)base")
|
302 |
+
|
303 |
+
# Next, stuff that's wrong (or dubious) only on certain platforms.
|
304 |
+
if os.name != "posix":
|
305 |
+
if self.exec_prefix:
|
306 |
+
self.warn("exec-prefix option ignored on this platform")
|
307 |
+
self.exec_prefix = None
|
308 |
+
|
309 |
+
# Now the interesting logic -- so interesting that we farm it out
|
310 |
+
# to other methods. The goal of these methods is to set the final
|
311 |
+
# values for the install_{lib,scripts,data,...} options, using as
|
312 |
+
# input a heady brew of prefix, exec_prefix, home, install_base,
|
313 |
+
# install_platbase, user-supplied versions of
|
314 |
+
# install_{purelib,platlib,lib,scripts,data,...}, and the
|
315 |
+
# install schemes. Phew!
|
316 |
+
|
317 |
+
self.dump_dirs("pre-finalize_{unix,other}")
|
318 |
+
|
319 |
+
if os.name == 'posix':
|
320 |
+
self.finalize_unix()
|
321 |
+
else:
|
322 |
+
self.finalize_other()
|
323 |
+
|
324 |
+
self.dump_dirs("post-finalize_{unix,other}()")
|
325 |
+
|
326 |
+
# Expand configuration variables, tilde, etc. in self.install_base
|
327 |
+
# and self.install_platbase -- that way, we can use $base or
|
328 |
+
# $platbase in the other installation directories and not worry
|
329 |
+
# about needing recursive variable expansion (shudder).
|
330 |
+
|
331 |
+
py_version = sys.version.split()[0]
|
332 |
+
(prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
|
333 |
+
try:
|
334 |
+
abiflags = sys.abiflags
|
335 |
+
except AttributeError:
|
336 |
+
# sys.abiflags may not be defined on all platforms.
|
337 |
+
abiflags = ''
|
338 |
+
self.config_vars = {'dist_name': self.distribution.get_name(),
|
339 |
+
'dist_version': self.distribution.get_version(),
|
340 |
+
'dist_fullname': self.distribution.get_fullname(),
|
341 |
+
'py_version': py_version,
|
342 |
+
'py_version_short': '%d.%d' % sys.version_info[:2],
|
343 |
+
'py_version_nodot': '%d%d' % sys.version_info[:2],
|
344 |
+
'sys_prefix': prefix,
|
345 |
+
'prefix': prefix,
|
346 |
+
'sys_exec_prefix': exec_prefix,
|
347 |
+
'exec_prefix': exec_prefix,
|
348 |
+
'abiflags': abiflags,
|
349 |
+
'platlibdir': getattr(sys, 'platlibdir', 'lib'),
|
350 |
+
'implementation_lower': _get_implementation().lower(),
|
351 |
+
'implementation': _get_implementation(),
|
352 |
+
}
|
353 |
+
|
354 |
+
if HAS_USER_SITE:
|
355 |
+
self.config_vars['userbase'] = self.install_userbase
|
356 |
+
self.config_vars['usersite'] = self.install_usersite
|
357 |
+
|
358 |
+
self.expand_basedirs()
|
359 |
+
|
360 |
+
self.dump_dirs("post-expand_basedirs()")
|
361 |
+
|
362 |
+
# Now define config vars for the base directories so we can expand
|
363 |
+
# everything else.
|
364 |
+
self.config_vars['base'] = self.install_base
|
365 |
+
self.config_vars['platbase'] = self.install_platbase
|
366 |
+
self.config_vars['installed_base'] = (
|
367 |
+
sysconfig.get_config_vars()['installed_base'])
|
368 |
+
|
369 |
+
if DEBUG:
|
370 |
+
from pprint import pprint
|
371 |
+
print("config vars:")
|
372 |
+
pprint(self.config_vars)
|
373 |
+
|
374 |
+
# Expand "~" and configuration variables in the installation
|
375 |
+
# directories.
|
376 |
+
self.expand_dirs()
|
377 |
+
|
378 |
+
self.dump_dirs("post-expand_dirs()")
|
379 |
+
|
380 |
+
# Create directories in the home dir:
|
381 |
+
if self.user:
|
382 |
+
self.create_home_path()
|
383 |
+
|
384 |
+
# Pick the actual directory to install all modules to: either
|
385 |
+
# install_purelib or install_platlib, depending on whether this
|
386 |
+
# module distribution is pure or not. Of course, if the user
|
387 |
+
# already specified install_lib, use their selection.
|
388 |
+
if self.install_lib is None:
|
389 |
+
if self.distribution.has_ext_modules(): # has extensions: non-pure
|
390 |
+
self.install_lib = self.install_platlib
|
391 |
+
else:
|
392 |
+
self.install_lib = self.install_purelib
|
393 |
+
|
394 |
+
|
395 |
+
# Convert directories from Unix /-separated syntax to the local
|
396 |
+
# convention.
|
397 |
+
self.convert_paths('lib', 'purelib', 'platlib',
|
398 |
+
'scripts', 'data', 'headers',
|
399 |
+
'userbase', 'usersite')
|
400 |
+
|
401 |
+
# Deprecated
|
402 |
+
# Well, we're not actually fully completely finalized yet: we still
|
403 |
+
# have to deal with 'extra_path', which is the hack for allowing
|
404 |
+
# non-packagized module distributions (hello, Numerical Python!) to
|
405 |
+
# get their own directories.
|
406 |
+
self.handle_extra_path()
|
407 |
+
self.install_libbase = self.install_lib # needed for .pth file
|
408 |
+
self.install_lib = os.path.join(self.install_lib, self.extra_dirs)
|
409 |
+
|
410 |
+
# If a new root directory was supplied, make all the installation
|
411 |
+
# dirs relative to it.
|
412 |
+
if self.root is not None:
|
413 |
+
self.change_roots('libbase', 'lib', 'purelib', 'platlib',
|
414 |
+
'scripts', 'data', 'headers')
|
415 |
+
|
416 |
+
self.dump_dirs("after prepending root")
|
417 |
+
|
418 |
+
# Find out the build directories, ie. where to install from.
|
419 |
+
self.set_undefined_options('build',
|
420 |
+
('build_base', 'build_base'),
|
421 |
+
('build_lib', 'build_lib'))
|
422 |
+
|
423 |
+
# Punt on doc directories for now -- after all, we're punting on
|
424 |
+
# documentation completely!
|
425 |
+
|
426 |
+
def dump_dirs(self, msg):
|
427 |
+
"""Dumps the list of user options."""
|
428 |
+
if not DEBUG:
|
429 |
+
return
|
430 |
+
from distutils.fancy_getopt import longopt_xlate
|
431 |
+
log.debug(msg + ":")
|
432 |
+
for opt in self.user_options:
|
433 |
+
opt_name = opt[0]
|
434 |
+
if opt_name[-1] == "=":
|
435 |
+
opt_name = opt_name[0:-1]
|
436 |
+
if opt_name in self.negative_opt:
|
437 |
+
opt_name = self.negative_opt[opt_name]
|
438 |
+
opt_name = opt_name.translate(longopt_xlate)
|
439 |
+
val = not getattr(self, opt_name)
|
440 |
+
else:
|
441 |
+
opt_name = opt_name.translate(longopt_xlate)
|
442 |
+
val = getattr(self, opt_name)
|
443 |
+
log.debug(" %s: %s", opt_name, val)
|
444 |
+
|
445 |
+
def finalize_unix(self):
|
446 |
+
"""Finalizes options for posix platforms."""
|
447 |
+
if self.install_base is not None or self.install_platbase is not None:
|
448 |
+
if ((self.install_lib is None and
|
449 |
+
self.install_purelib is None and
|
450 |
+
self.install_platlib is None) or
|
451 |
+
self.install_headers is None or
|
452 |
+
self.install_scripts is None or
|
453 |
+
self.install_data is None):
|
454 |
+
raise DistutilsOptionError(
|
455 |
+
"install-base or install-platbase supplied, but "
|
456 |
+
"installation scheme is incomplete")
|
457 |
+
return
|
458 |
+
|
459 |
+
if self.user:
|
460 |
+
if self.install_userbase is None:
|
461 |
+
raise DistutilsPlatformError(
|
462 |
+
"User base directory is not specified")
|
463 |
+
self.install_base = self.install_platbase = self.install_userbase
|
464 |
+
self.select_scheme("posix_user")
|
465 |
+
elif self.home is not None:
|
466 |
+
self.install_base = self.install_platbase = self.home
|
467 |
+
self.select_scheme("posix_home")
|
468 |
+
else:
|
469 |
+
if self.prefix is None:
|
470 |
+
if self.exec_prefix is not None:
|
471 |
+
raise DistutilsOptionError(
|
472 |
+
"must not supply exec-prefix without prefix")
|
473 |
+
|
474 |
+
# Allow Fedora to add components to the prefix
|
475 |
+
_prefix_addition = getattr(sysconfig, '_prefix_addition', "")
|
476 |
+
|
477 |
+
self.prefix = (
|
478 |
+
os.path.normpath(sys.prefix) + _prefix_addition)
|
479 |
+
self.exec_prefix = (
|
480 |
+
os.path.normpath(sys.exec_prefix) + _prefix_addition)
|
481 |
+
|
482 |
+
else:
|
483 |
+
if self.exec_prefix is None:
|
484 |
+
self.exec_prefix = self.prefix
|
485 |
+
|
486 |
+
self.install_base = self.prefix
|
487 |
+
self.install_platbase = self.exec_prefix
|
488 |
+
self.select_scheme("posix_prefix")
|
489 |
+
|
490 |
+
def finalize_other(self):
|
491 |
+
"""Finalizes options for non-posix platforms"""
|
492 |
+
if self.user:
|
493 |
+
if self.install_userbase is None:
|
494 |
+
raise DistutilsPlatformError(
|
495 |
+
"User base directory is not specified")
|
496 |
+
self.install_base = self.install_platbase = self.install_userbase
|
497 |
+
self.select_scheme(os.name + "_user")
|
498 |
+
elif self.home is not None:
|
499 |
+
self.install_base = self.install_platbase = self.home
|
500 |
+
self.select_scheme("posix_home")
|
501 |
+
else:
|
502 |
+
if self.prefix is None:
|
503 |
+
self.prefix = os.path.normpath(sys.prefix)
|
504 |
+
|
505 |
+
self.install_base = self.install_platbase = self.prefix
|
506 |
+
try:
|
507 |
+
self.select_scheme(os.name)
|
508 |
+
except KeyError:
|
509 |
+
raise DistutilsPlatformError(
|
510 |
+
"I don't know how to install stuff on '%s'" % os.name)
|
511 |
+
|
512 |
+
def select_scheme(self, name):
|
513 |
+
"""Sets the install directories by applying the install schemes."""
|
514 |
+
# it's the caller's problem if they supply a bad name!
|
515 |
+
if (hasattr(sys, 'pypy_version_info') and
|
516 |
+
sys.version_info < (3, 8) and
|
517 |
+
not name.endswith(('_user', '_home'))):
|
518 |
+
if os.name == 'nt':
|
519 |
+
name = 'pypy_nt'
|
520 |
+
else:
|
521 |
+
name = 'pypy'
|
522 |
+
scheme = _load_schemes()[name]
|
523 |
+
for key in SCHEME_KEYS:
|
524 |
+
attrname = 'install_' + key
|
525 |
+
if getattr(self, attrname) is None:
|
526 |
+
setattr(self, attrname, scheme[key])
|
527 |
+
|
528 |
+
def _expand_attrs(self, attrs):
|
529 |
+
for attr in attrs:
|
530 |
+
val = getattr(self, attr)
|
531 |
+
if val is not None:
|
532 |
+
if os.name == 'posix' or os.name == 'nt':
|
533 |
+
val = os.path.expanduser(val)
|
534 |
+
val = subst_vars(val, self.config_vars)
|
535 |
+
setattr(self, attr, val)
|
536 |
+
|
537 |
+
def expand_basedirs(self):
|
538 |
+
"""Calls `os.path.expanduser` on install_base, install_platbase and
|
539 |
+
root."""
|
540 |
+
self._expand_attrs(['install_base', 'install_platbase', 'root'])
|
541 |
+
|
542 |
+
def expand_dirs(self):
|
543 |
+
"""Calls `os.path.expanduser` on install dirs."""
|
544 |
+
self._expand_attrs(['install_purelib', 'install_platlib',
|
545 |
+
'install_lib', 'install_headers',
|
546 |
+
'install_scripts', 'install_data',])
|
547 |
+
|
548 |
+
def convert_paths(self, *names):
|
549 |
+
"""Call `convert_path` over `names`."""
|
550 |
+
for name in names:
|
551 |
+
attr = "install_" + name
|
552 |
+
setattr(self, attr, convert_path(getattr(self, attr)))
|
553 |
+
|
554 |
+
def handle_extra_path(self):
|
555 |
+
"""Set `path_file` and `extra_dirs` using `extra_path`."""
|
556 |
+
if self.extra_path is None:
|
557 |
+
self.extra_path = self.distribution.extra_path
|
558 |
+
|
559 |
+
if self.extra_path is not None:
|
560 |
+
log.warn(
|
561 |
+
"Distribution option extra_path is deprecated. "
|
562 |
+
"See issue27919 for details."
|
563 |
+
)
|
564 |
+
if isinstance(self.extra_path, str):
|
565 |
+
self.extra_path = self.extra_path.split(',')
|
566 |
+
|
567 |
+
if len(self.extra_path) == 1:
|
568 |
+
path_file = extra_dirs = self.extra_path[0]
|
569 |
+
elif len(self.extra_path) == 2:
|
570 |
+
path_file, extra_dirs = self.extra_path
|
571 |
+
else:
|
572 |
+
raise DistutilsOptionError(
|
573 |
+
"'extra_path' option must be a list, tuple, or "
|
574 |
+
"comma-separated string with 1 or 2 elements")
|
575 |
+
|
576 |
+
# convert to local form in case Unix notation used (as it
|
577 |
+
# should be in setup scripts)
|
578 |
+
extra_dirs = convert_path(extra_dirs)
|
579 |
+
else:
|
580 |
+
path_file = None
|
581 |
+
extra_dirs = ''
|
582 |
+
|
583 |
+
# XXX should we warn if path_file and not extra_dirs? (in which
|
584 |
+
# case the path file would be harmless but pointless)
|
585 |
+
self.path_file = path_file
|
586 |
+
self.extra_dirs = extra_dirs
|
587 |
+
|
588 |
+
def change_roots(self, *names):
|
589 |
+
"""Change the install directories pointed by name using root."""
|
590 |
+
for name in names:
|
591 |
+
attr = "install_" + name
|
592 |
+
setattr(self, attr, change_root(self.root, getattr(self, attr)))
|
593 |
+
|
594 |
+
def create_home_path(self):
|
595 |
+
"""Create directories under ~."""
|
596 |
+
if not self.user:
|
597 |
+
return
|
598 |
+
home = convert_path(os.path.expanduser("~"))
|
599 |
+
for name, path in self.config_vars.items():
|
600 |
+
if path.startswith(home) and not os.path.isdir(path):
|
601 |
+
self.debug_print("os.makedirs('%s', 0o700)" % path)
|
602 |
+
os.makedirs(path, 0o700)
|
603 |
+
|
604 |
+
# -- Command execution methods -------------------------------------
|
605 |
+
|
606 |
+
def run(self):
|
607 |
+
"""Runs the command."""
|
608 |
+
# Obviously have to build before we can install
|
609 |
+
if not self.skip_build:
|
610 |
+
self.run_command('build')
|
611 |
+
# If we built for any other platform, we can't install.
|
612 |
+
build_plat = self.distribution.get_command_obj('build').plat_name
|
613 |
+
# check warn_dir - it is a clue that the 'install' is happening
|
614 |
+
# internally, and not to sys.path, so we don't check the platform
|
615 |
+
# matches what we are running.
|
616 |
+
if self.warn_dir and build_plat != get_platform():
|
617 |
+
raise DistutilsPlatformError("Can't install when "
|
618 |
+
"cross-compiling")
|
619 |
+
|
620 |
+
# Run all sub-commands (at least those that need to be run)
|
621 |
+
for cmd_name in self.get_sub_commands():
|
622 |
+
self.run_command(cmd_name)
|
623 |
+
|
624 |
+
if self.path_file:
|
625 |
+
self.create_path_file()
|
626 |
+
|
627 |
+
# write list of installed files, if requested.
|
628 |
+
if self.record:
|
629 |
+
outputs = self.get_outputs()
|
630 |
+
if self.root: # strip any package prefix
|
631 |
+
root_len = len(self.root)
|
632 |
+
for counter in range(len(outputs)):
|
633 |
+
outputs[counter] = outputs[counter][root_len:]
|
634 |
+
self.execute(write_file,
|
635 |
+
(self.record, outputs),
|
636 |
+
"writing list of installed files to '%s'" %
|
637 |
+
self.record)
|
638 |
+
|
639 |
+
sys_path = map(os.path.normpath, sys.path)
|
640 |
+
sys_path = map(os.path.normcase, sys_path)
|
641 |
+
install_lib = os.path.normcase(os.path.normpath(self.install_lib))
|
642 |
+
if (self.warn_dir and
|
643 |
+
not (self.path_file and self.install_path_file) and
|
644 |
+
install_lib not in sys_path):
|
645 |
+
log.debug(("modules installed to '%s', which is not in "
|
646 |
+
"Python's module search path (sys.path) -- "
|
647 |
+
"you'll have to change the search path yourself"),
|
648 |
+
self.install_lib)
|
649 |
+
|
650 |
+
def create_path_file(self):
|
651 |
+
"""Creates the .pth file"""
|
652 |
+
filename = os.path.join(self.install_libbase,
|
653 |
+
self.path_file + ".pth")
|
654 |
+
if self.install_path_file:
|
655 |
+
self.execute(write_file,
|
656 |
+
(filename, [self.extra_dirs]),
|
657 |
+
"creating %s" % filename)
|
658 |
+
else:
|
659 |
+
self.warn("path file '%s' not created" % filename)
|
660 |
+
|
661 |
+
|
662 |
+
# -- Reporting methods ---------------------------------------------
|
663 |
+
|
664 |
+
def get_outputs(self):
|
665 |
+
"""Assembles the outputs of all the sub-commands."""
|
666 |
+
outputs = []
|
667 |
+
for cmd_name in self.get_sub_commands():
|
668 |
+
cmd = self.get_finalized_command(cmd_name)
|
669 |
+
# Add the contents of cmd.get_outputs(), ensuring
|
670 |
+
# that outputs doesn't contain duplicate entries
|
671 |
+
for filename in cmd.get_outputs():
|
672 |
+
if filename not in outputs:
|
673 |
+
outputs.append(filename)
|
674 |
+
|
675 |
+
if self.path_file and self.install_path_file:
|
676 |
+
outputs.append(os.path.join(self.install_libbase,
|
677 |
+
self.path_file + ".pth"))
|
678 |
+
|
679 |
+
return outputs
|
680 |
+
|
681 |
+
def get_inputs(self):
|
682 |
+
"""Returns the inputs of all the sub-commands"""
|
683 |
+
# XXX gee, this looks familiar ;-(
|
684 |
+
inputs = []
|
685 |
+
for cmd_name in self.get_sub_commands():
|
686 |
+
cmd = self.get_finalized_command(cmd_name)
|
687 |
+
inputs.extend(cmd.get_inputs())
|
688 |
+
|
689 |
+
return inputs
|
690 |
+
|
691 |
+
# -- Predicates for sub-command list -------------------------------
|
692 |
+
|
693 |
+
def has_lib(self):
|
694 |
+
"""Returns true if the current distribution has any Python
|
695 |
+
modules to install."""
|
696 |
+
return (self.distribution.has_pure_modules() or
|
697 |
+
self.distribution.has_ext_modules())
|
698 |
+
|
699 |
+
def has_headers(self):
|
700 |
+
"""Returns true if the current distribution has any headers to
|
701 |
+
install."""
|
702 |
+
return self.distribution.has_headers()
|
703 |
+
|
704 |
+
def has_scripts(self):
|
705 |
+
"""Returns true if the current distribution has any scripts to.
|
706 |
+
install."""
|
707 |
+
return self.distribution.has_scripts()
|
708 |
+
|
709 |
+
def has_data(self):
|
710 |
+
"""Returns true if the current distribution has any data to.
|
711 |
+
install."""
|
712 |
+
return self.distribution.has_data_files()
|
713 |
+
|
714 |
+
# 'sub_commands': a list of commands this command might have to run to
|
715 |
+
# get its work done. See cmd.py for more info.
|
716 |
+
sub_commands = [('install_lib', has_lib),
|
717 |
+
('install_headers', has_headers),
|
718 |
+
('install_scripts', has_scripts),
|
719 |
+
('install_data', has_data),
|
720 |
+
('install_egg_info', lambda self:True),
|
721 |
+
]
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/install_data.py
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.install_data
|
2 |
+
|
3 |
+
Implements the Distutils 'install_data' command, for installing
|
4 |
+
platform-independent data files."""
|
5 |
+
|
6 |
+
# contributed by Bastian Kleineidam
|
7 |
+
|
8 |
+
import os
|
9 |
+
from distutils.core import Command
|
10 |
+
from distutils.util import change_root, convert_path
|
11 |
+
|
12 |
+
class install_data(Command):
|
13 |
+
|
14 |
+
description = "install data files"
|
15 |
+
|
16 |
+
user_options = [
|
17 |
+
('install-dir=', 'd',
|
18 |
+
"base directory for installing data files "
|
19 |
+
"(default: installation base dir)"),
|
20 |
+
('root=', None,
|
21 |
+
"install everything relative to this alternate root directory"),
|
22 |
+
('force', 'f', "force installation (overwrite existing files)"),
|
23 |
+
]
|
24 |
+
|
25 |
+
boolean_options = ['force']
|
26 |
+
|
27 |
+
def initialize_options(self):
|
28 |
+
self.install_dir = None
|
29 |
+
self.outfiles = []
|
30 |
+
self.root = None
|
31 |
+
self.force = 0
|
32 |
+
self.data_files = self.distribution.data_files
|
33 |
+
self.warn_dir = 1
|
34 |
+
|
35 |
+
def finalize_options(self):
|
36 |
+
self.set_undefined_options('install',
|
37 |
+
('install_data', 'install_dir'),
|
38 |
+
('root', 'root'),
|
39 |
+
('force', 'force'),
|
40 |
+
)
|
41 |
+
|
42 |
+
def run(self):
|
43 |
+
self.mkpath(self.install_dir)
|
44 |
+
for f in self.data_files:
|
45 |
+
if isinstance(f, str):
|
46 |
+
# it's a simple file, so copy it
|
47 |
+
f = convert_path(f)
|
48 |
+
if self.warn_dir:
|
49 |
+
self.warn("setup script did not provide a directory for "
|
50 |
+
"'%s' -- installing right in '%s'" %
|
51 |
+
(f, self.install_dir))
|
52 |
+
(out, _) = self.copy_file(f, self.install_dir)
|
53 |
+
self.outfiles.append(out)
|
54 |
+
else:
|
55 |
+
# it's a tuple with path to install to and a list of files
|
56 |
+
dir = convert_path(f[0])
|
57 |
+
if not os.path.isabs(dir):
|
58 |
+
dir = os.path.join(self.install_dir, dir)
|
59 |
+
elif self.root:
|
60 |
+
dir = change_root(self.root, dir)
|
61 |
+
self.mkpath(dir)
|
62 |
+
|
63 |
+
if f[1] == []:
|
64 |
+
# If there are no files listed, the user must be
|
65 |
+
# trying to create an empty directory, so add the
|
66 |
+
# directory to the list of output files.
|
67 |
+
self.outfiles.append(dir)
|
68 |
+
else:
|
69 |
+
# Copy files, adding them to the list of output files.
|
70 |
+
for data in f[1]:
|
71 |
+
data = convert_path(data)
|
72 |
+
(out, _) = self.copy_file(data, dir)
|
73 |
+
self.outfiles.append(out)
|
74 |
+
|
75 |
+
def get_inputs(self):
|
76 |
+
return self.data_files or []
|
77 |
+
|
78 |
+
def get_outputs(self):
|
79 |
+
return self.outfiles
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/install_egg_info.py
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.install_egg_info
|
2 |
+
|
3 |
+
Implements the Distutils 'install_egg_info' command, for installing
|
4 |
+
a package's PKG-INFO metadata."""
|
5 |
+
|
6 |
+
|
7 |
+
from distutils.cmd import Command
|
8 |
+
from distutils import log, dir_util
|
9 |
+
import os, sys, re
|
10 |
+
|
11 |
+
class install_egg_info(Command):
|
12 |
+
"""Install an .egg-info file for the package"""
|
13 |
+
|
14 |
+
description = "Install package's PKG-INFO metadata as an .egg-info file"
|
15 |
+
user_options = [
|
16 |
+
('install-dir=', 'd', "directory to install to"),
|
17 |
+
]
|
18 |
+
|
19 |
+
def initialize_options(self):
|
20 |
+
self.install_dir = None
|
21 |
+
|
22 |
+
@property
|
23 |
+
def basename(self):
|
24 |
+
"""
|
25 |
+
Allow basename to be overridden by child class.
|
26 |
+
Ref pypa/distutils#2.
|
27 |
+
"""
|
28 |
+
return "%s-%s-py%d.%d.egg-info" % (
|
29 |
+
to_filename(safe_name(self.distribution.get_name())),
|
30 |
+
to_filename(safe_version(self.distribution.get_version())),
|
31 |
+
*sys.version_info[:2]
|
32 |
+
)
|
33 |
+
|
34 |
+
def finalize_options(self):
|
35 |
+
self.set_undefined_options('install_lib',('install_dir','install_dir'))
|
36 |
+
self.target = os.path.join(self.install_dir, self.basename)
|
37 |
+
self.outputs = [self.target]
|
38 |
+
|
39 |
+
def run(self):
|
40 |
+
target = self.target
|
41 |
+
if os.path.isdir(target) and not os.path.islink(target):
|
42 |
+
dir_util.remove_tree(target, dry_run=self.dry_run)
|
43 |
+
elif os.path.exists(target):
|
44 |
+
self.execute(os.unlink,(self.target,),"Removing "+target)
|
45 |
+
elif not os.path.isdir(self.install_dir):
|
46 |
+
self.execute(os.makedirs, (self.install_dir,),
|
47 |
+
"Creating "+self.install_dir)
|
48 |
+
log.info("Writing %s", target)
|
49 |
+
if not self.dry_run:
|
50 |
+
with open(target, 'w', encoding='UTF-8') as f:
|
51 |
+
self.distribution.metadata.write_pkg_file(f)
|
52 |
+
|
53 |
+
def get_outputs(self):
|
54 |
+
return self.outputs
|
55 |
+
|
56 |
+
|
57 |
+
# The following routines are taken from setuptools' pkg_resources module and
|
58 |
+
# can be replaced by importing them from pkg_resources once it is included
|
59 |
+
# in the stdlib.
|
60 |
+
|
61 |
+
def safe_name(name):
|
62 |
+
"""Convert an arbitrary string to a standard distribution name
|
63 |
+
|
64 |
+
Any runs of non-alphanumeric/. characters are replaced with a single '-'.
|
65 |
+
"""
|
66 |
+
return re.sub('[^A-Za-z0-9.]+', '-', name)
|
67 |
+
|
68 |
+
|
69 |
+
def safe_version(version):
|
70 |
+
"""Convert an arbitrary string to a standard version string
|
71 |
+
|
72 |
+
Spaces become dots, and all other non-alphanumeric characters become
|
73 |
+
dashes, with runs of multiple dashes condensed to a single dash.
|
74 |
+
"""
|
75 |
+
version = version.replace(' ','.')
|
76 |
+
return re.sub('[^A-Za-z0-9.]+', '-', version)
|
77 |
+
|
78 |
+
|
79 |
+
def to_filename(name):
|
80 |
+
"""Convert a project or version name to its filename-escaped form
|
81 |
+
|
82 |
+
Any '-' characters are currently replaced with '_'.
|
83 |
+
"""
|
84 |
+
return name.replace('-','_')
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/install_headers.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.install_headers
|
2 |
+
|
3 |
+
Implements the Distutils 'install_headers' command, to install C/C++ header
|
4 |
+
files to the Python include directory."""
|
5 |
+
|
6 |
+
from distutils.core import Command
|
7 |
+
|
8 |
+
|
9 |
+
# XXX force is never used
|
10 |
+
class install_headers(Command):
|
11 |
+
|
12 |
+
description = "install C/C++ header files"
|
13 |
+
|
14 |
+
user_options = [('install-dir=', 'd',
|
15 |
+
"directory to install header files to"),
|
16 |
+
('force', 'f',
|
17 |
+
"force installation (overwrite existing files)"),
|
18 |
+
]
|
19 |
+
|
20 |
+
boolean_options = ['force']
|
21 |
+
|
22 |
+
def initialize_options(self):
|
23 |
+
self.install_dir = None
|
24 |
+
self.force = 0
|
25 |
+
self.outfiles = []
|
26 |
+
|
27 |
+
def finalize_options(self):
|
28 |
+
self.set_undefined_options('install',
|
29 |
+
('install_headers', 'install_dir'),
|
30 |
+
('force', 'force'))
|
31 |
+
|
32 |
+
|
33 |
+
def run(self):
|
34 |
+
headers = self.distribution.headers
|
35 |
+
if not headers:
|
36 |
+
return
|
37 |
+
|
38 |
+
self.mkpath(self.install_dir)
|
39 |
+
for header in headers:
|
40 |
+
(out, _) = self.copy_file(header, self.install_dir)
|
41 |
+
self.outfiles.append(out)
|
42 |
+
|
43 |
+
def get_inputs(self):
|
44 |
+
return self.distribution.headers or []
|
45 |
+
|
46 |
+
def get_outputs(self):
|
47 |
+
return self.outfiles
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/install_lib.py
ADDED
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.install_lib
|
2 |
+
|
3 |
+
Implements the Distutils 'install_lib' command
|
4 |
+
(install all Python modules)."""
|
5 |
+
|
6 |
+
import os
|
7 |
+
import importlib.util
|
8 |
+
import sys
|
9 |
+
|
10 |
+
from distutils.core import Command
|
11 |
+
from distutils.errors import DistutilsOptionError
|
12 |
+
|
13 |
+
|
14 |
+
# Extension for Python source files.
|
15 |
+
PYTHON_SOURCE_EXTENSION = ".py"
|
16 |
+
|
17 |
+
class install_lib(Command):
|
18 |
+
|
19 |
+
description = "install all Python modules (extensions and pure Python)"
|
20 |
+
|
21 |
+
# The byte-compilation options are a tad confusing. Here are the
|
22 |
+
# possible scenarios:
|
23 |
+
# 1) no compilation at all (--no-compile --no-optimize)
|
24 |
+
# 2) compile .pyc only (--compile --no-optimize; default)
|
25 |
+
# 3) compile .pyc and "opt-1" .pyc (--compile --optimize)
|
26 |
+
# 4) compile "opt-1" .pyc only (--no-compile --optimize)
|
27 |
+
# 5) compile .pyc and "opt-2" .pyc (--compile --optimize-more)
|
28 |
+
# 6) compile "opt-2" .pyc only (--no-compile --optimize-more)
|
29 |
+
#
|
30 |
+
# The UI for this is two options, 'compile' and 'optimize'.
|
31 |
+
# 'compile' is strictly boolean, and only decides whether to
|
32 |
+
# generate .pyc files. 'optimize' is three-way (0, 1, or 2), and
|
33 |
+
# decides both whether to generate .pyc files and what level of
|
34 |
+
# optimization to use.
|
35 |
+
|
36 |
+
user_options = [
|
37 |
+
('install-dir=', 'd', "directory to install to"),
|
38 |
+
('build-dir=','b', "build directory (where to install from)"),
|
39 |
+
('force', 'f', "force installation (overwrite existing files)"),
|
40 |
+
('compile', 'c', "compile .py to .pyc [default]"),
|
41 |
+
('no-compile', None, "don't compile .py files"),
|
42 |
+
('optimize=', 'O',
|
43 |
+
"also compile with optimization: -O1 for \"python -O\", "
|
44 |
+
"-O2 for \"python -OO\", and -O0 to disable [default: -O0]"),
|
45 |
+
('skip-build', None, "skip the build steps"),
|
46 |
+
]
|
47 |
+
|
48 |
+
boolean_options = ['force', 'compile', 'skip-build']
|
49 |
+
negative_opt = {'no-compile' : 'compile'}
|
50 |
+
|
51 |
+
def initialize_options(self):
|
52 |
+
# let the 'install' command dictate our installation directory
|
53 |
+
self.install_dir = None
|
54 |
+
self.build_dir = None
|
55 |
+
self.force = 0
|
56 |
+
self.compile = None
|
57 |
+
self.optimize = None
|
58 |
+
self.skip_build = None
|
59 |
+
|
60 |
+
def finalize_options(self):
|
61 |
+
# Get all the information we need to install pure Python modules
|
62 |
+
# from the umbrella 'install' command -- build (source) directory,
|
63 |
+
# install (target) directory, and whether to compile .py files.
|
64 |
+
self.set_undefined_options('install',
|
65 |
+
('build_lib', 'build_dir'),
|
66 |
+
('install_lib', 'install_dir'),
|
67 |
+
('force', 'force'),
|
68 |
+
('compile', 'compile'),
|
69 |
+
('optimize', 'optimize'),
|
70 |
+
('skip_build', 'skip_build'),
|
71 |
+
)
|
72 |
+
|
73 |
+
if self.compile is None:
|
74 |
+
self.compile = True
|
75 |
+
if self.optimize is None:
|
76 |
+
self.optimize = False
|
77 |
+
|
78 |
+
if not isinstance(self.optimize, int):
|
79 |
+
try:
|
80 |
+
self.optimize = int(self.optimize)
|
81 |
+
if self.optimize not in (0, 1, 2):
|
82 |
+
raise AssertionError
|
83 |
+
except (ValueError, AssertionError):
|
84 |
+
raise DistutilsOptionError("optimize must be 0, 1, or 2")
|
85 |
+
|
86 |
+
def run(self):
|
87 |
+
# Make sure we have built everything we need first
|
88 |
+
self.build()
|
89 |
+
|
90 |
+
# Install everything: simply dump the entire contents of the build
|
91 |
+
# directory to the installation directory (that's the beauty of
|
92 |
+
# having a build directory!)
|
93 |
+
outfiles = self.install()
|
94 |
+
|
95 |
+
# (Optionally) compile .py to .pyc
|
96 |
+
if outfiles is not None and self.distribution.has_pure_modules():
|
97 |
+
self.byte_compile(outfiles)
|
98 |
+
|
99 |
+
# -- Top-level worker functions ------------------------------------
|
100 |
+
# (called from 'run()')
|
101 |
+
|
102 |
+
def build(self):
|
103 |
+
if not self.skip_build:
|
104 |
+
if self.distribution.has_pure_modules():
|
105 |
+
self.run_command('build_py')
|
106 |
+
if self.distribution.has_ext_modules():
|
107 |
+
self.run_command('build_ext')
|
108 |
+
|
109 |
+
def install(self):
|
110 |
+
if os.path.isdir(self.build_dir):
|
111 |
+
outfiles = self.copy_tree(self.build_dir, self.install_dir)
|
112 |
+
else:
|
113 |
+
self.warn("'%s' does not exist -- no Python modules to install" %
|
114 |
+
self.build_dir)
|
115 |
+
return
|
116 |
+
return outfiles
|
117 |
+
|
118 |
+
def byte_compile(self, files):
|
119 |
+
if sys.dont_write_bytecode:
|
120 |
+
self.warn('byte-compiling is disabled, skipping.')
|
121 |
+
return
|
122 |
+
|
123 |
+
from distutils.util import byte_compile
|
124 |
+
|
125 |
+
# Get the "--root" directory supplied to the "install" command,
|
126 |
+
# and use it as a prefix to strip off the purported filename
|
127 |
+
# encoded in bytecode files. This is far from complete, but it
|
128 |
+
# should at least generate usable bytecode in RPM distributions.
|
129 |
+
install_root = self.get_finalized_command('install').root
|
130 |
+
|
131 |
+
if self.compile:
|
132 |
+
byte_compile(files, optimize=0,
|
133 |
+
force=self.force, prefix=install_root,
|
134 |
+
dry_run=self.dry_run)
|
135 |
+
if self.optimize > 0:
|
136 |
+
byte_compile(files, optimize=self.optimize,
|
137 |
+
force=self.force, prefix=install_root,
|
138 |
+
verbose=self.verbose, dry_run=self.dry_run)
|
139 |
+
|
140 |
+
|
141 |
+
# -- Utility methods -----------------------------------------------
|
142 |
+
|
143 |
+
def _mutate_outputs(self, has_any, build_cmd, cmd_option, output_dir):
|
144 |
+
if not has_any:
|
145 |
+
return []
|
146 |
+
|
147 |
+
build_cmd = self.get_finalized_command(build_cmd)
|
148 |
+
build_files = build_cmd.get_outputs()
|
149 |
+
build_dir = getattr(build_cmd, cmd_option)
|
150 |
+
|
151 |
+
prefix_len = len(build_dir) + len(os.sep)
|
152 |
+
outputs = []
|
153 |
+
for file in build_files:
|
154 |
+
outputs.append(os.path.join(output_dir, file[prefix_len:]))
|
155 |
+
|
156 |
+
return outputs
|
157 |
+
|
158 |
+
def _bytecode_filenames(self, py_filenames):
|
159 |
+
bytecode_files = []
|
160 |
+
for py_file in py_filenames:
|
161 |
+
# Since build_py handles package data installation, the
|
162 |
+
# list of outputs can contain more than just .py files.
|
163 |
+
# Make sure we only report bytecode for the .py files.
|
164 |
+
ext = os.path.splitext(os.path.normcase(py_file))[1]
|
165 |
+
if ext != PYTHON_SOURCE_EXTENSION:
|
166 |
+
continue
|
167 |
+
if self.compile:
|
168 |
+
bytecode_files.append(importlib.util.cache_from_source(
|
169 |
+
py_file, optimization=''))
|
170 |
+
if self.optimize > 0:
|
171 |
+
bytecode_files.append(importlib.util.cache_from_source(
|
172 |
+
py_file, optimization=self.optimize))
|
173 |
+
|
174 |
+
return bytecode_files
|
175 |
+
|
176 |
+
|
177 |
+
# -- External interface --------------------------------------------
|
178 |
+
# (called by outsiders)
|
179 |
+
|
180 |
+
def get_outputs(self):
|
181 |
+
"""Return the list of files that would be installed if this command
|
182 |
+
were actually run. Not affected by the "dry-run" flag or whether
|
183 |
+
modules have actually been built yet.
|
184 |
+
"""
|
185 |
+
pure_outputs = \
|
186 |
+
self._mutate_outputs(self.distribution.has_pure_modules(),
|
187 |
+
'build_py', 'build_lib',
|
188 |
+
self.install_dir)
|
189 |
+
if self.compile:
|
190 |
+
bytecode_outputs = self._bytecode_filenames(pure_outputs)
|
191 |
+
else:
|
192 |
+
bytecode_outputs = []
|
193 |
+
|
194 |
+
ext_outputs = \
|
195 |
+
self._mutate_outputs(self.distribution.has_ext_modules(),
|
196 |
+
'build_ext', 'build_lib',
|
197 |
+
self.install_dir)
|
198 |
+
|
199 |
+
return pure_outputs + bytecode_outputs + ext_outputs
|
200 |
+
|
201 |
+
def get_inputs(self):
|
202 |
+
"""Get the list of files that are input to this command, ie. the
|
203 |
+
files that get installed as they are named in the build tree.
|
204 |
+
The files in this list correspond one-to-one to the output
|
205 |
+
filenames returned by 'get_outputs()'.
|
206 |
+
"""
|
207 |
+
inputs = []
|
208 |
+
|
209 |
+
if self.distribution.has_pure_modules():
|
210 |
+
build_py = self.get_finalized_command('build_py')
|
211 |
+
inputs.extend(build_py.get_outputs())
|
212 |
+
|
213 |
+
if self.distribution.has_ext_modules():
|
214 |
+
build_ext = self.get_finalized_command('build_ext')
|
215 |
+
inputs.extend(build_ext.get_outputs())
|
216 |
+
|
217 |
+
return inputs
|
env-llmeval/lib/python3.10/site-packages/setuptools/_distutils/command/install_scripts.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""distutils.command.install_scripts
|
2 |
+
|
3 |
+
Implements the Distutils 'install_scripts' command, for installing
|
4 |
+
Python scripts."""
|
5 |
+
|
6 |
+
# contributed by Bastian Kleineidam
|
7 |
+
|
8 |
+
import os
|
9 |
+
from distutils.core import Command
|
10 |
+
from distutils import log
|
11 |
+
from stat import ST_MODE
|
12 |
+
|
13 |
+
|
14 |
+
class install_scripts(Command):
|
15 |
+
|
16 |
+
description = "install scripts (Python or otherwise)"
|
17 |
+
|
18 |
+
user_options = [
|
19 |
+
('install-dir=', 'd', "directory to install scripts to"),
|
20 |
+
('build-dir=','b', "build directory (where to install from)"),
|
21 |
+
('force', 'f', "force installation (overwrite existing files)"),
|
22 |
+
('skip-build', None, "skip the build steps"),
|
23 |
+
]
|
24 |
+
|
25 |
+
boolean_options = ['force', 'skip-build']
|
26 |
+
|
27 |
+
def initialize_options(self):
|
28 |
+
self.install_dir = None
|
29 |
+
self.force = 0
|
30 |
+
self.build_dir = None
|
31 |
+
self.skip_build = None
|
32 |
+
|
33 |
+
def finalize_options(self):
|
34 |
+
self.set_undefined_options('build', ('build_scripts', 'build_dir'))
|
35 |
+
self.set_undefined_options('install',
|
36 |
+
('install_scripts', 'install_dir'),
|
37 |
+
('force', 'force'),
|
38 |
+
('skip_build', 'skip_build'),
|
39 |
+
)
|
40 |
+
|
41 |
+
def run(self):
|
42 |
+
if not self.skip_build:
|
43 |
+
self.run_command('build_scripts')
|
44 |
+
self.outfiles = self.copy_tree(self.build_dir, self.install_dir)
|
45 |
+
if os.name == 'posix':
|
46 |
+
# Set the executable bits (owner, group, and world) on
|
47 |
+
# all the scripts we just installed.
|
48 |
+
for file in self.get_outputs():
|
49 |
+
if self.dry_run:
|
50 |
+
log.info("changing mode of %s", file)
|
51 |
+
else:
|
52 |
+
mode = ((os.stat(file)[ST_MODE]) | 0o555) & 0o7777
|
53 |
+
log.info("changing mode of %s to %o", file, mode)
|
54 |
+
os.chmod(file, mode)
|
55 |
+
|
56 |
+
def get_inputs(self):
|
57 |
+
return self.distribution.scripts or []
|
58 |
+
|
59 |
+
def get_outputs(self):
|
60 |
+
return self.outfiles or []
|