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

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

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.3.tar.gz (231.1 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: pytnl-0.0.3.tar.gz
  • Upload date:
  • Size: 231.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for pytnl-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ee60d9b2f7017f1b816e8779488e5029749b72478a2e9ca11c3d0f572b0b7060
MD5 a74cbc743a813942517c25697ea0de82
BLAKE2b-256 02f04d7914657b6c6768f6750625ba62f292cb60ac1e7c7a4f8943fcff66e61c

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