extension-modules

Cross module dependencies in Boost Python

左心房为你撑大大i 提交于 2019-11-30 20:42:49
Suppose I have two boost python modules that are defined as follows. Module A: class SomeClass { public: SomeClass() {} ~SomeClass() {} }; BOOST_PYTHON_MODULE(A) { class_<SomeClass>("SomeClass"); } And module B: class AnotherClass { public: AnotherClass() {} ~AnotherClass() {} void func(SomeClass& sp) {} }; BOOST_PYTHON_MODULE(B) { class_<AnotherClass>("AnotherClass") .def("func", &AnotherClass::func) ; } Module B has a dependency on module A (i.e. it uses SomeClass from module A). Now, I execute the following python script: import A import B obj1 = A.SomeClass() obj2 = B.AnotherClass() obj2

In Python how can one tell if a module comes from a C extension?

不羁岁月 提交于 2019-11-30 13:57:52
What is the correct or most robust way to tell from Python if an imported module comes from a C extension as opposed to a pure Python module? This is useful, for example, if a Python package has a module with both a pure Python implementation and a C implementation, and you want to be able to tell at runtime which one is being used. One idea is to examine the file extension of module.__file__ , but I'm not sure all the file extensions one should check for and if this approach is necessarily the most reliable. First, I don't think this is at all useful. It's very common for modules to be pure

Linking errors when compiling python extension module

点点圈 提交于 2019-11-29 15:48:48
So I'm writing a python extension module in C and I'm trying to compile it for my 64-bit Python build. After bashing my head against MinGW for a while, I did some googling around and found that MinGW doesn't do 64-bit extension modules, so I set up Visual C++ 2008 Express with the Win7 SDK and DISTUTILS_USE_SDK and MSSdk both equal to 1 as in the answers to this question . I finally got Distutils to find the compilers, but when I compile the extension I get this output: core.obj : error LNK2019: unresolved external symbol __imp__PyErr_NoMemory refer enced in function "int __cdecl handleErrors

Linking errors when compiling python extension module

一个人想着一个人 提交于 2019-11-28 09:11:10
问题 So I'm writing a python extension module in C and I'm trying to compile it for my 64-bit Python build. After bashing my head against MinGW for a while, I did some googling around and found that MinGW doesn't do 64-bit extension modules, so I set up Visual C++ 2008 Express with the Win7 SDK and DISTUTILS_USE_SDK and MSSdk both equal to 1 as in the answers to this question. I finally got Distutils to find the compilers, but when I compile the extension I get this output: core.obj : error