Skip to content

yanqd0/swig-python-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SWIG Python demo

Travis Requirements License

This is a demo for using SWIG to communicate C/C++ in Python.

中文介绍:《在setup.py中配置SWIG模块 · 零壹軒·笔记

Project Structure

swig-python-demo
├── LICENSE
├── Makefile
├── setup.cfg
├── setup.py
├── src
│   └── example
│       ├── example.c
│       ├── example.h
│       ├── example.i
│       ├── __init__.py
│       ├── _meta.py
│       ├── stl_example.cpp
│       ├── stl_example.hpp
│       └── stl_example.i
└── tests
    ├── test_example.py
    └── test_stl_example.py

There is only 1 Python module named example. However, there are 2 extensions behind. One (example.c) is by C, and the other is by C++ with STL (stl_example.cpp).

The key secret is in setup.py.

There is also a Makefile to explain how SWIG works.

Usage

virtualenv -p python3 .env
source .env/bin/activate
pip install -r requirements.txt
pip install -e .
pytest

The compilation and packaging happens in pip install -e .

About

A Python demo for SWIG

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published