/Poetry_C_Extension_Example

Poetry C Extension Example

Primary LanguagePythonCreative Commons Zero v1.0 UniversalCC0-1.0

Poetry C Extension Example

Example for developing C extension on Poetry
This repository show example spam module (in official document) and simple math module.

Build

  1. Clone this repository.
  2. If you use VSCode, use Remote-Containers extension, and Reopen in Container.
  3. Otherwise, install poetry by running in a terminal:
pip install poetry

Installation

  1. To install the module in the poetry environment, run:
poetry install
  1. If you want to install the module system-wide, you could run:
poetry build
pip install dist/spam*whl

Test

Run:

poetry run pytest -s

Usage

Run a Python interpreter:

poetry run python

Then, run the following commands:

from spam.math import add
assert add(3, 2) == 5