Skip to main content

pyrucast

A finite-element library written in Rust, inspired by cast3m, used from Python on Linux, Windows and macOS with a single pip install. It also works as a pure Rust crate, with no Python involved.

PyPI · crates.io · Documentation (French) · Rust API

Install

pip install pyrucast

PyPI ships prebuilt wheels: nothing to compile, no Rust, no C compiler.

System Processor Wheel
Linux, glibc ≥ 2.17 x86_64 manylinux2014_x86_64
Windows 64-bit x86_64 win_amd64
macOS ≥ 10.12 (Intel), ≥ 11 (Apple Silicon) x86_64 and arm64 universal2, one wheel for both

The only prerequisite is CPython ≥ 3.11. Each wheel targets Python's stable ABI (abi3), so one wheel per platform serves Python 3.11, 3.12, 3.13 and later versions. pyrucast has no required Python dependency.

What the wheels contain, and what they expect from the system:

  • Visualization is included: plot() exports PNG and SVG, and opens an interactive window when called without save=.
  • Linux: the wheel bundles its own fontconfig and freetype. It needs only glibc, libgcc, zlib and expat from the system, which every common distribution provides. The interactive window needs a display (X11 or Wayland). Export to PNG/SVG works without one, on a server, in CI or in a container.
  • Windows, macOS: nothing to install. The wheel uses only system libraries and the runtime that comes with Python.

Check the installation:

python -c "import pyrucast; print(pyrucast.__version__, pyrucast.__features__)"

viz in __features__ means plotting is compiled in.

Other platforms (Linux ARM, musl/Alpine, BSD…): pip finds no wheel and compiles the source distribution itself. This needs Rust (rustup), and the result has no visualization (__features__ lacks viz, plot() does not exist). To get plotting there, build from the repository, as described in Build from source.

A first analysis

A 10 cm steel plate, heated throughout, its edge held at 0 °C:

import pyrucast as pc

coords = pc.Coords(2)
a = coords.add_node([0.0, 0.0])
b = coords.add_node([0.10, 0.0])
plate = pc.mesh.extrude(pc.mesh.line(a, b, 20), [0.0, 0.10], 20)  # 20 × 20 QUA4
edge = pc.mesh.border(plate)

fes = pc.FiniteElementSpace(plate)
model = pc.model.heat_conduction(fes)
model = model | pc.model.dirichlet(edge, model, "T")
model = model | pc.model.flux(fes, model, "q")
materials = pc.element_field.material_field(model, [("k", 50.0), ("phi_q", 1.0e6)])

rhs = pc.node_field.external_forces(model, materials)
K = pc.matrix.stiffness(model, materials)
T = pc.solver.solve(K, rhs)
print(f"T max = {T.max('T'):.2f} °C")  # T max = 14.76 °C
plate.plot(field=T, component="T", save="plate.png")  # omit save= for a window

The tutorial (in French) builds on this, step by step, from meshing to nonlinear mechanics. Complete scripts are in examples/ and tutoriel/.

Documentation

  • The book, in French: https://pyrucast.github.io/pyrucast/. It covers installation, the tutorial, the object model, meshing, fields, physics and development. It is built from master, so it can describe features newer than the latest release.
  • Rust API reference: https://docs.rs/pyrucast for the published versions, https://pyrucast.github.io/pyrucast/rust/ for master, or locally cargo doc --no-deps --lib --open.
  • In Python: help(pyrucast.mesh.line). The wheel ships a type stub, so editors show signatures and docstrings.

Use from Rust

cargo add pyrucast
use pyrucast::atoms::ElementType;
// `contour`: a closed line mesh around the area to fill.
let mesh = pyrucast::ops::mesh::triangulate_surface(&contour, ElementType::TRI3, Some(1.0))?;

No feature is on by default, so the crate is pure Rust: it pulls in neither pyo3 nor libpython, and needs no Python to build or test. It requires Rust ≥ 1.89 (edition 2024). The optional features are viz (PNG/SVG export) and viz-interactive (adds the window). The Python binding lives behind python-api, which maturin turns on.

Build from source

You only need this for the development version, or to get plotting on a platform without a wheel.

Tool Version Notes
Git — to clone the repository
Rust ≥ 1.89, edition 2024 via rustup
Python ≥ 3.11
Linux only — pkg-config, plus the fontconfig and freetype headers for the visualization: libfontconfig1-dev libfreetype6-dev (Debian/Ubuntu) or fontconfig-devel freetype-devel (Fedora/RHEL). Add the Python headers, python3-dev / python3-devel, for builds that link libpython (cargo --features python-api, the stub generator).

