A minimal example project which builds a Python extension with NumpyEigen. The module is called example
and consists
of two parts:
- A C++ module called
_example_internal
- A Python module called
example
which imports_example_internal
This structure allows you to wrap your C++ bindings in a Python function to add extra functionality.
Additionally, this project includes tests (See /tests
directory) and continuous integration with GitHub actions which
builds on Linux/Mac/Windows and can deploy to PyPI.
To adapt this project for your own custom module, you need to do the following:
- Rename
example/
to the name of your module - Edit
setup.py
(See comments on where to edit) - Edit
CMakeLists.txt
(See comments on where to edit) - Edit
tests/test_example.py
(or delete it if you don't want tests)
This project can convenient deploy your package to PyPI when you release a new version. To enable this, first go to:
Settings > Secrets > Actions
and set the key PYPI_API_TOKEN
to the API token for your PyPI account. You can get an API
token by going to your PyPY Account Settings
and scrolling down to the API tokens section.
Once you've set up an API token, you can deploy a new version of your package by creating a
release whose name is of the form vX.Y.Z
where X
, Y
, and Z
are numbers.
Important: When creating a release vX.Y.Z
, don't forget to update the version in setup.py
to
match!
When you create such a release, Github Actions will build your package and push the new version to PyPI.