Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / graphics / freecad / 0001-NIXOS-don-t-ignore-PYTHONPATH.patch
blob27e5fb81b8d074b9f267cda342409d146fe62f0a
1 From c4f452ef6ae083ed21095313582f6d1bd775cbf3 Mon Sep 17 00:00:00 2001
2 From: Andreas Rammhold <andreas@rammhold.de>
3 Date: Thu, 2 Nov 2023 17:32:07 +0100
4 Subject: [PATCH] NIXOS: don't ignore PYTHONPATH
6 On NixOS or rather within nixpkgs we provide the runtime Python
7 packages via the PYTHONPATH environment variable. FreeCAD tries its
8 best to ignore Python environment variables that are being inherited
9 from the environment. For Python versions >=3.11 it also tries to
10 initialize the interpreter config without any environmental data. We
11 have to initialize the configuration *with* the information from the
12 environment for our packaging to work.
14 Upstream has purposely isolated the environments AFAIK and thus
15 shouldn't accept this patch (as is). What they might accept (once
16 support for older Python versions has been dropped) is removing the
17 PYTHONPATH specific putenv calls.
18 ---
19 src/Base/Interpreter.cpp | 2 +-
20 src/Main/MainGui.cpp | 3 ---
21 2 files changed, 1 insertion(+), 4 deletions(-)
23 diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp
24 index 52c47168af..9966bd0013 100644
25 --- a/src/Base/Interpreter.cpp
26 +++ b/src/Base/Interpreter.cpp
27 @@ -554,7 +554,9 @@ void initInterpreter(int argc,char *argv[])
29 PyStatus status;
30 PyConfig config;
31 PyConfig_InitIsolatedConfig(&config);
32 + config.isolated = 0;
33 + config.use_environment = 1;
35 status = PyConfig_SetBytesArgv(&config, argc, argv);
36 if (PyStatus_Exception(status)) {
37 diff --git a/src/Main/MainGui.cpp b/src/Main/MainGui.cpp
38 index 48ae847ef4..28813df383 100644
39 --- a/src/Main/MainGui.cpp
40 +++ b/src/Main/MainGui.cpp
41 @@ -112,17 +112,14 @@ int main( int argc, char ** argv )
42 // See https://forum.freecad.org/viewtopic.php?f=18&t=20600
43 // See Gui::Application::runApplication()
44 putenv("LC_NUMERIC=C");
45 - putenv("PYTHONPATH=");
46 #elif defined(FC_OS_MACOSX)
47 (void)QLocale::system();
48 - putenv("PYTHONPATH=");
49 #elif defined(__MINGW32__)
50 const char* mingw_prefix = getenv("MINGW_PREFIX");
51 const char* py_home = getenv("PYTHONHOME");
52 if (!py_home && mingw_prefix)
53 _putenv_s("PYTHONHOME", mingw_prefix);
54 #else
55 - _putenv("PYTHONPATH=");
56 // https://forum.freecad.org/viewtopic.php?f=4&t=18288
57 // https://forum.freecad.org/viewtopic.php?f=3&t=20515
58 const char* fc_py_home = getenv("FC_PYTHONHOME");
59 --
60 2.42.0