Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
Questions tagged [python-extensions]
323 questions
5
votes
1 answer
How to return a list of ints in Python C API extension with PyList?
I am building a Python extension (.pyd) using Visual Studio 2015 C++ project and Python 2.7 32bit.
This is my .cpp file:
#include
static PyObject* GetTwoInts(PyObject* self, PyObject* args)
{
srand(time(NULL));
int random1 =…

Alex Tereshenkov
- 3,340
- 8
- 36
- 61
5
votes
1 answer
Bundling C++ extension headers with a Python package source distribution
I'm writing a Cython wrapper to a C++ library that I would like to distribute as a Python package. I've come up with a dummy version of my package that looks like this (full source here).
$ tree
.
├── bogus.pyx
├── inc
│ └── bogus.hpp
├──…

Daniel Standage
- 8,136
- 19
- 69
- 116
5
votes
1 answer
how to write setup.py to install python extention (xxx.so file) built by SWIG?
Using SWIG to build python extensions (xxx.so) is easier than distutils. You don't need to write a wrap.c program to wrap your original c program. So I'd like using SWIG than Distutils. But There is no methods to install extensions(xxx.so)…

horbat
- 93
- 1
- 1
- 8
5
votes
1 answer
Differences between Cython, extending C/C++ with Python.h, etc
Right now I have an image processing algorithm that is roughly 100 lines or so in Python. It takes about 500ms using numpy, PIL and scipy. I am looking to get it faster, and as the actual algorithm seems pretty optimized thus far, I'm wondering if…

Chrispresso
- 3,660
- 2
- 19
- 31
5
votes
2 answers
using a C extension in python, without installing it as a module
I am writing C extensions for python. I am just experimenting for the time being and I have written a hello world extension that looks like this :
#include
static PyObject* helloworld(PyObject* self)
{
return…

ironstein
- 416
- 8
- 23
5
votes
1 answer
Python Function Capsules
I found this code snippet in the help of python 2.7.5, which is a chapter about exposing a C-API to other modules in the Extending Python with C and C++ section: Providing a C API for an Extension Module
/* C API functions */
#define…

Sebi2020
- 1,966
- 1
- 23
- 40
5
votes
1 answer
why i failed to build sqlite3 when build python?
why i just failed to build sqlite?
does it have something to do with readline or _tkinter, or something else?
pes/libffi/src/prep_cif.o build/temp.linux-i686-2.7/home/mirror/build/tmp/Python-2.7.3/Modules/_ctypes/libffi/src/closures.o…

hugemeow
- 7,777
- 13
- 50
- 63
4
votes
1 answer
Identifying Packages Using Python's Stable ABI
I have a Python package containing a number of C/C++ extensions built as a single wheel. I'm trying to understand how to ensure the wheel and shared libraries it contains correctly advertise that they use the stable ABI at a particular API version.…

Jim
- 474
- 5
- 17
4
votes
1 answer
How to structure and distribute Pybind11 extension with stubs?
I'm trying to create and distribute (with pip) a Python package that has Python code, and C++ code compiled to a .pyd file with Pybind11 (using Visual Studio 2019). I also want to include .pyi stub files, for VScode and other editors. I can't find…

wolfinabox
- 83
- 1
- 4
4
votes
4 answers
error while installing python extensions " can't open file 'directory + filename': [Errno 2] No such file or directory "
I tried to install mypy extension in vs code but it keeps showing me this error below
C:\Users\Yourusername\Dev\django_project_boilerplate\env\Scripts\python.exe: can't open file…

anouar es-sayid
- 355
- 5
- 11
4
votes
3 answers
Debugging Pybind11 extension with Visual Studio Code (MacOS)
I've been using pybind11 recently, and now that I'm getting the hang of it, I'm thrilled with it. It's an awesome piece of work. The final piece of the tool puzzle for doing pybind11 is the debug part. I've got command line debugging with lldb…

Andrew Voelkel
- 513
- 4
- 10
4
votes
0 answers
Cross compile Python extension from Linux to Win using MingW
I am trying to cross compile a software on a Linux machine targeting a Windows system using Mingw.
Baiscally in the software compilation a Python extension is built and here we have the problems:
When I run the command starting the execution of the…

rakwaht
- 3,666
- 3
- 28
- 45
4
votes
0 answers
Shared library distributed in python wheel not found
I have a python module which contains a C++ extension as well a shared library on which the C++ extension depends. The shared library is picked up by setuptools as an extra_object on the extension. After running python setup.py bdist_wheel, the…

mcguip
- 5,947
- 5
- 25
- 32
4
votes
2 answers
retrieving current URL from FireFox with python
I want to know what is the current url of active tab in running firefox instance from python module. Does FireFox have any API for this and does python know to work with it?

user20955
- 2,552
- 4
- 24
- 23
4
votes
2 answers
Use Setuptools with C Extension as part of package
I wrote a C Extension to access an error message for a camera from a proprietary library. The structure is
setup.py
dicamsdk\
|---__init__.py
|---control.py
|---pcoError.c
with setup.py
from setuptools import setup, Extension, find_packages
from…

smiddy84
- 285
- 1
- 4
- 13