summaryrefslogtreecommitdiffstats
path: root/academic/ViennaRNA/swig4.patch
blob: 88df2eb9330015d5ca1f9e4ccfa84ccf382aac4c (about) (plain) (blame)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
commit c8a867dc017f58a4ffbfb2d3d976506947e5d9d6
Author: Ronny Lorenz <ronny@tbi.univie.ac.at>
Date:   Mon May 13 08:22:42 2019 +0200

    SWIG: Fix install for wrappers generated by swig 4
    
    - We now default to install _RNA.*so files for Python2/3 into the RNA/
      subdirectory. This seems necessary to avoid problems when importing
      the RNA package, where the underlying loader changed from swig 3 to
      swig 4.
    - We also require swig 3.0.0 or later from now on to generate the
      wrapper code, and we drop the -modern flag

diff --git a/interfaces/Python/Makefile.am b/interfaces/Python/Makefile.am
index df279501..41be4c08 100644
--- a/interfaces/Python/Makefile.am
+++ b/interfaces/Python/Makefile.am
@@ -16,9 +16,8 @@ INTERFACE_FILES = $(SWIG_src) \
                   $(LANG_SPECIFIC_INTERFACE_FILES)
 
 pkgpy2execdir = $(py2execdir)/RNA
-pkgpy2cmoddir = $(py2execdir)
 
-pkgpy2cmod_LTLIBRARIES = _RNA.la
+pkgpy2exec_LTLIBRARIES = _RNA.la
 pkgpy2exec_DATA = RNA/__init__.py
 
 _RNA_la_SOURCES = $(INTERFACE_FILES) \
@@ -73,7 +72,7 @@ $(SWIG_wrapper): $(SWIG_src) $(INTERFACE_FILES)
 	$(swig_verbose)$(SWIG) -I$(top_srcdir)/src \
                   -I$(srcdir) -I$(builddir) \
                   $(RNA_CPPFLAGS) \
-                  -python -modern  -c++ \
+                  -python -c++ \
                   -o $(SWIG_wrapper) \
                   $(SWIG_main_src)
 
@@ -87,27 +86,33 @@ RNA/__init__.py: $(SWIG_module_name).py
 	$(AM_V_GEN)( test -d RNA || $(MKDIR_P) RNA ) && \
   cp `test -f RNA.py || echo '$(srcdir)/'`RNA.py RNA/__init__.py
 
-_RNA$(PYTHON2_SO): _RNA.la
-	$(AM_V_GEN)( $(LIBTOOL) --config > libtoolconfig.tmp ) && \
-  ( . ./libtoolconfig.tmp; cp $$objdir/_RNA$(PYTHON2_SO) . ) && \
+RNA/_RNA$(PYTHON2_SO): _RNA.la
+	$(AM_V_GEN)( test -d RNA || $(MKDIR_P) RNA ) && \
+  ( $(LIBTOOL) --config > libtoolconfig.tmp ) && \
+  ( . ./libtoolconfig.tmp; cp $$objdir/_RNA$(PYTHON2_SO) RNA ) && \
   rm -f libtoolconfig.tmp
 
-all-local:  _RNA$(PYTHON2_SO)
+CLEANFILES = \
+    RNA/_RNA$(PYTHON2_SO) \
+    RNA/__init__.py \
+    RNA/__init__.pyc
+
+all-local:  RNA/_RNA$(PYTHON2_SO)
 
 clean-local:
-	-rm -rf RNA _RNA$(PYTHON2_SO)
+	-rm -rf RNA
 
 # Remove the .la file - RNA.la is never linked against (it's a module)
 # and Python doesn't use libltdl.  Note that the library gets installed by
 # install-data, so that's where we need to hook.
 install-data-hook:
-	rm -f $(DESTDIR)$(pkgpy2cmoddir)/_RNA.la
+	rm -f $(DESTDIR)$(pkgpy2execdir)/_RNA.la
 
 # Because we don't install the .la file, "make uninstall" doesn't work and
 # we need to remove the file ourselves.
 uninstall-local:
-	eval `grep '^dlname=' $(pkgpy2cmod_LTLIBRARIES)` ; \
-	rm -f $(DESTDIR)$(pkgpy2cmoddir)/"$$dlname"
+	eval `grep '^dlname=' $(pkgpy2exec_LTLIBRARIES)` ; \
+	rm -f $(DESTDIR)$(pkgpy2execdir)/"$$dlname"
 
 ## remove all generated content
 maintainer-clean-local:
diff --git a/interfaces/Python3/Makefile.am b/interfaces/Python3/Makefile.am
index de9b049e..67824a99 100644
--- a/interfaces/Python3/Makefile.am
+++ b/interfaces/Python3/Makefile.am
@@ -17,10 +17,9 @@ INTERFACE_FILES = $(SWIG_src) \
                   $(LANG_SPECIFIC_INTERFACE_FILES)
 
 pkgpyexecdir = $(py3execdir)/RNA
-pkgpycmoddir = $(py3execdir)
 pkgpycachedir = $(pkgpyexecdir)/__pycache__
 
-pkgpycmod_LTLIBRARIES = _RNA.la
+pkgpyexec_LTLIBRARIES = _RNA.la
 pkgpyexec_DATA =  RNA/__init__.py
 pkgpycache_DATA = RNA/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc \
                   RNA/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@
@@ -75,7 +74,7 @@ $(SWIG_wrapper): $(SWIG_src) $(INTERFACE_FILES)
                   -I$(srcdir) -I$(builddir) \
                   -DPY3 \
                   $(RNA_CPPFLAGS) \
