Hi All,
I have an application with an embedded python interpreter and i need to
get the embedded interpreter to "import" strangely named files as python
modules.
Anyhow the simple part of the question is:
How do i convert a _node* object returned from:
PyParser_SimpleParseStringFlagsFilename()
into a code object i can use as a module to import with:
PyImport_ExecCodeModule()
I cant seem to find any documentation about this. If you are wondering
why i want to do this, then you can read on and maybe there is a much
better way to achieve what i am after.
Thanks,
Brendon
----- What i am trying to achieve -----
Basically i want to "import" using the python C API a module from
various files which may have names that do not make valid python module
names.
In particular i have an embedded python interpreter that is used to
apply a number of operations on some data based on a user supplied
"suppressions file" (*.eds). This .eds file is just a python source file
designed only to be used from within this application.
Now the names of these suppression files usually matche that of a
library or application to which they will apply to. For example:
libstdc++.so.6.0.5 : has eds file: libstdc++.so.6.0.5.eds
Now i want to have my code import this eds file as a python module so
that i can then use it as any other standard python module. So i need to
separate the name of the module from the name of the file. I was
thinking for example for the above filename i would give it a module
name like:
libstdc___so_6_0_5
(The name is not important just that the above one is a valid module
name from what i understand and it is based on the original name)
So i have some random file:
/foo/bar/lib/libstdc++.so.6.0.5.eds
and i want to be able to import that as a module using the Python C API
so native python code can access the module like:
libstdc___so_6_0_5.PostCalculation()
If you have any better method of doing this, i would love to know what
it is.
Thanks in advance for any help,
Brendon.