File: 0011-Fix-sys.path-to-load-the-shared-libs.patch

package info (click to toggle)
bornagain 23.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,936 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (34 lines) | stat: -rw-r--r-- 1,387 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From: Roland Mas <lolando@debian.org>
Date: Tue, 13 Aug 2024 22:15:43 +0200
Subject: Fix sys.path to load the shared libs

---
 Wrap/Python/src/bornagain/lib/__init__.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Wrap/Python/src/bornagain/lib/__init__.py b/Wrap/Python/src/bornagain/lib/__init__.py
index 36dd4e0..179a7bf 100644
--- a/Wrap/Python/src/bornagain/lib/__init__.py
+++ b/Wrap/Python/src/bornagain/lib/__init__.py
@@ -12,14 +12,19 @@
 #  **************************************************************************  #
 
 import sys, os
+import sysconfig
 
 # NOTE: Adding the path to Python path is required for the automatically-built SWIG wrappers
 BA_LIBPATH = os.path.dirname(__file__)  # BornAgain shared libs
-BA_EXTRALIBPATH = os.path.join(BA_LIBPATH, 'extra')  # Extra dependencies
+BA_EXTRALIBPATH = os.path.join(BA_LIBPATH, "extra")  # Extra dependencies
 
 sys.path.append(BA_LIBPATH)
 sys.path.append(BA_EXTRALIBPATH)
-if sys.platform == 'win32':
+sys.path.append(os.path.join(sysconfig.get_config_var("LIBDIR"), "bornagain"))
+
+# this is needed to adapt to the changes in Python 3.8 on Windows regarding dll loading
+# see https://docs.python.org/3/whatsnew/3.8.html#ctypes
+if sys.platform == "win32" and sys.version_info >= (3, 8, 0):
     os.add_dll_directory(BA_EXTRALIBPATH)
 
 # import all available BornAgain functionality