⚠️ This guide is intended for developers building and testingpyamtrack, not for end-users. For the main user-oriented documentation, see the main README.
Ensure you have the following installed:
- Python 3 (with development headers, at least 3.9)
- CMake (3.16 or later)
- Ninja (recommended for faster builds)
- GSL (GNU Scientific Library)
- Git (for fetching dependencies)
On Debian/Ubuntu:
sudo apt-get install libgsl-devOn Fedora/RHEL:
sudo dnf install gsl-develFollow these steps to build and install the pyamtrack Python module as a wheel package.
To build and install the project locally, follow these steps:
-
Create a Virtual Environment: Create and activate a Python virtual environment:
python3 -m venv .venv
source .venv/bin/activate -
Install Development Dependencies: Install the required dependencies for building the project:
pip install -r requirements-dev.txt
-
Build the Project: Run the following command to build the project:
python -m build --wheel --no-isolation --config-setting=build-dir=./build
This command speeds up the build process for local development by avoiding recompilation of the
libamtracksource code in every iteration. -
Install the Built Wheel: After building, install the wheel:
pip install dist/*.whl -
Test the Installation: Verify the installation by running:
python -c "import pyamtrack; print(pyamtrack.converters.beta_from_energy(150))"
Expected output:
Python bindings for libamtrack
Alternatively, you can use the scripts/build_linux.sh script to perform the same steps as above. This script automates the process of creating a virtual environment, installing dependencies, building the project, and testing the installation:
./scripts/build_linux.shThis project uses pre-commit. More information about that can be found here.
pip uninstall pyamtrackrm -rf build distpython -m build --wheelNow you can use pyamtrack in your Python scripts:
import pyamtrack
print(pyamtrack.converters.beta_from_energy(150))For a clean and isolated build environment, you can use cibuildwheel. This ensures that the compilation happens in a very clean environment, which is ideal for producing distributable wheels:
pip install cibuildwheelThen, run the following command to build the wheel for a specific Python version and platform:
cibuildwheel --only "cp312-manylinux_x86_64"To test the installed package, type in the virtual environment:
pip install wheelhouse/*whlThen:
>>> import pyamtrack
>>> pyamtrack.stopping.electron_range(120)
0.0006700734300203331
>>> pyamtrack.__version__
'0.14.1'
>>>CI of this project consists of quick, automatic jobs. There are also long manual jobs, which are described here.