Skip to main content

Python bindings for the Template Numerical Library

Project description

PyTNL

Python bindings for the Template Numerical Library (TNL).

Installation

From PyPI

PyTNL can be installed from PyPI using any Python package manager, e.g. pip:

pip install pytnl

However, PyTNL currently publishes only a source distribution (sdist) so this step involves building the binary modules on your own system. For this to work, several dependencies must be installed:

  • Python 3.12 or later, including the development headers for building C/C++ Python modules
  • Compiler for the C++17 standard, e.g. GCC or Clang
  • Git
  • An MPI library such as OpenMPI
  • (Optional): CUDA toolkit for building and using CUDA-enabled PyTNL submodules

You can install all dependencies with one of the following commands, depending on your Linux distribution:

  • Arch Linux:

    pacman -S base-devel git python openmpi
    
  • Ubuntu:

    apt install build-essential git python3-dev libopenmpi-dev
    

Additional dependencies will be pulled in automatically either as Python packages (e.g. cmake) or using the FetchContent cmake module.

From git repository

Alternatively, the latest development version can be installed directly from the git repository instead of the stable release from PyPI:

pip install git+https://gitlab.com/tnl-project/pytnl.git

This step involves building PyTNL from source as well, see the previous section for the necessary dependencies.

Alternatively, if you need to make changes to the sources, see the next section.

For development

This section covers the suggested setup for PyTNL developers. First make sure to install all dependencies mentioned in the first section.

Clone the repository and create a Python virtual environment for the project:

git clone https://gitlab.com/tnl-project/pytnl.git
cd pytnl
python -m venv .venv
source .venv/bin/activate

Next we need to install the build system in this environment:

pip install scikit-build-core
pip install cmake ninja  # only necessary if not present in your system

To facilitate repeatable builds, the following command installs PyTNL without build isolation using the active venv and shared build subdirectory for build artifacts:

pip install --no-build-isolation -ve .[dev]

Run the previous command again after making changes in the code to rebuild the project.

The [dev] extra also installs packages for testing and linting the code that you can run:

pytest
ruff check
basedpyright
mypy

The [dev-cuda] extra additionally contains dependencies necessary for testing the CUDA support.

Other

There are other ways to install PyTNL in specific environments, including running plain cmake commands or using a different Python build frontend such as build. See the .gitlab-ci.yml file for examples and do not hesitate to get in touch in case of questions!

Usage

After installing PyTNL, run python and import some module from the pytnl package, e.g. pytnl.containers.

The examples directory contains some short examples showing how to use PyTNL.

Note that if you install pyright and integrate its LSP server (pyright-langserver) into your editor, you will get code completion for objects in the pytnl package 🤩 There is also an extension for VSCode and for VSCodium.

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

pytnl-0.0.8.tar.gz (247.4 kB view details)

Uploaded Source

File details

Details for the file pytnl-0.0.8.tar.gz.

File metadata

  • Download URL: pytnl-0.0.8.tar.gz
  • Upload date:
  • Size: 247.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for pytnl-0.0.8.tar.gz
Algorithm Hash digest
SHA256 4d69abd4219fd216729b0263f126f0d8c8e53962e767c1b2f5356c9678b8f9aa
MD5 f4cabe18358d804c18fafa2f3276226d
BLAKE2b-256 ee99e0561aeb766720508f18ea60c074d332c635d9c5eb0c0fa7e1518964f164

See more details on using hashes here.

Supported by

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