Skip to main content

autowrap build autowrap | Conda Version

Generates Python Extension modules from Cython PXD files.

Introduction

One important application of Cython is to wrap C++ classes for using them in Python. As Cythons syntax is quite similar to the syntax of Python writing a wrapper can be learned easily. Further Cython prevents you from many typical errors which might get in your way if you write such a wrapper in C++.

Requirements

  • Python ≥ 3.9
  • Cython ≥ 3.0

This wrapping process typically consist of four steps:

  1. Rewrite parts of the header files of your C++ library in so called .pxd files. These give Cython information for calling the library and for error checking the code written in the following step.

  2. Write Cython code which wraps the C++ library. This code resides in one or more .pyx files.

  3. Translate these .pyx files to C++ code with Cython.

  4. Use distutils to compile and link the C++ code to the final Python extension module.

Depending on the size of your library step 2 can be tedious and the code will consist of many similar code blocks with only minor differences.

This is where autowrap comes into play: autowrap replaces step 2 by analyzing the .pxd files with Cythons own parser and generating correct code for step 3. In order to steer and configure this process the .pxd files can be annotated using special formatted comments.

The main work which remains is writing the .pxd files. This is comparable to the declarations you have to provide if you use SIP or SWIG.

Documentation

We assume that you installed autowrap already, so running

$ autowrap --help

does not fail.

Please see docs/README.md for further documentation.

Features

  • Wrapping of template classes with their public methods and attributes,enums, free functions and static methods.

  • Included converters from Python data types to (many) STL containers and back. As this is version 0.2, not all STL containers are supported. We plan full support of nested STL containers.

  • Manually written Cython code can be incorporated for wrapping code which autowrap can not handle (yet), and for enriching the API of the wrapped library. As this is done by writing Cython instead of C/C++ code, we get all benefits which Cython shows compared to C/C++.

    Writing a code generator for handling all thinkable APIs is hard, and results in a difficult and hard to understand code base. We prefer a maintainable code generator which handles 95% of all use cases, where the remaining 5% are still wrapped manually.

  • For achieving a pythonic API, converters for library specific data types can be implemented easily. These converters are written in Python and Cython, not in C/C++ code using the C-API of CPython.

  • autowrap relies on Cython, so we get automatic conversion of C++ exceptions to Python exceptions and wrapper code with correct reference counting. Using distutils we do not have to care to much about the build process on the targeted platform.

  • Support for generating some special methods, as __getitem__, __copy__ and numerical comparison operators.

Credits

Many thanks go to:

  • Hannes Roest, ETH Zürich, for contributing new ideas, patches, fruitful discussions and writing the first draft of this README.

  • Lars Gustav Malmström, ETH Zürich, for getting the ball rolling.

  • The developers of Cython for providing such a powerful and high quality tool.

  • Thanks to https://github.com/hendrik-cliqz for implementing the "no-gil" annotation.

Release files for autowrap 0.27.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autowrap 0.27.0
File Size Uploaded
autowrap-0.27.0.tar.gz 111.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autowrap 0.27.0
File Interpreter ABI Platform
autowrap-0.27.0-py3-none-any.whl Python 3 none any Details

Total release size: 190.7 kB

Release files / autowrap-0.27.0.tar.gz

Download URL autowrap-0.27.0.tar.gz
Size 111.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7f746e006a92409dd2cba04e033dd415ffe759ae5620a93a12ac734068430831
BLAKE2b-256 checksum
How to use checksums
4c093c50695d39b8245ce620d0840358e2e1ecac76797693b7f8e16fbe497a46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 14, 2026.

Transparency log

Release files / autowrap-0.27.0-py3-none-any.whl

Download URL autowrap-0.27.0-py3-none-any.whl
Size 79.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4d3b0aef4da1ab7d075d8fc3e679b1ff18a25a0c09bdb551d5c770d867f3ac2
BLAKE2b-256 checksum
How to use checksums
5e90e36ae678ffac2be7ef81811754ca1be1deede2f0d010055d148837e5f498
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.27.0 This release

2 release files

0.25.0

2 release files

0.24.0

2 release files

0.22.9

2 release files

0.22.8

2 release files

0.22.6

1 release file

0.22.5

1 release file

0.22.4

1 release file

0.22.3

1 release file

0.22.2

1 release file

0.22.1

1 release file

0.22.0

1 release file

0.20.0

1 release file

0.19.1

1 release file

0.19.0

1 release file

0.18.1

1 release file

0.18.0

2 release files

0.17.0

1 release file

0.16.0

1 release file

0.15.0

1 release file

0.14.0

1 release file

0.13.1

1 release file

0.13.0

1 release file

0.11.0

1 release file

0.10.0

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.8.0

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.7.0

1 release file

0.6.0

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.2.18

1 release file

0.2.17

1 release file

0.2.16

1 release file

0.2.15

1 release file

0.2.14

1 release file

0.2.13

1 release file

0.2.12

1 release file

0.2.10

1 release file

0.2.8

1 release file

0.2.7

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.1

1 release file

0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page