The following instructions explain how to compile, use and test the Python interface to Atomistica.
- Python 3.8 or greater (Python 3.12+ recommended)
- NumPy >= 1.21.0 (NumPy 2.x supported)
- Meson >= 1.1.0
- meson-python >= 0.15.0
- A Fortran compiler (gfortran or ifort)
- A C compiler
- A C++ compiler
- LAPACK library
Using pip:
pip install meson-python meson ninja numpy aseOr using uv (recommended):
uv pip install meson-python meson ninja numpy aseTo build a wheel:
python -m build --no-isolation -wTo build and install in development mode:
pip install -e . --no-build-isolationpip install dist/atomistica-*.whlImport Atomistica to verify it works:
python -c "import atomistica; print('Successfully imported atomistica')"cd tests
python run_tests.pyEach test can also be run directly for more diagnostic output:
python bulk_properties.py
python forces_and_virial.py
python rebo2_molecules.pyAtomistica now uses the Meson build system (via meson-python) instead of the deprecated numpy.distutils. The build configuration is defined in:
pyproject.toml- Python package metadata and build backend configurationmeson.build- Meson build configurationbuild_helpers/generate_factories.py- Factory code generation script
The build system will automatically detect your compilers. If you need to specify particular compilers, you can set environment variables:
For GNU compilers:
export CC=gcc
export CXX=g++
export FC=gfortranFor Intel compilers:
export CC=icc
export CXX=icpc
export FC=ifortThe build system automatically detects LAPACK using pkg-config. If LAPACK is not found automatically, you may need to install it or specify its location:
On Ubuntu/Debian:
sudo apt-get install liblapack-devOn macOS with Homebrew:
brew install lapackOn Fedora/RHEL:
sudo dnf install lapack-develInstall Meson and ninja:
pip install meson ninjaThis typically indicates a linking issue. Make sure all dependencies (LAPACK, compiler runtime libraries) are properly installed and accessible.
Atomistica supports both NumPy 1.x and 2.x through a compatibility layer. If you encounter NumPy-related errors, try upgrading to NumPy 2.x:
pip install 'numpy>=2.0'If you previously built Atomistica with setup.py, note that:
setup.cfgis no longer used for compiler configuration- The build system now uses
pyproject.tomlandmeson.build - You no longer need to run
python setup.py cleanbetween builds - OpenMP and other compiler flags are automatically configured by Meson
For active development, use the provided rebuild scripts to quickly rebuild and reinstall after making changes:
Using standard pip:
./rebuild.shUsing uv:
./rebuild-uv.shThese scripts will:
- Build a new wheel
- Force-reinstall it
- Provide a test command to verify the installation
Note on editable installs: Meson's editable install mode (pip install -e .) can have caching issues. We recommend using the wheel rebuild workflow for development instead.
To pass additional Fortran flags:
FFLAGS="-fopenmp" pip install -e . --no-build-isolationTo enable verbose build output:
python -m build --no-isolation -w -vFor development, you can use meson directly:
meson setup builddir
meson compile -C builddir