Windows and macOS need nothing beyond the first three lines. maturin requires an activated venv: without one it fails with "Couldn't find a virtualenv or conda environment".

Linux / macOS (bash):

git clone https://github.com/Pyrucast/pyrucast
cd pyrucast
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip maturin
maturin develop --release --features extension-module,viz-interactive

Windows (PowerShell):

git clone https://github.com/Pyrucast/pyrucast
cd pyrucast
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install --upgrade pip maturin
maturin develop --release --features extension-module,viz-interactive

maturin develop compiles the module and installs it into the venv, in editable mode. After any change to the Rust code, re-run the same command: a plain maturin develop builds without the visualization. bash script/dev.sh (or .\script\dev.ps1) does the same build and also regenerates the type stub.

Development

Every script in script/ exists in bash (.sh) and PowerShell (.ps1).

pip install pytest ruff==0.16.4   # on top of maturin, in the venv
cargo build                       # pure Rust core (no pyo3, no venv needed)
cargo test                        # unit + integration tests + doctests
maturin develop --release --features extension-module,viz && python -m pytest
cargo fmt && ruff format .        # formatting (Rust + Python)
bash script/check_all.sh          # every check, formatting included
bash script/check_rust.sh         # or one block: format / rust / python / examples / doc

The book's chapter Compilation et tests details the Cargo features, the scripts, the generation of the .pyi stub and common troubleshooting.

License

Distributed under the Mozilla Public License 2.0 (MPL-2.0).

The copyleft applies file by file. If you distribute a modified pyrucast source file, it stays under the MPL and its source must be made available. Your own code, built on top of the library or combined with it, can be under any license, proprietary included. The MPL also allows combining pyrucast with code under the GPL, LGPL or AGPL ("Secondary Licenses", §3.3).

Metadata

Release files for pyrucast 0.17.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyrucast 0.17.0
File Size Uploaded Provenance Actions
pyrucast-0.17.0.tar.gz 2.4 MB With provenance Details for pyrucast-0.17.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pyrucast 0.17.0
File Interpreter ABI Platform Actions
pyrucast-0.17.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for pyrucast-0.17.0-cp311-abi3-win_amd64.whl
pyrucast-0.17.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for pyrucast-0.17.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pyrucast-0.17.0-cp311-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.11 abi3 macOS 10.12+ x86-64, macOS 10.12+ universal2 (ARM64, x86-64), macOS 11.0+ ARM64 Details for pyrucast-0.17.0-cp311-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Total release size: 26.3 MB

Release files / pyrucast-0.17.0.tar.gz

Download URL pyrucast-0.17.0.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
8eacedf1e525b7e525ad199483f7b535072cc7439f4fc19628c3da0a767473fd
BLAKE2b-256 checksum
How to use checksums
ba13521b58f9054ba8282faa2a04a3a0f621b85bbceb76dd2408097a6e278d7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / pyrucast-0.17.0-cp311-abi3-win_amd64.whl

Download URL pyrucast-0.17.0-cp311-abi3-win_amd64.whl
Size 5.2 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b44287eb8e1db7e74f40412e3ac9ecba7ab3c7fea25234589b437a681367102d
BLAKE2b-256 checksum
How to use checksums
2d8b5425c7019620b640e4f9ffe767bed59fdf6a243e9bcc9e67b1bc8529b389
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / pyrucast-0.17.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyrucast-0.17.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 8.3 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
84bd285c43ab5f4db46ac19ec55a2e25bda63c5b1bf5d990e6d59c366c84b7b0
BLAKE2b-256 checksum
How to use checksums
b478fc617b09a8cb5c609db33af4ab7e5cd138893241cebde1935aa7ae74350b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / pyrucast-0.17.0-cp311-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL pyrucast-0.17.0-cp311-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 10.5 MB
Tags CPython 3.11 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
444ee48a19a82604d19c209b52825c9e065fffe90a75b85957f465dccac56d3f
BLAKE2b-256 checksum
How to use checksums
dc254108ba21ec9441b4aeeeec6ac4f7a643f30e96e637621d42882ba15acb09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for pyrucast 0.17.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for pyrucast-0.17.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page