@@ -20,6 +20,8 @@ export LLVM_PROFDATA=/tools/clang-linux64/bin/llvm-profdata
20
20
find /tools/deps -name ' *.so*' -exec rm {} \;
21
21
22
22
tar -xf Python-${PYTHON_VERSION} .tar.xz
23
+ unzip setuptools-${SETUPTOOLS_VERSION} .zip
24
+ tar -xf pip-${PIP_VERSION} .tar.gz
23
25
24
26
cat Setup.local
25
27
mv Setup.local Python-${PYTHON_VERSION} /Modules/Setup.local
@@ -89,6 +91,55 @@ cat ../Makefile.extra >> Makefile
89
91
make -j ` nproc`
90
92
make -j ` nproc` install DESTDIR=/build/out/python
91
93
94
+ # Install pip so we can patch it to work with non-dynamic executables
95
+ # and work around https://github.com/pypa/pip/issues/6543. But pip's bundled
96
+ # setuptools has the same bug! So we need to install a patched version.
97
+ pushd /build/setuptools-${SETUPTOOLS_VERSION}
98
+ patch -p1 << EOF
99
+ diff --git a/setuptools/glibc.py b/setuptools/glibc.py
100
+ index a134591c..c9c3f378 100644
101
+ --- a/setuptools/glibc.py
102
+ +++ b/setuptools/glibc.py
103
+ @@ -14,7 +14,10 @@ def glibc_version_string():
104
+ # manpage says, "If filename is NULL, then the returned handle is for the
105
+ # main program". This way we can let the linker do the work to figure out
106
+ # which libc our process is actually using.
107
+ - process_namespace = ctypes.CDLL(None)
108
+ + try:
109
+ + process_namespace = ctypes.CDLL(None)
110
+ + except OSError:
111
+ + return None
112
+ try:
113
+ gnu_get_libc_version = process_namespace.gnu_get_libc_version
114
+ except AttributeError:
115
+ EOF
116
+
117
+ /build/out/python/install/bin/python3 setup.py install
118
+ popd
119
+
120
+ pushd /build/pip-${PIP_VERSION}
121
+ patch -p1 << EOF
122
+ diff --git a/src/pip/_internal/utils/glibc.py b/src/pip/_internal/utils/glibc.py
123
+ --- a/src/pip/_internal/utils/glibc.py
124
+ +++ b/src/pip/_internal/utils/glibc.py
125
+ @@ -18,7 +18,10 @@ def glibc_version_string():
126
+ # manpage says, "If filename is NULL, then the returned handle is for the
127
+ # main program". This way we can let the linker do the work to figure out
128
+ # which libc our process is actually using.
129
+ - process_namespace = ctypes.CDLL(None)
130
+ + try:
131
+ + process_namespace = ctypes.CDLL(None)
132
+ + except OSError:
133
+ + return None
134
+ try:
135
+ gnu_get_libc_version = process_namespace.gnu_get_libc_version
136
+ except AttributeError:
137
+
138
+ EOF
139
+
140
+ /build/out/python/install/bin/python3 setup.py install
141
+ popd
142
+
92
143
# Downstream consumers don't require bytecode files. So remove them.
93
144
# Ideally we'd adjust the build system. But meh.
94
145
find /build/out/python/install -type d -name __pycache__ -print0 | xargs -0 rm -rf
0 commit comments