This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: importing dynamic modules via embedded python
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: awilson123456, brett.cannon, chomo
Priority: normal Keywords:

Created on 2004-06-02 18:42 by awilson123456, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg60493 - (view) Author: Anne Wilson (awilson123456) Date: 2004-06-02 18:42
I had existing C and Python code in which the C code
invoked the Python interpreter via a system call.  For
efficiency reasons, the code needed modification to
invoke the interpreter directly from the code.  This is
a Fedora Core Linux system using Python 2.2.

Based on the Extending/Embedding documentation it all
seemed very easy, but it was not.  It cost me 12 hours
just to figure out why both PyImport_Import and
PyImport_ImportModule would fail.  Turns on that when
embeddeding Python and importing dynamically linked
modules or modules that in turn import dynamically
linked modules, the code must be linked with the -Wl,-E
option to the compiler (e.g. the -E option to ld).

In my up-until-then-blissful ignorance, I didn't know
(or care) that some modules were statically linked
while others were dynamic.  And, of course, I was
clueless about the implications wrt embedded Python. 
It took much painful debugging to track this down. 
(Special thanks to Bob Hepple and Jim Bublitz for
helping me sort this out.)

This should be mentioned up front in the documentation.

Thanks!

Anne

msg60494 - (view) Author: alan johnson (chomo) Date: 2004-07-01 22:05
Logged In: YES 
user_id=943591

needs documenting
msg85156 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2009-04-02 03:58
sys.builtin_module_names lists the modules that are statically linked.
History
Date User Action Args
2022-04-11 14:56:04adminsetgithub: 40336
2009-04-02 03:58:23brett.cannonsetstatus: open -> closed
resolution: not a bug
messages: + msg85156
2009-02-11 02:53:22ajaksu2setassignee: brett.cannon
nosy: + brett.cannon
2004-06-02 18:42:31awilson123456create