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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pytnl-0.0.5.tar.gz.
File metadata
- Download URL: pytnl-0.0.5.tar.gz
- Upload date:
- Size: 242.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b97409ffe2ec179f91a69c64a8e132d07bad83a598e1d45ccaba3ee571283e0d
|
|
| MD5 |
2d6439fbb4afac38d2d76be0412d2143
|
|
| BLAKE2b-256 |
317db74e4abdccd36dbab45f8d512825bf033037cb57f4c118a66a4d908b2d72
|