# Patch GNAT Studio to find and use the existing Python installation # relative to the IDE executable. # # Since the commit https://github.com/AdaCore/gnatstudio/commit/2b886cac44425d91e26c93f2d2cfcc993467662c, # GNAT Studio expects Python to be in $GNATSTUDIO_PYTHONHOME, # which defaults to "$exec_prefix/share/gnatstudio/python". # # If Python is not found under this path, GNAT Studio crashes # with logs similar to the following: # # PYTHONHOME = '/mingw64/share/gnatstudio/python' # PYTHONPATH = '\mingw64\share\gnatstudio\python' # ... # Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding # Python runtime state: core initialized # ModuleNotFoundError: No module named 'encodings' # # AUR works around this by creating a symlink `/usr/share/gnatstudio/python` # which points to `/usr` (https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=gnatstudio&id=a031c734c1efd5bb4069f47b70a83dde8f04a1ab#n108). # However, symbolic links in packages are discouraged in MSYS2. # # Instead, we patch the source code of GNAT Studio to change the default value # of $GNATSTUDIO_PYTHONHOME. Hackers and IDE plugin developers can still override # this environment variable to run GNAT Studio with an alternative Python location. # --- a/python/core/gps-python_core.adb +++ b/python/core/gps-python_core.adb @@ -43,8 +43,7 @@ package body GPS.Python_Core is if Python_Home.Is_Empty then declare Packaged_Python_Location : constant Virtual_File := - Create (+Executable_Location) - / (+"share") / (+"gnatstudio") / (+"python"); + Create (+Executable_Location); begin Register_Python_Scripting (Kernel.Scripts,