Skip to main content

Fortran magic

PyPI CI PyPI - Downloads

Compile and import symbols from a cell with Fortran code, using f2py.

Attention: I am looking for collaborators to maintain this project. If you are interested, please open an issue (or PRs) with your proposals for improvements and volunteer to be a maintainer.

The contents of the cell are written to a .f90 file in the directory IPYTHONDIR/fortran using a filename with the hash of the code. This file is then compiled. The resulting module is imported and all of its symbols are injected into the user's namespace.

Install

You can install or upgrade via uv:

uv add fortran-magic

Or via pip:

pip install -U fortran-magic

Or run directly

uv run --with=fortran-magic ipython

Basic usage

Once it's installed, you can load it with %load_ext fortranmagic. Then put your Fortran code in a cell started with the cell magic %%fortran. For example:

In[1]: %load_ext fortranmagic

In[2]: %%fortran

       subroutine f1(x, y, z)
            real, intent(in) :: x,y
            real, intent(out) :: z

            z = sin(x+y)

       end subroutine f1

Every symbol is automatically imported. So the subroutine f1 is already available in your python session as a function:

In[3]:  f1(1.0, 2.1415)
Out[3]: 9.26574066397734e-05

Tests

Run tests with:

uv run --group dev pytest

See the documentation for further details.

Release files for fortran-magic 1.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 fortran-magic 1.0
File Size Uploaded
fortran_magic-1.0.tar.gz 25.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fortran-magic 1.0
File Interpreter ABI Platform
fortran_magic-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.2 kB

Release files / fortran_magic-1.0.tar.gz

Download URL fortran_magic-1.0.tar.gz
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a34ef0a0bc535bd45c7afb7ba027f74b156bf0ed8abf5f7c11d01fe185591520
BLAKE2b-256 checksum
How to use checksums
c038e7a6bcba8d28c45cc3b0498bf0a0ea61ac27962a8214de1e123ded462843
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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 Jul 30, 2026.

Transparency log

Release files / fortran_magic-1.0-py3-none-any.whl

Download URL fortran_magic-1.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
28aff14396b3afb470655e29c688c64c90dd478db749733ffa3f46bdacf37dc3
BLAKE2b-256 checksum
How to use checksums
499424b8af11f5f7e6dc6c9ef7842bb773e82f466557d6efeacf891119104bba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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 Jul 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files

0.9

2 release files

0.8

2 release files

0.7.1

2 release files

0.7

2 release files

0.6.1

2 release files

0.6

2 release files

0.5.1

2 release files

0.5

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4

1 release file

0.3

1 release file

0.2.1

1 release file

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