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.
This commit is contained in:
Philip Taron
2025-01-04 15:37:24 -08:00
parent 6f65a35a30
commit bde021ab43
2 changed files with 25 additions and 6 deletions
+4 -6
View File
@@ -3,10 +3,10 @@
fetchFromGitHub,
lib,
fetchpatch,
replaceVars,
cmake,
uthash,
pkg-config,
makeWrapper,
python3,
freetype,
zlib,
@@ -74,6 +74,9 @@ stdenv.mkDerivation rec {
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
@@ -91,7 +94,6 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [
pkg-config
cmake
makeWrapper
];
buildInputs =
@@ -131,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";
@@ -0,0 +1,21 @@
Author: Philip Taron <philip.taron@gmail.com>
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)) {