Questions tagged [extension-modules]

29 questions
22
votes
5 answers

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

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…
cjerdonek
  • 5,814
  • 2
  • 32
  • 26
11
votes
1 answer

C++ Python module import error: "undefined symbol: Py_InitModule3" ( Py_InitModule () )

I am just starting an attempt to write my first Python extension module in C and are using instructions provided at https://www.tutorialspoint.com/python/python_further_extensions.htm I am on Linux Mint 18.1, using Python 3.6.1 in its virtualenv…
Claudio
  • 7,474
  • 3
  • 18
  • 48
7
votes
3 answers

Cross module dependencies in Boost Python

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"); } And module B: class AnotherClass…
Arjan
  • 71
  • 1
  • 3
6
votes
3 answers

Groovy's extension-module compared to java's inheritance

Is groovy's extension module feature a hybrid form of java's inheritance feature? Why are the extension-module needs to be declared as static?
user2454455
4
votes
0 answers

Python/pip: How to do an editable package install with extension modules?

I am developing a python package with a C++ extension module that interops with the python code via pybind11, and which I am building using CMake (based on this answer). I have the package installed as editable to aid in development via pip install…
Ben Jones
  • 41
  • 1
4
votes
1 answer

How to import or install pre-built python extension module (C++) (i.e. library not compiled via setuptools)?

I have a C++ project for which I am developing a Python interface. For now I am using pybind11 since it seems pretty neat, and has some nice tools for building the extension module with CMake, which is how the main C++ project is built. Via CMake I…
Ben Farmer
  • 2,387
  • 1
  • 25
  • 44
4
votes
5 answers

_functools module

How does this import work, what file does it use? import _functools In python 2.5: import _functools print _functools.__file__ Gives: Traceback (most recent call last): File "D:\zjm_code\mysite\zjmbooks\a.py", line 5, in print…
zjm1126
  • 63,397
  • 81
  • 173
  • 221
4
votes
1 answer

DLL Load Failed: %1 is not a valid win32 application

So I have a situation where I need to make binary patches and then be able to apply them from within python. I found bsdiff which looks like a great algorithm and has a python extension module, but that extension module doesn't have a windows…
glittershark
  • 534
  • 2
  • 6
  • 19
3
votes
1 answer

python3 C extension module with cp1252 encoded string

I am writing a Python3 extension module for an existing C++ library which returns a string that appears to be in cp1252 encoding. The C++ function signature is int get_name(std::string& name); where name is the output variable that contains a…
3
votes
2 answers

How can one get the version of the currently-running Python interpreter from within a Python extension module?

This question is about how to detect the version of the Python interpreter being used to execute an extension module, from within an extension module (i.e. one written in C). As background, it's straightforward inside a Python extension module to…
cjerdonek
  • 5,814
  • 2
  • 32
  • 26
3
votes
4 answers

Linking errors when compiling python extension module

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…
glittershark
  • 534
  • 2
  • 6
  • 19
2
votes
0 answers

Call to module in __init__.py breaks with python setup.py install; module imported into init relies on extension which is not built yet

and thanks in advance for whatever help you can give me on this problem. I am working to deploy a python project with a cython-generated .c file with the following configuration for the setup.py file: . . . setup( . . ., packages=[ …
2
votes
1 answer

Unable to get Groovy extension module to work

I am trying to create an extension module and then use it in a different project/script but unable to get it to work. Here is what I am doing: Step-1: Created a file named TemperatureUtils.groovy which is a category-like class. Here is the…
2
votes
1 answer

How to call a builtin function (or method) from C code of a Python extension module?

What I currently want to accomplish is to tweak Pythons itertools module function combinations to sort the passed iterable before creating combinations out of it with the goal of having the returned combinations sorted. I am working on a Python…
Claudio
  • 7,474
  • 3
  • 18
  • 48
2
votes
1 answer

add extension module to groovy class

I am trying to create simple extension module. I created Main.groovy file class Item { String item } new Item().sayHello() // this method supposed to be extension I compiled it (not ran). I created ItemExtension.groovy class class ItemExtension…
lapots
  • 12,553
  • 32
  • 121
  • 242
1
2