-                  -python -modern -py3 -c++ \
+                  -python -py3 -c++ \
                   -o $(SWIG_wrapper) \
                   $(SWIG_main_src)
 
@@ -91,42 +90,43 @@ RNA/__init__.py: $(SWIG_module_name).py
 
 # We "import _RNA" first so that if we fail to import the glue library
 # we don't generate a broken .pyc or .pyo.
-RNA/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc: RNA/__init__.py _RNA$(PYTHON3_SO)
+RNA/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc: RNA/__init__.py RNA/_RNA$(PYTHON3_SO)
 	$(AM_V_GEN)( PYTHONPATH="RNA:$$PYTHONPATH" $(PYTHON3) -c "import _RNA" ; \
   PYTHONPATH=".:$$PYTHONPATH" $(PYTHON3) -c "import RNA" )
 
-RNA/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@: RNA/__init__.py _RNA$(PYTHON3_SO)
+RNA/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@: RNA/__init__.py RNA/_RNA$(PYTHON3_SO)
 	$(AM_V_GEN)( PYTHONPATH="RNA:$$PYTHONPATH" $(PYTHON3) -O -c "import _RNA" ; \
   PYTHONPATH=".:$$PYTHONPATH" $(PYTHON3) -O -c "import RNA" )
 
-_RNA$(PYTHON3_SO): _RNA.la
-	$(AM_V_GEN)( $(LIBTOOL) --config > libtoolconfig.tmp ) && \
-  ( . ./libtoolconfig.tmp; cp $$objdir/_RNA$(PYTHON3_SO) . ) && \
+RNA/_RNA$(PYTHON3_SO): _RNA.la
+	$(AM_V_GEN)( test -d RNA || $(MKDIR_P) RNA ) && \
+  ( $(LIBTOOL) --config > libtoolconfig.tmp ) && \
+  ( . ./libtoolconfig.tmp; cp $$objdir/_RNA$(PYTHON3_SO) RNA ) && \
   rm -f libtoolconfig.tmp
 
 CLEANFILES = \
-    _RNA$(PYTHON3_SO) \
+    RNA/_RNA$(PYTHON3_SO) \
     RNA/__init__.py \
     RNA/__pycache__/__init__.@PYTHON3_CACHE_TAG@.pyc \
     RNA/__pycache__/__init__.@PYTHON3_CACHE_OPT1_EXT@\
     $(srcdir)/*.pyc
 
-all-local:  _RNA$(PYTHON3_SO)
+all-local:  RNA/_RNA$(PYTHON3_SO)
 
 clean-local:
-	-rm -rf RNA _RNA$(PYTHON3_SO)
+	-rm -rf RNA
 
 # Remove the .la file - RNA.la is never linked against (it's a module)
 # and Python doesn't use libltdl.  Note that the library gets installed by
 # install-data, so that's where we need to hook.
 install-data-hook:
-	rm -f $(DESTDIR)$(pkgpycmoddir)/_RNA.la
+	rm -f $(DESTDIR)$(pkgpyexecdir)/_RNA.la
 
 # Because we don't install the .la file, "make uninstall" doesn't work and
 # we need to remove the file ourselves.
 uninstall-local:
-	eval `grep '^dlname=' $(pkgpycmod_LTLIBRARIES)` ; \
-	rm -f $(DESTDIR)$(pkgpycmoddir)/"$$dlname"
+	eval `grep '^dlname=' $(pkgpyexec_LTLIBRARIES)` ; \
+	rm -f $(DESTDIR)$(pkgpyexecdir)/"$$dlname"
 
 ## remove all generated content
 maintainer-clean-local:
diff --git a/interfaces/RNA.i b/interfaces/RNA.i
index fb2260d6..6ae86641 100644
--- a/interfaces/RNA.i
+++ b/interfaces/RNA.i
@@ -1,4 +1,9 @@
+#ifdef SWIGPYTHON
+%module(moduleimport="from . import _RNA") RNA
+#else
 %module RNA
+#endif
+
 //%pragma(perl5)  modulecode="@EXPORT=qw(fold);"
 %pragma(perl5)  include="RNA.pod"
 
diff --git a/m4/ac_rna_swig.m4 b/m4/ac_rna_swig.m4
index 98583bed..29ea398f 100644
--- a/m4/ac_rna_swig.m4
+++ b/m4/ac_rna_swig.m4
@@ -9,13 +9,12 @@ AC_DEFUN([RNA_ENABLE_SWIG_INTERFACES],[
 
   AS_IF([test "x$with_swig" != "xno"],[
     wants_swig="yes"
-    AX_PKG_SWIG(2.0.0, [has_swig="yes"], [has_swig="no"])
+    AX_PKG_SWIG(3.0.0, [has_swig="yes"], [has_swig="no"])
   ],[
     wants_swig="no"
   ])
 
   AM_CONDITIONAL(HAS_SWIG, test "x$has_swig" != "xno")
-  
   RNA_ENABLE_SWIG_PERL
   RNA_ENABLE_SWIG_PYTHON
   RNA_ENABLE_SWIG_PYTHON3
@@ -55,10 +54,6 @@ AC_DEFUN([RNA_ENABLE_SWIG_PERL],[
       AC_MSG_ERROR([Perl is required to build.])
       [enable_perl_status="Perl is required to build."]
     fi
-#    AX_PERL_EXT_FLAGS([PERLXS_CFLAGS], [PERLXS_LDFLAGS])
-#    AX_PERL_EXT_LINK_CHECK([with_perl])
-#    AC_SUBST([PERLXS_CFLAGS])
-#    AC_SUBST([PERLXS_LDFLAGS])
   ])
 
   # prepare all files for perl interface