# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/fontforge/hotfix-distutils.patch # Copyright (C) 2024 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License version 2 as used by the T2 SDE. # --- T2-COPYRIGHT-NOTE-END --- From 24968a8bf713396bc4a5dbb8bf3a03a9479b2568 Mon Sep 17 00:00:00 2001 From: Maxim Iorsh Date: Fri, 24 May 2024 16:48:47 +0300 Subject: [PATCH 1/3] Use sysconfig for Python module locations diff --git a/.github/workflows/scripts/ffosxbuild.sh b/.github/workflows/scripts/ffosxbuild.sh index 6476ec0f0f..0da3c2944c 100755 --- a/.github/workflows/scripts/ffosxbuild.sh +++ b/.github/workflows/scripts/ffosxbuild.sh @@ -32,6 +32,12 @@ fi # Now we bundle the Python libraries echo "Bundling Python libraries..." +# MacOS runner has way too much preinstalled Python versions. We must +# use the exact one discovered by CMake. +# The CMake_Python3_EXECUTABLE file resides in build/CMake_Python3_EXECUTABLE +PYTHON_EXE=`cat ../CMake_Python3_EXECUTABLE` +PY_DLLS_PATH=`$PYTHON_EXE -c "import sysconfig as sc; print(sc.get_path('platlib', sc.get_preferred_scheme('user'), vars={'userbase': '.'}))"` + PYLIB=$(otool -L $APPDIR/Contents/Resources/opt/local/bin/fontforge | grep -i python | sed -e 's/ \(.*\)//') PYVER=$(echo $PYLIB | rev | cut -d/ -f2 | rev) PYTHON=python$PYVER @@ -42,10 +48,10 @@ mkdir -p $APPDIR/Contents/Frameworks cp -a $pycruft/Python.framework $APPDIR/Contents/Frameworks pushd $APPDIR/Contents/Frameworks/Python.framework/Versions/$PYVER/lib/$PYTHON/ rm site-packages || rm -rf site-packages -ln -s ../../../../../../Resources/opt/local/lib/$PYTHON/site-packages +ln -s ../../../../../../Resources/opt/local/$PY_DLLS_PATH popd -pushd $APPDIR/Contents/Resources/opt/local/lib/$PYTHON/site-packages +pushd $APPDIR/Contents/Resources/opt/local/$PY_DLLS_PATH cp -Rn "$pycruft/Python.framework/Versions/$PYVER/lib/$PYTHON/site-packages/" . popd diff --git a/.github/workflows/scripts/setup_linux_deps.sh b/.github/workflows/scripts/setup_linux_deps.sh index d31f795327..6d82cc4c51 100755 --- a/.github/workflows/scripts/setup_linux_deps.sh +++ b/.github/workflows/scripts/setup_linux_deps.sh @@ -17,7 +17,7 @@ echo "DEPSPREFIX=$DEPSPREFIX" >> $GITHUB_ENV echo "PATH=$PATH:$DEPSPREFIX/bin:$PREFIX/bin:~/.local/bin" >> $GITHUB_ENV echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DEPSPREFIX/lib:$PREFIX/lib" >> $GITHUB_ENV echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$DEPSPREFIX/lib/pkgconfig" >> $GITHUB_ENV -echo "PYTHONPATH=$PYTHONPATH:$PREFIX/$($PYTHON -c "import distutils.sysconfig as sc; print(sc.get_python_lib(prefix='', plat_specific=True,standard_lib=False))")" >> $GITHUB_ENV +echo "PYTHONPATH=$PYTHONPATH:$PREFIX/$($PYTHON -c "import sysconfig as sc; print(sc.get_path('platlib', sc.get_preferred_scheme('user'), vars={'userbase': '.'}))")" >> $GITHUB_ENV if [ ! -d deps/install ]; then echo "Custom dependencies not present - will build them" diff --git a/pyhook/CMakeLists.txt b/pyhook/CMakeLists.txt index dd48054aa7..1fc258a521 100644 --- a/pyhook/CMakeLists.txt +++ b/pyhook/CMakeLists.txt @@ -21,7 +21,7 @@ target_link_libraries(psMat_pyhook PRIVATE Python3::Module) # So do it ourselves, getting the prefix-relative path instead if(NOT DEFINED PYHOOK_INSTALL_DIR) execute_process( - COMMAND "${Python3_EXECUTABLE}" -c "import distutils.sysconfig as sc; print(sc.get_python_lib(prefix='', plat_specific=True,standard_lib=False))" + COMMAND "${Python3_EXECUTABLE}" -c "import sysconfig as sc; print(sc.get_path('platlib', sc.get_preferred_scheme('user'), vars={'userbase': '.'}))" RESULT_VARIABLE _pyhook_install_dir_result OUTPUT_VARIABLE PYHOOK_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) From a7d6c2571ee441fa8ec890e5347cce46d4415aea Mon Sep 17 00:00:00 2001 From: Maxim Iorsh Date: Fri, 24 May 2024 16:49:37 +0300 Subject: [PATCH 2/3] [TEMP] Use iorsh/fontforgebuilds repo --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2be70e1865..62d389e9a7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -130,7 +130,8 @@ jobs: - name: Checkout FontForgeBuilds uses: actions/checkout@v3 with: - repository: fontforge/fontforgebuilds + repository: iorsh/fontforgebuilds + ref: py_sysconfig path: fontforgebuilds - name: Setup MSYS2 uses: msys2/setup-msys2@v2