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
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
An installation and dependency system for Python

Pyflow Simple is better than complex - The Zen of Python Pyflow streamlines working with Python projects and files. It's an easy-to-use CLI app with a

David O'Connor 1.2k Dec 23, 2022
The Fast Cross-Platform Package Manager

The Fast Cross-Platform Package Manager part of mamba-org Package Manager mamba Package Server quetz Package Builder boa mamba Mamba is a reimplementa

Mamba 4k Dec 30, 2022
pipreqs - Generate pip requirements.txt file based on imports of any project. Looking for maintainers to move this project forward.

pipreqs - Generate requirements.txt file for any project based on imports Installation pip install pipreqs Usage Usage: pipreqs [options] path

Vadim Kravcenko 4.8k Dec 31, 2022
Example for how to package a Python library based on Cython.

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 Kh

Juan José García Ripoll 4 Aug 28, 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 Dec 30, 2022
Cilantropy: a Python Package Manager interface created to provide an "easy-to-use" visual and also a command-line interface for Pythonistas.

Cilantropy Cilantropy is a Python Package Manager interface created to provide an "easy-to-use" visual and also a command-line interface for Pythonist

48 Dec 16, 2022
A tool to upgrade dependencies to the latest versions

pip-check-updates A tool to upgrade dependencies to the latest versions, inspired by npm-check-updates Install From PyPi pip install pip-check-updates

Zeheng Li 12 Jan 06, 2023
If you have stars in your Pipfile and you don't want them, this project is for you!

unstar-pipfile If you have stars in your Pipfile, this project is for you! unstar-pipfile is a tool to scan Pipfile.lock and replace any stars in Pipf

2 Jul 26, 2022
Python Development Workflow for Humans.

Pipenv: Python Development Workflow for Humans [ ~ Dependency Scanning by PyUp.io ~ ] Pipenv is a tool that aims to bring the best of all packaging wo

Python Packaging Authority 23.5k Jan 06, 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
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
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
:package: :fire: Python project management. Manage packages: convert between formats, lock, install, resolve, isolate, test, build graph, show outdated, audit. Manage venvs, build package, bump version.

THE PROJECT IS ARCHIVED Forks: https://github.com/orsinium/forks DepHell -- project management for Python. Why it is better than all other tools: Form

DepHell 1.7k Dec 30, 2022
Dotpkg - Package manager for your dotfiles

Dotpkg A package manager for your dotfiles. Usage First make sure to have Python

FW 4 Mar 18, 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
PokerFace is a Python package for various poker tools.

PokerFace is a Python package for various poker tools. The following features are present in PokerFace... Types for cards and their componen

Juho Kim 21 Dec 29, 2022
Python Environment & Package Manager

Python Environment Manager A Visual Studio Code extension that provides the ability to via and manage all of your Python environments & packages from

Don Jayamanne 72 Dec 29, 2022
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
Python PyPi staging server and packaging, testing, release tool

devpi: PyPI server and packaging/testing/release tool This repository contains three packages comprising the core devpi system on the server and clien

629 Jan 01, 2023