File: petsc_soname_extensions.patch

package info (click to toggle)
petsc4py 3.23.1-1exp2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 3,448 kB
  • sloc: python: 12,503; ansic: 1,697; makefile: 343; f90: 313; sh: 14
file content (64 lines) | stat: -rw-r--r-- 3,117 bytes parent folder | download | duplicates (3)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Author: Drew Parsons <dparsons@debian.org>
Forwarded: not-needed
Description: teach the wrap-swig demo to use PETSC_LIB_EXT, enabling use with petsc64.

Applies also to wrap-cython, but the same trick doesn't fix wrap-f2py

Index: petsc4py/demo/legacy/wrap-swig/setup.py
===================================================================
--- petsc4py.orig/demo/legacy/wrap-swig/setup.py	2023-01-08 20:28:44.754798414 +0100
+++ petsc4py/demo/legacy/wrap-swig/setup.py	2023-01-08 20:28:44.750798381 +0100
@@ -24,7 +24,15 @@
     import os
     PETSC_DIR  = os.environ['PETSC_DIR']
     PETSC_ARCH = os.environ.get('PETSC_ARCH', '')
+    PETSC_LIB_EXT = os.environ.get('PETSC_LIB_EXT', '')
     from os.path import join, isdir
+    if not PETSC_LIB_EXT:
+        from configparser import ConfigParser
+        parser = ConfigParser()
+        petscvariables = join(PETSC_DIR, PETSC_ARCH, 'lib/petsc/conf/petscvariables')
+        with open(petscvariables) as stream: # waiting for https://github.com/python/cpython/pull/2735 to avoid this step
+            parser.read_string("[petscvariables]\n" + stream.read())
+        PETSC_LIB_EXT = parser['petscvariables'].get('PETSC_LIB_EXT','')
     if PETSC_ARCH and isdir(join(PETSC_DIR, PETSC_ARCH)):
         INCLUDE_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'include'),
                          join(PETSC_DIR, 'include')]
@@ -36,6 +44,8 @@
     LIBRARIES += [#'petscts', 'petscsnes', 'petscksp',
                   #'petscdm', 'petscmat',  'petscvec',
                   'petsc']
+    if PETSC_LIB_EXT:
+        LIBRARIES = [lib+PETSC_LIB_EXT for lib in LIBRARIES]
 
     # PETSc for Python
     import petsc4py
Index: petsc4py/demo/legacy/wrap-cython/setup.py
===================================================================
--- petsc4py.orig/demo/legacy/wrap-cython/setup.py	2021-04-19 22:57:36.065972153 +0200
+++ petsc4py/demo/legacy/wrap-cython/setup.py	2023-01-08 20:30:26.899626904 +0100
@@ -18,7 +18,15 @@
     import os
     PETSC_DIR  = os.environ['PETSC_DIR']
     PETSC_ARCH = os.environ.get('PETSC_ARCH', '')
+    PETSC_LIB_EXT = os.environ.get('PETSC_LIB_EXT', '')
     from os.path import join, isdir
+    if not PETSC_LIB_EXT:
+        from configparser import ConfigParser
+        parser = ConfigParser()
+        petscvariables = join(PETSC_DIR, PETSC_ARCH, 'lib/petsc/conf/petscvariables')
+        with open(petscvariables) as stream: # waiting for https://github.com/python/cpython/pull/2735 to avoid this step
+            parser.read_string("[petscvariables]\n" + stream.read())
+        PETSC_LIB_EXT = parser['petscvariables'].get('PETSC_LIB_EXT','')
     if PETSC_ARCH and isdir(join(PETSC_DIR, PETSC_ARCH)):
         INCLUDE_DIRS += [join(PETSC_DIR, PETSC_ARCH, 'include'),
                          join(PETSC_DIR, 'include')]
@@ -27,7 +35,7 @@
         if PETSC_ARCH: pass # XXX should warn ...
         INCLUDE_DIRS += [join(PETSC_DIR, 'include')]
         LIBRARY_DIRS += [join(PETSC_DIR, 'lib')]
-    LIBRARIES += ['petsc']
+    LIBRARIES += ['petsc'+PETSC_LIB_EXT]
 
     # PETSc for Python
     INCLUDE_DIRS += [petsc4py.get_include()]