Installation

From a Tarball Using Pip

The easiest way is to simply pip install LFortran. An example:

conda create -n lfortran python=3.7
conda activate lfortran
pip install lfortran

This works on Linux, macOS and Windows. Pip will automatically download all build and run time dependencies, compile and install LFortran. The only prerequisite that you have to have is a working C compiler.

Now the lfortran environment has the lfort compiler available, you can start the interactive prompt by executing lfort, or see the command line options using lfort -h.

Optional: run tests:

pytest --pyargs lfortran

You can also install any tarball from https://lfortran.org/download/ directly, e.g.:

pip install https://lfortran.github.io/tarballs/release/lfortran-0.1.14.tar.gz

or equivalently by:

wget https://lfortran.github.io/tarballs/release/lfortran-0.1.14.tar.gz
tar xzf lfortran-0.1.14.tar.gz
cd lfortran-0.1.14
pip install .

From Git

This works on Linux, macOS and Windows:

conda create -n lfortran python=3.7 pytest llvmlite prompt_toolkit cmake make
conda activate lfortran
pip install antlr4-python3-runtime scikit-build

Install Java and then ANTLR, say, into ~/ext:

export CLASSPATH="$HOME/ext/antlr-4.7-complete.jar:$CLASSPATH"

Clone the LFortran git repository:

git clone https://gitlab.com/lfortran/lfortran
cd lfortran

Build:

./build.sh

Run tests:

pytest

Run an interactive prompt:

./lfort

Note About Dependencies

End users (and distributions) are encouraged to use the tarball from https://lfortran.org/download/, which only depends on Python and a few Python packages (llvmlite, pytest, prompt_toolkit and antlr4-python3-runtime). The LFortran standard library needs to be compiled and it needs a C compiler. Down the road (see our roadmap), LFortran will be gradually rewritten in C++, so it will also depend on a C++ compiler.

The tarball is generated automatically by our CI (continuous integration) and contains some autogenerated files: the parser, which is generated by ANTLR4 (requires Java) and the AST and ASR nodes, which is generated by an ASDL translator (requires Python). The Java requirement is only needed when using git directly, the tarball does not depend on Java in any way.

The same tarball is accessible from our Downloads page as well as from PyPI.