Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jss95/numpy-cython-example
Example for NumPy + Cython + PyPI
https://github.com/jss95/numpy-cython-example
Last synced: 12 days ago
JSON representation
Example for NumPy + Cython + PyPI
- Host: GitHub
- URL: https://github.com/jss95/numpy-cython-example
- Owner: JSS95
- Created: 2024-08-30T12:51:54.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2024-09-19T06:51:26.000Z (4 months ago)
- Last Synced: 2024-11-03T09:42:08.162Z (2 months ago)
- Language: Cython
- Homepage: https://test.pypi.org/project/numpy-cython-example/
- Size: 43.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# NumPy + Cython + PyPI Example
An ultimate guide for writing a Numpy-oriented Cython package and pubilshing to PyPI.
This example covers:
* src-layout with Cython.
* Using `cibuildwheel` to generate pre-built distributions for different platforms.
* Publishing the distribution to PyPI using Github Action.... and many more details!
> (Note) This example uses TestPyPI for distribution. If you create a real project based on this and publish to PyPI, modify the scripts accordingly.
## Installation
You can either download the pre-built binaries for your platform from PyPI, or get the source and build the binaries yourself.
> (Note) Binaries for MacOS are not distributed because I just couldn't make OpenMP work in CI.
Building binaries from `.pyx` files requires Cython's prerequisits and OpenMP installed in your machine.
Once it is satisfied, building can be automated thanks to `setuptools`.### Installing from PyPI
The simplest option. Your platform is detected and binary wheel is installed from PyPI. Just run this and forget about the rest.
```
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ numpy-cython-example
```### Building from PyPI
You can get source from PyPI by disabling binary installation.
This will download the source and automatically build the binary.```
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ --no-binary=numpy-cython-example numpy-cython-example
```### Building from Source
If you have already acquired the souce code (e.g., from Github), running this in your local project root directory will do the same job.
```
pip install .
```> Instead of running the build script, you can also directly run Cython and C compiler to build the binaries with additional options. That approach is not covered in this project.