vuls: init at 0.27.0 (#348530)
[NixPkgs.git] / pkgs / by-name / fr / freecad / 0001-NIXOS-don-t-ignore-PYTHONPATH.patch
blob185d6effa25ef643c32026bd7bf2d31c6650d31e
1 commit c534a831c2f7186ebabe4e17f1e1df6d11ebff89
2 Author: Samuel Rounce <me@samuelrounce.co.uk>
3 Date: Thu Sep 5 22:17:21 2024 +0100
5 [PATCH] NIXOS: don't ignore PYTHONPATH
7 On NixOS or rather within nixpkgs we provide the runtime Python
8 packages via the PYTHONPATH environment variable. FreeCAD tries its
9 best to ignore Python environment variables that are being inherited
10 from the environment. For Python versions >=3.11 it also tries to
11 initialize the interpreter config without any environmental data. We
12 have to initialize the configuration *with* the information from the
13 environment for our packaging to work.
15 Upstream has purposely isolated the environments AFAIK and thus
16 shouldn't accept this patch (as is). What they might accept (once
17 support for older Python versions has been dropped) is removing the
18 PYTHONPATH specific putenv calls.
19 ---
20 src/Base/Interpreter.cpp | 1 +
21 src/Main/MainGui.cpp | 3 ---
22 2 files changed, 1 insertion(+), 3 deletions(-)
24 diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp
25 index 2bdc54ccff..ee4f7fc070 100644
26 --- a/src/Base/Interpreter.cpp
27 +++ b/src/Base/Interpreter.cpp
28 @@ -593,6 +593,7 @@ void initInterpreter(int argc, char* argv[])
29 PyConfig config;
30 PyConfig_InitIsolatedConfig(&config);
31 config.isolated = 0;
32 + config.use_environment = 1;
33 config.user_site_directory = 1;
35 status = PyConfig_SetBytesArgv(&config, argc, argv);
36 diff --git a/src/Main/MainGui.cpp b/src/Main/MainGui.cpp
37 index 36087cffd6..89d49d2cc6 100644
38 --- a/src/Main/MainGui.cpp
39 +++ b/src/Main/MainGui.cpp
40 @@ -114,10 +114,8 @@ int main(int argc, char** argv)
41 // See https://forum.freecad.org/viewtopic.php?f=18&t=20600
42 // See Gui::Application::runApplication()
43 putenv("LC_NUMERIC=C");
44 - putenv("PYTHONPATH=");
45 #elif defined(FC_OS_MACOSX)
46 (void)QLocale::system();
47 - putenv("PYTHONPATH=");
48 #elif defined(__MINGW32__)
49 const char* mingw_prefix = getenv("MINGW_PREFIX");
50 const char* py_home = getenv("PYTHONHOME");
51 @@ -125,7 +123,6 @@ int main(int argc, char** argv)
52 _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");