diff --git a/pkgs/by-name/fo/fontforge/package.nix b/pkgs/by-name/fo/fontforge/package.nix index e52b1ec8c9c1..efe02f87dfcb 100644 --- a/pkgs/by-name/fo/fontforge/package.nix +++ b/pkgs/by-name/fo/fontforge/package.nix @@ -3,10 +3,10 @@ fetchFromGitHub, lib, fetchpatch, + replaceVars, cmake, uthash, pkg-config, - makeWrapper, python3, freetype, zlib, @@ -52,14 +52,31 @@ stdenv.mkDerivation rec { url = "https://github.com/fontforge/fontforge/commit/216eb14b558df344b206bf82e2bdaf03a1f2f429.patch"; hash = "sha256-aRnir09FSQMT50keoB7z6AyhWAVBxjSQsTRvBzeBuHU="; }) - # Fixes translation compatibility with gettext 0.22 + + # Replace distutils use in the build script (fetchpatch { - url = "https://github.com/fontforge/fontforge/commit/55d58f87ab1440f628f2071a6f6cc7ef9626c641.patch"; - hash = "sha256-rkYnKPXA8Ztvh9g0zjG2yTUCPd3lE1uqwvBuEd8+Oyw="; + name = "replace-distutils.patch"; + url = "https://github.com/fontforge/fontforge/commit/8c75293e924602ed09a9481b0eeb67ba6c623a81.patch"; + includes = [ "pyhook/CMakeLists.txt" ]; + hash = "sha256-3CEwC8vygmCztKRmeD45aZIqyoj8yk5CLwxX2SGP7z4="; }) - # https://github.com/fontforge/fontforge/pull/5423 - ./replace-distutils.patch + # Fixes translation compatibility with gettext 0.22 + (fetchpatch { + name = "update-translation-compatibility.patch"; + url = "https://github.com/fontforge/fontforge/commit/642d8a3db6d4bc0e70b429622fdf01ecb09c4c10.patch"; + hash = "sha256-uO9uEhB64hkVa6O2tJKE8BLFR96m27d8NEN9UikNcvg="; + }) + + # Updates to new Python initialization API + (fetchpatch { + name = "modern-python-initialization-api.patch"; + url = "https://github.com/fontforge/fontforge/commit/2f2ba54c15c5565acbde04eb6608868cbc871e01.patch"; + hash = "sha256-qF4DqFpiZDbULi9+POPM73HF6pEot8BAFSVaVCNQrMU="; + }) + + # Provide a Nix-controlled location for the initial `sys.path` entry. + (replaceVars ./set-python-sys-path.patch { python = "${py}/${py.sitePackages}"; }) ]; # use $SOURCE_DATE_EPOCH instead of non-deterministic timestamps @@ -77,7 +94,6 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ pkg-config cmake - makeWrapper ]; buildInputs = @@ -117,10 +133,6 @@ stdenv.mkDerivation rec { export SOURCE_DATE_EPOCH=$(date -d ${version} +%s) ''; - postInstall = lib.optionalString withPython '' - wrapProgram $out/bin/fontforge --suffix PYTHONPATH : "${py}/${py.sitePackages}" - ''; - meta = { description = "Font editor"; homepage = "https://fontforge.github.io"; diff --git a/pkgs/by-name/fo/fontforge/replace-distutils.patch b/pkgs/by-name/fo/fontforge/replace-distutils.patch deleted file mode 100644 index 99087c649021..000000000000 --- a/pkgs/by-name/fo/fontforge/replace-distutils.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/pyhook/CMakeLists.txt b/pyhook/CMakeLists.txt -index dd48054aa..710728f26 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; print(sysconfig.get_path('platlib', sysconfig.get_preferred_scheme('user'), vars={'userbase': '.'}))" - RESULT_VARIABLE _pyhook_install_dir_result - OUTPUT_VARIABLE PYHOOK_INSTALL_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) diff --git a/pkgs/by-name/fo/fontforge/set-python-sys-path.patch b/pkgs/by-name/fo/fontforge/set-python-sys-path.patch new file mode 100644 index 000000000000..22b7057e9ac3 --- /dev/null +++ b/pkgs/by-name/fo/fontforge/set-python-sys-path.patch @@ -0,0 +1,21 @@ +Author: Philip Taron +Date: Sat Jan 4 12:22:38 2025 -0800 + + fontforge: add an initial value for `sys.path` + +diff --git a/fontforge/python.c b/fontforge/python.c +index e18d77d43..2e312eeb4 100644 +--- a/fontforge/python.c ++++ b/fontforge/python.c +@@ -19576,6 +19576,11 @@ void FontForge_InitializeEmbeddedPython(void) { + PyStatus status; + PyConfig_InitPythonConfig(&config); + ++ status = PyConfig_SetBytesString(&config, &config.pythonpath_env, "@python@"); ++ if (PyStatus_Exception(status)) { ++ fprintf(stderr, "Failed to set the Python search path: %s\n", status.err_msg); ++ } ++ + status = PyConfig_SetBytesString(&config, &config.program_name, + "fontforge"); + if (PyStatus_Exception(status)) {