tools: Ensure python3 in-build symlinking does not run on Windows

This commit is contained in:
Bruno Lopes 2026-03-20 22:51:15 -03:00
parent 92a860d5c9
commit e83eef67a9

View file

@ -44,20 +44,21 @@ try:
#Ensure the same python from meson.build (GIMP_PYTHON_WITH_GI) is used by plugins
#This is needed because GIMP_PYTHON_WITH_GI can not coincide with python3 from shebang
#(on MacPorts, there is no python3 symlink, so we would misuse Xcode python3 without GI)
python_symlink = shutil.which("python3")
pygobject_found=False
different_python=False
if python_symlink and not os.path.samefile(python_symlink, os.environ.get("GIMP_PYTHON_WITH_GI")):
result = subprocess.run([python_symlink,"-c","import sys, gi; version='3.0'; sys.exit(gi.check_version(version))"], check=False)
pygobject_found = (result.returncode == 0)
if not python_symlink or (python_symlink and not pygobject_found):
different_python=True
tmp_path = os.path.join(GIMP3_DIRECTORY, "tmp_python")
os.makedirs(tmp_path, exist_ok=True)
tmp_symlink = os.path.join(tmp_path, "python3")
if not os.path.exists(tmp_symlink):
os.symlink(os.environ.get("GIMP_PYTHON_WITH_GI"), tmp_symlink)
os.environ["PATH"] = tmp_path + os.pathsep + os.environ.get("PATH", "")
if sys.platform not in ['win32', 'cygwin']:
python_symlink = shutil.which("python3")
pygobject_found=False
different_python=False
if python_symlink and not os.path.samefile(python_symlink, os.environ.get("GIMP_PYTHON_WITH_GI")):
result = subprocess.run([python_symlink,"-c","import sys, gi; version='3.0'; sys.exit(gi.check_version(version))"], check=False)
pygobject_found = (result.returncode == 0)
if not python_symlink or (python_symlink and not pygobject_found):
different_python=True
tmp_path = os.path.join(GIMP3_DIRECTORY, "tmp_python")
os.makedirs(tmp_path, exist_ok=True)
tmp_symlink = os.path.join(tmp_path, "python3")
if not os.path.exists(tmp_symlink):
os.symlink(os.environ.get("GIMP_PYTHON_WITH_GI"), tmp_symlink)
os.environ["PATH"] = tmp_path + os.pathsep + os.environ.get("PATH", "")
if "GIMP_DEBUG_SELF" in os.environ and shutil.which("gdb"):
print(f"RUNNING: gdb --batch -x {os.environ['GIMP_GLOBAL_SOURCE_ROOT']}/tools/debug-in-build-gimp.py --args {os.environ['GIMP_SELF_IN_BUILD']} {' '.join(sys.argv[1:])}")