Example for how to package a Python library based on Cython.

Overview

Cython sample module

This project is an example of a module that can be built using Cython. It is an upgrade from a similar model developed by Arin Khare.

Structure

The structure of this project is as follows:

.
├── cython_example
│   ├── dataset
│   ├── hello.pyx
│   └── matrix
|       ├── matrix.pyx
|       ├── norm1.pyx
|       └── trace.pyx
├── MANIFEST.in
├── pyproject.toml
├── README.md
├── test
│   └── test.py
└── setup.py

Let me describe the individual components:

  • *.pyx are files that will be compiled to native code from Cython/Python sources.
  • dataset is an example of a file that will be installed raw.
  • hello.pxd is a Cython file that will be compiled to a module with the path cython_example.hello
  • matrix.pyx is a Cython file that joins two other files, norm1.pyx and trace.pyx, which will be joined under the same submodule, cython_example.matrix
  • MANIFEST.in enumerates additional files that need to be installed in the package.
  • pyproject.toml lists packages required to build this module (Cython, to start with), but which are not required for execution.
  • README.md is this long description.
  • setup.py is the Python program that builds the module and assists pip with the installation.

Building and installing from sources

Using a virtual environment

The canonical way to build and install the package is to use setuptools with a build system. In Anaconda, this means you have to install

conda install setuptools build

Then you can issue the command

python -m build

from within the directory of this project. This command will create a new environment only with the libraries indicated in pyproject.toml and build your extension there.

The binary of this build process will be stored as dist/cython_example-*.whl, with some intermediate characters in '*' that represent the version of python and operating system or platform it was built for. You can install this binary on your system using

pip install dist/cython_example*.whl

Note that if you already installed a previous version, you can use the argument --force after install to force reinstalling the package.

Using setuptools

Alternatively, you can use

python setup.py sdist bdist_wheel

This requires that you have already installed the build dependencies enumerated in pyproject.toml.

Trying out the package

The file test/test.py contains an example of a program that invokes all functions from all modules installed in cython_example. Note how the functions norm1 and test are directly available form within the matrix submodule, because of the inline structure.

Owner
Juan José García Ripoll
Quantum scientist and programmer. Proficient in C++, Python, Lisp and C, among other languages and environments.
Juan José García Ripoll
Easy to use, fast, git sourced based, C/C++ package manager.

Yet Another C/C++ Package Manager Easy to use, fast, git sourced based, C/C++ package manager. Features No need to install a program, just include the

31 Dec 21, 2022
Template repo for a GCP-hosted REST API with automatic API versioning and custom domain mapping

Python + Poetry REST API with FastAPI, hosted on GCP This template will get you ready to deploy a FastAPI app in Google Cloud with automatic API versi

Kevin Duff 10 Dec 25, 2022
For when Poetry just doesn't work.

Ballad For when Poetry just doesn't work. Have you tried setting up Poetry, but something doesn't work? Maybe you're... Trying to implement Github Act

BD103 4 Dec 06, 2021
Simple Library Management made with Python

Installation pip install mysql-connector-python NOTE: You must make a database (library) & and table (books, student) to hold all data. Languange and

SonLyte 10 Oct 21, 2021
A set of tools to keep your pinned Python dependencies fresh.

pip-tools = pip-compile + pip-sync A set of command line tools to help you keep your pip-based packages fresh, even when you've pinned them. You do pi

Jazzband 6.5k Dec 29, 2022
Library Management System

Library Management Library Management System How to Use run main.py python file. python3 main.py Links Download Source Code: Click Here My Github Aco

Mohammad Dori 3 Jul 15, 2022
A PyPI mirror client according to PEP 381 http://www.python.org/dev/peps/pep-0381/

This is a PyPI mirror client according to PEP 381 + PEP 503 http://www.python.org/dev/peps/pep-0381/. bandersnatch =4.0 supports Linux, MacOSX + Wind

Python Packaging Authority 345 Dec 28, 2022
A software manager for easy development and distribution of Python code

Piper A software manager for easy development and distribution of Python code. The main features that Piper adds to Python are: Support for large-scal

13 Nov 22, 2022
A Poetry plugin for dynamically extracting the package version.

Poetry Version Plugin A Poetry plugin for dynamically extracting the package version. It can read the version from a file __init__.py with: # __init__

Sebastián Ramírez 264 Dec 22, 2022
Solaris IPS: Image Packaging System

Solaris Image Packaging System Introduction The image packaging system (IPS) is a software delivery system with interaction with a network repository

Oracle 57 Dec 30, 2022
pip-run - dynamic dependency loader for Python

pip-run provides on-demand temporary package installation for a single interpreter run. It replaces this series of commands (or their Windows equivale

Jason R. Coombs 79 Dec 14, 2022
Workon - A simple project manager for conda, windows 10 and vscode

WORK ON A simple project manager for conda, windows 10 and vscode Installation p

Jesus Alan Hernandez Galvan 1 Jan 16, 2022
Python dependency management and packaging made easy.

Poetry: Dependency Management for Python Poetry helps you declare, manage and install dependencies of Python projects, ensuring you have the right sta

Poetry 23.1k Jan 01, 2023
[DEPRECATED] YUM package manager

⛔ This project is deprecated. Please use DNF, the successor of YUM. YUM Yum is an automatic updater and installer for rpm-based systems. Included prog

111 Dec 20, 2022
A PDM plugin that packs your packages into a zipapp

pdm-packer A PDM plugin that packs your packages into a zipapp Requirements pdm-packer requires Python =3.7 Installation If you have installed PDM wi

Frost Ming 23 Dec 29, 2022
OS-agnostic, system-level binary package manager and ecosystem

Conda is a cross-platform, language-agnostic binary package manager. It is the package manager used by Anaconda installations, but it may be used for

Conda 5.1k Jan 07, 2023
Install All Basic Termux Packages To Your Phone

~All-Packages~ The Easiest Way To Install All Termux Packages 🤗 Tool By ⒹⓈ᭄ʜʏᴅʀᴀ✘๛ˢᴸ 👇 Contact Me On 👇 AVAILABLE ON : Termux TESTED ON : Term

ⒹⓈ ʜʏͥᴅᷧʀᷟᴀ✘๛ˢᴸ 7 Nov 12, 2022
A PyPI mirror client according to PEP 381 http://www.python.org/dev/peps/pep-0381/

This is a PyPI mirror client according to PEP 381 + PEP 503 http://www.python.org/dev/peps/pep-0381/. bandersnatch =4.0 supports Linux, MacOSX + Wind

Python Packaging Authority 345 Dec 28, 2022
Python dependency management and packaging made easy.

Poetry: Dependency Management for Python Poetry helps you declare, manage and install dependencies of Python projects, ensuring you have the right sta

Poetry 23.2k Jan 05, 2023
Install and Run Python Applications in Isolated Environments

pipx — Install and Run Python Applications in Isolated Environments Documentation: https://pipxproject.github.io/pipx/ Source Code: https://github.com

5.8k Dec 31, 2022