diff options
Diffstat (limited to 'Examples/python/import_packages/split_modules')
11 files changed, 133 insertions, 0 deletions
diff --git a/Examples/python/import_packages/split_modules/Makefile b/Examples/python/import_packages/split_modules/Makefile new file mode 100644 index 000000000..65d635bb7 --- /dev/null +++ b/Examples/python/import_packages/split_modules/Makefile @@ -0,0 +1,26 @@ +TOP = ../../.. +LIBS = + +subdirs = vanilla vanilla_split + + +check: build + for s in $(subdirs); do \ + (cd $$s && $(MAKE) check); \ + done + +build: + for s in $(subdirs); do \ + (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build); \ + done + +static: + for s in $(subdirs); do \ + (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static); \ + done + +clean: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean + for s in $(subdirs); do \ + (cd $$s && $(MAKE) clean); \ + done diff --git a/Examples/python/import_packages/split_modules/README b/Examples/python/import_packages/split_modules/README new file mode 100644 index 000000000..0cb543e8a --- /dev/null +++ b/Examples/python/import_packages/split_modules/README @@ -0,0 +1,7 @@ + These examples/tests are for when the SWIG generated wrapper module is split +between two packages. Specifically the pure python part is part of a package +and the C/C++ part is not in any package at all. Historically SWIG has +supported this sort of thing. + +vanilla # "plane Jane" module both halves in pkg1 +vanilla_split # python 1/2 in pkg1 C 1/2 in global namespace diff --git a/Examples/python/import_packages/split_modules/vanilla/Makefile b/Examples/python/import_packages/split_modules/vanilla/Makefile new file mode 100644 index 000000000..b679d60a0 --- /dev/null +++ b/Examples/python/import_packages/split_modules/vanilla/Makefile @@ -0,0 +1,18 @@ +TOP = ../../../.. +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib +SWIGOPT = +LIBS = + +check: build + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run + +build: + cd pkg1 && $(MAKE) build + +static: + cd pkg1 && $(MAKE) static + +clean: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean + cd pkg1 && $(MAKE) -f $(TOP)/../Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/split_modules/vanilla/pkg1/Makefile b/Examples/python/import_packages/split_modules/vanilla/pkg1/Makefile new file mode 100644 index 000000000..921bb9951 --- /dev/null +++ b/Examples/python/import_packages/split_modules/vanilla/pkg1/Makefile @@ -0,0 +1,18 @@ +TOP = ../../../../.. +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib +SWIGOPT = +LIBS = + +build: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + +static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + +clean: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/split_modules/vanilla/pkg1/__init__.py b/Examples/python/import_packages/split_modules/vanilla/pkg1/__init__.py new file mode 100644 index 000000000..7b1594cc8 --- /dev/null +++ b/Examples/python/import_packages/split_modules/vanilla/pkg1/__init__.py @@ -0,0 +1 @@ +# killroy was here diff --git a/Examples/python/import_packages/split_modules/vanilla/pkg1/foo.i b/Examples/python/import_packages/split_modules/vanilla/pkg1/foo.i new file mode 100644 index 000000000..60ce16ec3 --- /dev/null +++ b/Examples/python/import_packages/split_modules/vanilla/pkg1/foo.i @@ -0,0 +1,10 @@ +%module(package="pkg1") foo +%{ +static unsigned count(void) +{ + return 3; +} +%} + +unsigned count(void); + diff --git a/Examples/python/import_packages/split_modules/vanilla/runme.py b/Examples/python/import_packages/split_modules/vanilla/runme.py new file mode 100644 index 000000000..a188364f1 --- /dev/null +++ b/Examples/python/import_packages/split_modules/vanilla/runme.py @@ -0,0 +1,10 @@ +import os.path + +testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) +print "Testing " + testname + " - split modules" + +import pkg1.foo + +print " Finished importing pkg1.foo" + +assert(pkg1.foo.count() == 3) diff --git a/Examples/python/import_packages/split_modules/vanilla_split/Makefile b/Examples/python/import_packages/split_modules/vanilla_split/Makefile new file mode 100644 index 000000000..c322b5aec --- /dev/null +++ b/Examples/python/import_packages/split_modules/vanilla_split/Makefile @@ -0,0 +1,22 @@ +TOP = ../../../.. +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib +SWIGOPT = -outdir pkg1 +LIBS = + +check: build + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run + +build: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + +static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + +clean: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean + cd pkg1 && $(MAKE) -f $(TOP)/../Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean diff --git a/Examples/python/import_packages/split_modules/vanilla_split/foo.i b/Examples/python/import_packages/split_modules/vanilla_split/foo.i new file mode 100644 index 000000000..60ce16ec3 --- /dev/null +++ b/Examples/python/import_packages/split_modules/vanilla_split/foo.i @@ -0,0 +1,10 @@ +%module(package="pkg1") foo +%{ +static unsigned count(void) +{ + return 3; +} +%} + +unsigned count(void); + diff --git a/Examples/python/import_packages/split_modules/vanilla_split/pkg1/__init__.py b/Examples/python/import_packages/split_modules/vanilla_split/pkg1/__init__.py new file mode 100644 index 000000000..7b1594cc8 --- /dev/null +++ b/Examples/python/import_packages/split_modules/vanilla_split/pkg1/__init__.py @@ -0,0 +1 @@ +# killroy was here diff --git a/Examples/python/import_packages/split_modules/vanilla_split/runme.py b/Examples/python/import_packages/split_modules/vanilla_split/runme.py new file mode 100644 index 000000000..a188364f1 --- /dev/null +++ b/Examples/python/import_packages/split_modules/vanilla_split/runme.py @@ -0,0 +1,10 @@ +import os.path + +testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) +print "Testing " + testname + " - split modules" + +import pkg1.foo + +print " Finished importing pkg1.foo" + +assert(pkg1.foo.count() == 3) |