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.15.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.15.0
File Size Uploaded Provenance Actions
pyrucast-0.15.0.tar.gz 1.8 MB With provenance Details for pyrucast-0.15.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pyrucast 0.15.0
File Interpreter ABI Platform Actions
pyrucast-0.15.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for pyrucast-0.15.0-cp311-abi3-win_amd64.whl
pyrucast-0.15.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.15.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pyrucast-0.15.0-cp311-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.11 abi3 macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64 Details for pyrucast-0.15.0-cp311-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Total release size: 23.5 MB

Release files / pyrucast-0.15.0.tar.gz

Download URL pyrucast-0.15.0.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
e4f6623c9061bd32bb70a34330e0ec7c3ac61197021633894fc78a336b6eb62a
BLAKE2b-256 checksum
How to use checksums
95d767887f250bcb71b03f4ae66bef03b8fd82725ad360ca9d75094cc341e4b4
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 Nov 20, 2026.

Transparency log

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

Download URL pyrucast-0.15.0-cp311-abi3-win_amd64.whl
Size 4.6 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
dc6dafb9cc87780656cee69f9730e60c253f6e9af17fec874e66afddad9557a8
BLAKE2b-256 checksum
How to use checksums
c29e46d2e7fd019d8cc53985a70b0a7334b8bb088a1779ddc8550229b9819306
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 Nov 20, 2026.

Transparency log

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

Download URL pyrucast-0.15.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 7.7 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
4187d4c6b806fc4dfcd817cbfbcfc52d16962052eee03b6507212e5986b87d36
BLAKE2b-256 checksum
How to use checksums
b9efebd7b752ec700fee993f4194cd0a35297e84592d466fa85e227eed85cae9
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 Nov 20, 2026.

Transparency log

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

Download URL pyrucast-0.15.0-cp311-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 9.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
f5cd9bc1034d4ab2740e2e0e98507111df601b0129cf7afc0e5f4770c5a8987c
BLAKE2b-256 checksum
How to use checksums
cc9997011a47dafa0b4a38716d1746e5c68aefe59f8e2f9009e6d1e7e6307050
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 Nov 20, 2026.

Transparency log

Security for pyrucast 0.15.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.15.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 Nov 20, 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.

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