From b19d3e06b3132b0c212fd2fb8c2ceb5cc1cac263 Mon Sep 17 00:00:00 2001
From: William S Fulton By default, SWIG would generate mod2.py proxy file with
+ By default, SWIG will generate mod2.py proxy file with
import directive as in point 1. This can be changed with the
-relativeimport command line option. The -relativeimport instructs
-SWIG to organize imports as in point 2 (for Python < 2.7.0) or as in point 4
-for Python 2.7.0 and newer. This is a check done at the time the module is
-imported. In short, if you have
+SWIG to organize imports as in point 4 for Python 2.7.0 and newer.
+
+Compatibility Note: Versions of SWIG prior to SWIG-4.0.0 supported Python < 2.7.0
+and would organize the imports as in point 2 if an older version of Python was detected at runtime.
+
+In short, if you have
mod2.i and mod3.i as above, then without
-relativeimport SWIG will write
-from sys import version_info -if version_info >= (2, 7, 0): - from . import pkg2 - import pkg1.pkg2.mod3 -else: - import pkg2.mod3 -del version_info +from . import pkg2 +from .pkg2 import mod3
at the very beginning of his proxy *.py file. In SWIG, it may be +
at the very beginning of your proxy *.py file. In SWIG, it may be accomplished with %pythonbegin directive as follows:
-The pure Python module needs to load the C/C++ module in order to link -to the wrapped C/C++ methods. To do this it must make some assumptions +The pure Python module needs to load the C/C++ module in order to call +the wrapped C/C++ methods. To do this it must make some assumptions about what package the C/C++ module may be located in. The approach the pure Python module uses to find the C/C++ module is as follows: