Skip to content
Snippets Groups Projects
Commit 9f08091d authored by Sergey Kosukhin's avatar Sergey Kosukhin
Browse files

Build Python extension as a separate module

parent e63264e5
No related branches found
No related tags found
1 merge request!43Update python build
......@@ -68,6 +68,7 @@ libtool
/**/examples/test_dace
/**/examples/test_jd_logic
/**/examples/uniq
/**/python/mtime/.dirstamp
__pycache__/
# Documentation stage files
......
......@@ -37,9 +37,9 @@ AS_VAR_IF([ac_cv_prog_cc_c99], [no],
AC_PROG_FC
ACX_USE_LIBTOOL_CONFIGURATION([pic-only])
dnl Get extension of the dynamic libraries from Libtool:
{ module=no; eval acx_shrext=\"$shrext_cmds\"; unset module;}
AC_SUBST([acx_shrext])dnl
dnl Get extension of a dynamically loaded module file from Libtool:
{ module=yes; eval acx_modext=\"$shrext_cmds\"; unset module;}
AC_SUBST([acx_modext])dnl
AC_LANG_PUSH([Fortran])
dnl Automake does not trace AC_FC_PP_SRCEXT/ACX_FC_PP_SRCEXT and therefore
......@@ -74,12 +74,12 @@ AC_ARG_ENABLE([python],
[AS_HELP_STRING([--enable-python],
[enable the Python interface @<:@default=auto@:>@])], [],
[enable_python=auto])
AS_VAR_IF([enable_shared], [no],
AS_IF([test "x$enable_shared" = xno || test "x$with_pic" = xno],
[AS_CASE([$enable_python],
[auto], [enable_python=no],
[no], [],
[AC_MSG_ERROR([cannot provide the Python interface when the shared libraries dnl
are disabled])])])
or PIC objects are disabled])])])
AC_ARG_ENABLE([check],
[AS_HELP_STRING([--enable-check],
......@@ -157,7 +157,7 @@ AC_CONFIG_FILES([
test/test_python.sh
], [chmod a+x "$ac_file"])
AS_VAR_IF([enable_shared], [yes],
AS_VAR_IF([enable_python], [yes],
[AC_CONFIG_LINKS([
python/mtime/__init__.py:python/mtime/__init__.py
python/mtime/libmtime.py:python/mtime/libmtime.py
......
......@@ -6,9 +6,22 @@ install_tmpdir = mtime/.install
pkgpython_PYTHON = mtime/__init__.py
nodist_pkgpython_PYTHON = $(install_tmpdir)/libmtime.py
pkgpyexec_LTLIBRARIES = mtime/mtime.la
mtime_mtime_la_SOURCES =
mtime_mtime_la_LDFLAGS = -shared -avoid-version -module
mtime_mtime_la_LIBADD = $(top_builddir)/src/libmtime_c.la
$(install_tmpdir)/libmtime.py: mtime/libmtime.py
$(MKDIR_P) $(@D) && sed "s,^SOFILE = None$$,SOFILE = '$(DESTDIR)$(libdir)/libmtime$(acx_shrext)'," $< >$@
$(MKDIR_P) $(@D) && sed "s,^SOFILE = None$$,SOFILE = '$(DESTDIR)$(pkgpyexecdir)/mtime$(acx_modext)'," $< >$@
install-data-hook:
rm -rf $(install_tmpdir)
# overrides to make regular compilations also use libtool
COMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) -static $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
FCCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=FC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(FC) -static $(AM_FCFLAGS) $(FCFLAGS)
......@@ -34,20 +34,15 @@ if SOFILE is None:
import os
import sys
if sys.platform == "darwin":
SOFILE = ".dylib"
elif sys.platform == "win32":
if sys.platform == "win32":
SOFILE = ".dll"
else:
SOFILE = ".so"
SOFILE = os.path.join(
os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
),
"src",
os.path.dirname(os.path.abspath(__file__)),
".libs",
"libmtime{0}".format(SOFILE),
"mtime{0}".format(SOFILE),
)
libmtime = cdll.LoadLibrary(SOFILE)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment