Skip to main content

Python Fortran import hook

Project description


Python import hook for importing Fortran modules.


import fimport

import somefortrancode # <- builds and imports somefortrancode.f90

But why in the world would you want that? One reason is
interactive use, where being able to reload modules is often
very convenient.

This code is based on Cython's pyximport module.

Build customization

A custom numpy.distutils.core.Extension instance and setup()
args (Distribution) for for the build can be defined by a
``<modulename>.fbld`` file, such as::

import os
from numpy.distutils.core import Extension

def make_ext(modname, ffilename):
cwd = os.path.dirname(__file__)
return Extension(name=modname,
sources=[ffilename, 'other_file.f90'],
f2py_options=['only:', 'some_subroutine', ':'],
libraries=['lapack', 'blas'],
include_dirs=['/myinclude', cwd])

def make_setup_args():
return dict(script_args=["--fcompiler=gnu"])

Extra dependencies can be listed in a <modulename>.fdep::


Project details

Release history Release notifications

History Node


This version
History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
fimport-0.1.tar.gz (10.7 kB) Copy SHA256 hash SHA256 Source None Oct 15, 2012

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page