Skip to main content

Tutorial on publishing to PyPI

Project description

$\texttt{PyPI-Bonjour}$ 🥖

License PyPI version

Tutorial on publishing to PyPI.

Tutorial

The pypi-bonjour package gradually adds more functionality over different versions.

v0.0.1: the hello-world example

This version publishes the barebone skeleton code to pypi, which includes:

  • the source code with the single pure Python function hello_world (in contrast with pybinded functions)
  • a pyproject.toml file for enabling pip install of the package
  • the GitHub workflow that publishes the package to pypi upon release publish

See this video by Prof.Qiusheng Wu for an introduction to PyPI packaging.

v0.0.2: add dependencies

This version adds NumPy as one of the dependencies.

v0.0.3: add pybind11-binded C++ function

This version adds a function that is pybind11-binded from C++ from Python without the use of CMake. See here for an intro regarding using pybind11 with setuptools.

See this video by anthonywritescode for an introduction to manylinux. Building these manylinux wheels requires the installation of a docker image and building the wheels inside that docker image. This process is automated by cibuildwheel. Furthermore, to enable the build for different architectures on a computer, one should download QEMU for architecture emulation

python3 -m pip install cibuildwheel
sudo apt-get install qemu-system  # for Ubuntu, see https://www.qemu.org/download for more details

To build the wheels only for CPython (what is PyPy...), non-alpine Linux (what is musllinux...), x86_64 and aarch64 platforms use the following command:

export CIBW_SKIP="pp* *musllinux*"
export CIBW_ARCHS="x86_64 aarch64"
cibuildwheel

These can also be added to the pyproject.toml file

[tool.cibuildwheel]
skip = "pp* *musllinux*"
archs = "x86_64 aarch64" 

Then, run cibuildwheel in the root directory. These commands will generate the built distributions in the wheelhouse directory, which can then be uploaded to PyPI using the command

twine upload wheelhouse/*

Note that the source distribution (only the source code) is still missing. To generate it and upload it to PyPI, run the commands

python3 -m build --sdist
twine upload dist/*

The final result is here. Note that the GitHub actions are not setup yet, so the action that this release triggered did not successfully upload the wheels to PyPI.

v0.0.4: added build and publish to PyPI GitHub workflow

For details see build_publish_pypi.yml.

v0.0.5: added C++ projects that are built by CMake

Added a CMakeLists.txt file to build the Python bindings using pybind11 and cmake. The setup.py file is updated according to the official pybind11 + cmake example, if you prefer a video that goes through this process see this one by Facile Tutorials.

v0.0.6: added external C++ dependencies

Added functions that uses Eigen. This involves installing Eigen in the CIBW_BEFORE_ALL script. However, there are certain limitations to CentOS that needs to be taken cared of.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypi_bonjour-0.0.6.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distributions

pypi_bonjour-0.0.6-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (64.4 kB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.24+ x86-64 manylinux: glibc 2.28+ x86-64

pypi_bonjour-0.0.6-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (59.6 kB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.24+ ARM64 manylinux: glibc 2.28+ ARM64

pypi_bonjour-0.0.6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (64.4 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.24+ x86-64 manylinux: glibc 2.28+ x86-64

pypi_bonjour-0.0.6-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (59.7 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.24+ ARM64 manylinux: glibc 2.28+ ARM64

pypi_bonjour-0.0.6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (65.2 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.24+ x86-64 manylinux: glibc 2.28+ x86-64

pypi_bonjour-0.0.6-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (60.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.24+ ARM64 manylinux: glibc 2.28+ ARM64

pypi_bonjour-0.0.6-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (63.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.24+ x86-64 manylinux: glibc 2.28+ x86-64

pypi_bonjour-0.0.6-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (58.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.24+ ARM64 manylinux: glibc 2.28+ ARM64

pypi_bonjour-0.0.6-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (64.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64 manylinux: glibc 2.28+ x86-64

pypi_bonjour-0.0.6-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (58.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.24+ ARM64 manylinux: glibc 2.28+ ARM64

pypi_bonjour-0.0.6-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (63.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.24+ x86-64 manylinux: glibc 2.28+ x86-64

pypi_bonjour-0.0.6-cp38-cp38-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (58.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.24+ ARM64 manylinux: glibc 2.28+ ARM64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page