fontforge: add an initial value for sys.path inside fontforge, rather than using a wrapper

Using a wrapper causes build failures on Darwin for some derivations like `dejavu-fonts`, and we don't need to do it.

+25 -6
+4 -6
pkgs/by-name/fo/fontforge/package.nix
··· 3 3 fetchFromGitHub, 4 4 lib, 5 5 fetchpatch, 6 + replaceVars, 6 7 cmake, 7 8 uthash, 8 9 pkg-config, 9 - makeWrapper, 10 10 python3, 11 11 freetype, 12 12 zlib, ··· 74 74 url = "https://github.com/fontforge/fontforge/commit/2f2ba54c15c5565acbde04eb6608868cbc871e01.patch"; 75 75 hash = "sha256-qF4DqFpiZDbULi9+POPM73HF6pEot8BAFSVaVCNQrMU="; 76 76 }) 77 + 78 + # Provide a Nix-controlled location for the initial `sys.path` entry. 79 + (replaceVars ./set-python-sys-path.patch { python = "${py}/${py.sitePackages}"; }) 77 80 ]; 78 81 79 82 # use $SOURCE_DATE_EPOCH instead of non-deterministic timestamps ··· 91 94 nativeBuildInputs = [ 92 95 pkg-config 93 96 cmake 94 - makeWrapper 95 97 ]; 96 98 97 99 buildInputs = ··· 129 131 preConfigure = '' 130 132 # The way $version propagates to $version of .pe-scripts (https://github.com/dejavu-fonts/dejavu-fonts/blob/358190f/scripts/generate.pe#L19) 131 133 export SOURCE_DATE_EPOCH=$(date -d ${version} +%s) 132 - ''; 133 - 134 - postInstall = lib.optionalString withPython '' 135 - wrapProgram $out/bin/fontforge --suffix PYTHONPATH : "${py}/${py.sitePackages}" 136 134 ''; 137 135 138 136 meta = {
+21
pkgs/by-name/fo/fontforge/set-python-sys-path.patch
··· 1 + Author: Philip Taron <philip.taron@gmail.com> 2 + Date: Sat Jan 4 12:22:38 2025 -0800 3 + 4 + fontforge: add an initial value for `sys.path` 5 + 6 + diff --git a/fontforge/python.c b/fontforge/python.c 7 + index e18d77d43..2e312eeb4 100644 8 + --- a/fontforge/python.c 9 + +++ b/fontforge/python.c 10 + @@ -19576,6 +19576,11 @@ void FontForge_InitializeEmbeddedPython(void) { 11 + PyStatus status; 12 + PyConfig_InitPythonConfig(&config); 13 + 14 + + status = PyConfig_SetBytesString(&config, &config.pythonpath_env, "@python@"); 15 + + if (PyStatus_Exception(status)) { 16 + + fprintf(stderr, "Failed to set the Python search path: %s\n", status.err_msg); 17 + + } 18 + + 19 + status = PyConfig_SetBytesString(&config, &config.program_name, 20 + "fontforge"); 21 + if (PyStatus_Exception(status)) {