Skip to content

Commit ccaf6c0

Browse files
committed
Fix issues with wsl+docker on windows when building
1 parent 3e3e83e commit ccaf6c0

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

tools/build.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,21 @@ def parse_version_wrapper(txt):
2727
return version
2828

2929

30+
def _run(cmd, **kwargs):
31+
# For some reason, when combined with wsl calls, Python thinks the directory we're in has been deleted
32+
# so os.getcwd() fails
33+
saved_directory = os.getcwd()
34+
subprocess.run(cmd, **kwargs)
35+
os.chdir(saved_directory)
36+
37+
3038
def _verbose_run(cmd, **kwargs):
3139
print(' '.join(c if ' ' not in c else f'"{c}"' for c in cmd), flush=True)
40+
# For some reason, when combined with wsl calls, Python thinks the directory we're in has been deleted
41+
# so os.getcwd() fails
42+
saved_directory = os.getcwd()
3243
subprocess.run(cmd, **kwargs)
44+
os.chdir(saved_directory)
3345

3446

3547
def clear_pythia_directory():
@@ -56,7 +68,7 @@ def del_rw(action, name, exc):
5668
def create_interpreters(version, dest):
5769
version = parse_version_wrapper(version)
5870
print(f'Creating Python {version} interpreters in "{dest}" directory...', flush=True)
59-
subprocess.run([sys.executable, os.path.join('tools', 'create_embedded_python.py'), '--version', str(version), dest], check=True)
71+
_run([sys.executable, os.path.join('tools', 'create_embedded_python.py'), '--version', str(version), dest], check=True)
6072

6173

6274
def _get_embed(version, system, arch):
@@ -113,7 +125,7 @@ def run_tests(version, arch, system):
113125

114126
def build_pbos():
115127
print('Building PBOs...', flush=True)
116-
subprocess.run([sys.executable, os.path.join('tools', 'create_pbos.py')], check=True)
128+
_run([sys.executable, os.path.join('tools', 'create_pbos.py')], check=True)
117129

118130

119131
def copy_templates(version):
@@ -136,7 +148,7 @@ def copy_templates(version):
136148
def safety_checks(version):
137149
version = parse_version_wrapper(version)
138150
print('Running safety checks...', flush=True)
139-
subprocess.run([sys.executable, os.path.join('tools', 'safety_checks.py'), str(version)], check=True)
151+
_run([sys.executable, os.path.join('tools', 'safety_checks.py'), str(version)], check=True)
140152

141153

142154
def pack_mod():

tools/create_embedded_python.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ def convert_standalone_build(directory):
4848
dereference_symlinks('.')
4949
# Note: both adding the rpath and copying libcrypt will be unnecessary with 3.11+
5050
subprocess.run("patchelf --set-rpath '$ORIGIN/../lib' bin/python3", shell=True, check=True)
51+
current_dir = os.getcwd()
5152
subprocess.run('docker run --platform linux/386 --rm -v "$(pwd)"/:/data quay.io/pypa/manylinux2014_i686:latest /bin/bash -c "cp /usr/local/lib/libcrypt.so.1 /data/ && chown 1000:1000 /data/libcrypt.so.1 && chmod 555 /data/libcrypt.so.1"',
5253
shell=True, cwd='lib', check=True)
54+
os.chdir(current_dir)
5355

5456
os.chdir(currdir)
5557

58+
5659
def install_pip(python_executable):
5760
"""Just call ensurepip and then the regular pip installation."""
5861

0 commit comments

Comments
 (0)