Can't bootstrap on windows with python 3.12
And python 3.11.3+
A recent change in cpython modified the behavior of subprocess
and now instead of using PATH
when passing shell=True
, it relies on %ComSpec%
or %SystemRoot%
which are not currently exposed in the env we pass.
Step 35/35 : RUN C:\MinGW\msys\1.0\bin\bash.exe --login -c "C:/prepare_cerbero_env.sh"
---> Running in 1301f6911de0
+ cd C:/
+ git clone -b main https://gitlab.freedesktop.org/gstreamer/cerbero.git C:/cerbero
Cloning into 'C:/cerbero'...
+ cd C:/cerbero
+ echo 'local_sources="C:/cerbero/cerbero-sources"'
+ echo 'home_dir="C:/cerbero/cerbero-build"'
+ echo 'vs_install_path = "C:/BuildTools"'
+ echo 'vs_install_version = "vs16"'
+ ./cerbero-uninstalled -t -v visualstudio -c localconf.cbc -c config/win64.cbc fetch-bootstrap --jobs=4
Traceback (most recent call last):
File "c:\cerbero\cerbero\utils\__init__.py", line 432, in parse_file
exec(compile(open(filename).read(), filename, 'exec'), dict)
File "c:/cerbero/config/windows.config", line 203, in <module>
msvc_env, msvc_version = get_msvc_env(arch, target_arch, variants.uwp,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\cerbero\cerbero\ide\vs\env.py", line 221, in get_msvc_env
without_msvc = run_and_get_env('set')
^^^^^^^^^^^^^^^^^^^^^^
File "c:\cerbero\cerbero\ide\vs\env.py", line 202, in run_and_get_env
output = subprocess.check_output(cmd, shell=True, env=env,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\subprocess.py", line 466, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\subprocess.py", line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\subprocess.py", line 1024, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Python311\Lib\subprocess.py", line 1494, in _execute_child
raise FileNotFoundError('shell not found: neither %ComSpec% nor %SystemRoot% is set')
FileNotFoundError: shell not found: neither %ComSpec% nor %SystemRoot% is set
0:00:00.030999 Configuration Error: Could not include config file (c:/cerbero/config/windows.config)
SystemRoot
is properly set when executing the same code inside just the interpreter in either normal python or inside mingw.
PS C:\> C:\MinGW\msys\1.0\bin\bash.exe --login -c "python"
Python 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> from pprint import pprint
>>> def run_and_get_env(cmd):
... env = os.environ.copy()
... env['VSCMD_ARG_no_logo'] = '1'
... env['VSCMD_DEBUG'] = ''
... # Pass errors=ignore to ignore env vars with invalid encoding, such as
... # GITLAB_USER_NAME when the name of the user triggering the pipeline has
... # non-ascii characters.
... # The env vars set by MSVC will always be correctly encoded.
... output = subprocess.check_output(cmd, shell=True, env=env,
... universal_newlines=True,
... errors='ignore')
... lines = []
... for line in output.split('\n'):
... if '=' in line:
... lines.append(line)
... return lines
...
>>>
>>> without_msvc = run_and_get_env('set')
>>> pprint(without_msvc)
['ALLUSERSPROFILE=C:\\ProgramData',
'APPDATA=C:\\Users\\ContainerAdministrator\\AppData\\Roaming',
'CHOCOLATEYINSTALL=C:\\ProgramData\\chocolatey',
'CHOCOLATEYLASTPATHUPDATE=133250280503138950',
'COMMONPROGRAMFILES(X86)=C:\\Program Files (x86)\\Common Files',
'COMMONPROGRAMFILES=C:\\Program Files\\Common Files',
'COMMONPROGRAMW6432=C:\\Program Files\\Common Files',
'COMPUTERNAME=549C219136B5',
'COMSPEC=C:\\Windows\\system32\\cmd.exe',
'DRIVERDATA=C:\\Windows\\System32\\Drivers\\DriverData',
'ERRORACTIONPREFERENCE=Stop',
'GCM_VALIDATE=false',
'GIT_LFS_PATH=C:\\Program Files\\Git LFS',
'HOME=C:/MinGW/msys/1.0/home/ContainerAdministrator',
'LOCALAPPDATA=C:\\Users\\ContainerAdministrator\\AppData\\Local',
'LOGNAME=ContainerAdministrator',
'LOGONSERVER=\\\\549C219136B5',
'MAKE_MODE=unix',
'MSYSTEM=MINGW32',
'NUMBER_OF_PROCESSORS=32',
'OLDPWD=c:/',
'OS=Windows_NT',
'PATH=.;C:\\MinGW\\msys\\1.0\\local\\bin;C:\\MinGW\\bin;C:\\MinGW\\msys\\1.0\\bin;c:\\Python311\\Scripts\\;c:\\Python311\\;c:\\Windows\\system32;c:\\Windows;c:\\Windows\\System32\\Wbem;c:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;c:\\Windows\\System32\\OpenSSH\\;c:\\ProgramData\\chocolatey\\bin;c:\\Program '
'Files\\CMake\\bin;c:\\Program Files\\Git\\cmd;c:\\Program Files\\Git '
'LFS;c:\\Users\\ContainerAdministrator\\.cargo\\bin;c:\\Users\\ContainerAdministrator\\AppData\\Local\\Microsoft\\WindowsApps',
'PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW;.CPL',
'PROCESSOR_ARCHITECTURE=AMD64',
'PROCESSOR_IDENTIFIER=AMD64 Family 25 Model 1 Stepping 1, AuthenticAMD',
'PROCESSOR_LEVEL=25',
'PROCESSOR_REVISION=0101',
'PROGRAMDATA=C:\\ProgramData',
'PROGRAMFILES(X86)=C:\\Program Files (x86)',
'PROGRAMFILES=C:\\Program Files',
'PROGRAMW6432=C:\\Program Files',
'PROMPT=$P$G',
'PS1=\\[\\033]0;$MSYSTEM:\\w\\007',
'PSMODULEPATH=C:\\Users\\ContainerAdministrator\\Documents\\WindowsPowerShell\\Modules;C:\\Program '
'Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules',
'PUBLIC=C:\\Users\\Public',
'PWD=C:/MinGW/msys/1.0/home/ContainerAdministrator',
'SHLVL=1',
'SYSTEMDRIVE=C:',
'SYSTEMROOT=C:\\Windows',
'TEMP=C:/Users/ContainerAdministrator/AppData/Local/Temp',
'TERM=cygwin',
'TMP=C:/Users/ContainerAdministrator/AppData/Local/Temp',
'USERDOMAIN=User Manager',
'USERNAME=ContainerAdministrator',
'USERPROFILE=C:\\Users\\ContainerAdministrator',
'WINDIR=C:\\Windows',
'WIX=C:\\Program Files (x86)\\WiX Toolset v3.11\\',
'_=c:/Python311/python',
'VSCMD_ARG_no_logo=1',
'VSCMD_DEBUG=']
>>>
I think the place we'd reexport SystemRoot would be in windows.config
though from a quick look I am nor sure how or where does env
originate in the file.
Edited by Jordan Petridіs