commit c8a867dc017f58a4ffbfb2d3d976506947e5d9d6 Author: Ronny Lorenz 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