hepyy
A HEP C++ package manager that installs native wheels or builds packages from source
and exposes them as Python modules through a shared
cppyy interpreter.
Supported packages out of the box: FastJet, Pythia8, HepMC3, fjcontrib, LHAPDF6.
Step-by-step examples for common setups (local, Colab, HPC, Jupyter, ROOT, shared packages):
WORKFLOW-EXAMPLE.md
Requirements
- Python 3.9+ for the base package; CPython 3.10+ for the pip-installable bundle
- A virtual environment or activated conda environment (strongly recommended)
- A C++ compiler:
clang++ (macOS) or g++ (Linux)
cmake (for building HepMC3 from source)
swig (optional, for the LHAPDF source recipe’s Python-enabled build)
- Internet access for first-time package downloads
For source-build tools on macOS with Homebrew:
brew install cmake swig
Installation
Pip-installable HEP bundle
Starting with hepyy 0.2.31, the hepbundle extra installs FastJet, fjcontrib,
HepMC3, LHAPDF, and Pythia8 as native wheels. Pythia includes its external
FastJet/HepMC3/LHAPDF interfaces; LHAPDF includes its upstream Python API and
lhapdf command. The packages share the same native libraries and cppyy runtime.
Wheels are available for Linux x86_64 and macOS arm64/Intel, using
CPython 3.10+. cppyy's JIT needs a compatible C++ toolchain. The native wheels
include the libraries and headers, so their installation does not require
building the five HEP packages or installing cmake/swig.
Linux — create a fresh venv:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install "hepyy[cppyy,hepbundle]>=0.2.31"
macOS — use conda-forge cppyy:
conda create -n hepbundle -c conda-forge python=3.12 cppyy pip
conda activate hepbundle
python -m pip install "hepyy[hepbundle]>=0.2.31"
If you already have a compatible conda-forge cppyy environment, activate it and
run just the final pip command. Using the hepbundle extra on its own preserves
the conda-managed cppyy runtime.
Load before importing: pip installation supplies the native libraries;
hepyy.load() creates their Python proxy modules in the current process.
Call hepyy.load("hepbundle") before import fastjet, fjcontrib, hepmc3
or pythia8. For FastJet alone, use hepyy.load("fastjet"). A bare
import fastjet in a fresh session can raise ModuleNotFoundError until this
initialization runs. Repeat it after restarting a Python process or notebook
kernel. LHAPDF's upstream Python module is directly importable.
Install PDF data, then load the bundle:
lhapdf install CT14lo
import hepyy
hepyy.load("hepbundle")
import fastjet as fj
import fjcontrib, hepmc3, pythia8, lhapdf
print(fj.JetDefinition(fj.antikt_algorithm, 0.4).description())
pdf = lhapdf.mkPDF("CT14lo", 0)
print(pdf.xfxQ(21, 0.1, 100.))
PDF sets are downloaded separately; use LHAPDF_DATA_PATH for custom data
locations. See installation and compatibility for individual
extras, supported runtimes and coexistence with source installations. Maintainers
can follow the recipe-driven upgrade guide
to prepare later wheel releases when recipes change.
Package manager installation
Create and activate a virtual environment, then install hepyy:
Short aliases: heyy and her are registered as identical entry points alongside
hepyy — use whichever you prefer.
heyy install fastjet
her list
hepyy config # all three are the same CLI
python -m venv myenv
source myenv/bin/activate
# From PyPI (the [cppyy] extra also installs cppyy itself — see note below):
pip install "hepyy[cppyy]"
# Or directly from GitHub (no clone needed):
pip install "hepyy[cppyy] @ git+https://github.com/matplo/hepyy.git"
# To update to the latest version (once inside an activated venv):
heyy upgrade
# Or manually with pip / uv:
pip install --force-reinstall "hepyy[cppyy] @ git+https://github.com/matplo/hepyy.git"
uv pip install --reinstall "hepyy[cppyy] @ git+https://github.com/matplo/hepyy.git"
# Or from a local clone (editable install for development):
git clone https://github.com/matplo/hepyy
cd hepyy
pip install -e ".[cppyy]"
Already have cppyy? (e.g. via conda/ROOT — see below) Just pip install hepyy,
no [cppyy] extra. cppyy isn't a hard dependency specifically so that pip never
tries to install or upgrade it when a compatible one is already present — the
[cppyy] extra is only needed when nothing already provides it.
Installing via conda (optional)
hepyy isn't on conda-forge, but it can still be installed straight from PyPI
inside an activated conda/mamba environment:
# conda >=26.5: opt into the rattler solver, then install via the conda-pypi
# bridge channel (mirrors PyPI packages as installable conda packages)
conda config --set solver rattler
conda config --append channels conda-pypi
conda install hepyy
# Older conda: just use pip inside the activated conda env — no solver or
# channel setup needed, and it works on any conda version
pip install hepyy
Note: both routes above deliberately install plain hepyy, not
hepyy[cppyy]. If this conda env already has a working cppyy — for example
because you installed CERN's root package, which pulls in matched
conda-forge cppyy/cppyy-backend/cppyy-cling/CPyCppyy packages — this
leaves it alone rather than having pip try to install or upgrade its own
copy (which risks an ABI mismatch against that matched set). If this conda
env has no cppyy at all, use pip install hepyy[cppyy] instead (the
conda-pypi bridge only mirrors the base package, not extras) or install
cppyy separately via conda install -c conda-forge cppyy.
Also: the conda-pypi channel mirrors PyPI on its own schedule, so a
release published minutes ago may not have propagated there yet.
pip install -U hepyy inside the same conda env always gets the latest
release immediately. See Configuration reference
below for where hepyy stores its package builds inside a conda env.
Google Colab
In a fresh Google Colab runtime, install the
full HEP bundle directly from PyPI:
# Cell 1 — install cppyy and the native HEP wheels
!pip install "hepyy[cppyy,hepbundle]>=0.2.31"
Then initialize the packages in the notebook before importing their Python
proxies:
# Cell 2 — load and use the bundle
import hepyy
hepyy.load("hepbundle")
import fastjet, fjcontrib, hepmc3, lhapdf, pythia8
See the Colab example: Pythia8 → FastJet → fjcontrib SoftDrop,
which uses pip installation followed by the same analysis as the demos.
Rerun the install cell for a new Colab runtime, and the load cell after a kernel
restart.
Slower alternative — source installation: the source-build workflow remains
supported and should also work in Colab. Use a fresh runtime for this alternative;
it compiles the HEP packages instead of installing their wheels:
!pip install "hepyy[cppyy]>=0.2.31"
!heyy init
!heyy install fastjet hepmc3 lhapdf pythia8 fjcontrib --verbose
After building, load the source-installed packages explicitly:
import hepyy
hepyy.load(["fastjet", "hepmc3", "lhapdf", "pythia8", "fjcontrib"])
import fastjet, fjcontrib, hepmc3, lhapdf, pythia8
See the Colab source-build and Drive-cache workflow
for reusing source installations across sessions.
Podman / containers
For a rootless, GPU-aware container setup (Python 3.11 + C++ + Fortran toolchain,
with hepyy-installed packages persisted on the host so adding a package never
needs an image rebuild), see contrib/podman/:
curl -fsSL https://raw.githubusercontent.com/matplo/hepyy/v0.2.30/contrib/podman/hepyy-pod.sh -o hepyy-pod.sh
chmod +x hepyy-pod.sh
./hepyy-pod.sh build
./hepyy-pod.sh run
See contrib/podman/README.md for details, including
automatic CUDA detection and GPU passthrough.
Initialise
Run once after installation to create the package store, fetch recipes, and check cppyy:
hepyy init
This creates the package store under your active venv and automatically clones the
hepyy-recipes repository so the
latest recipes are always available:
<venv>/hepyy_packages/
registry.json ← installed package index
src/ ← cached tarballs (safe to delete to free space)
logs/ ← build logs
recipe-cache/ ← cloned recipe repos
recipe-sources.json ← registered recipe sources
init also checks whether the cppyy backend (libCling) has broken library references
(common on macOS when the cppyy wheel was built against a different package manager).
When running inside a virtual environment, broken paths are patched automatically —
only files inside the venv are ever modified.
If the auto-fix cannot run (e.g. outside a venv, or install_name_tool / patchelf
is missing), inspect and patch manually:
# Inspect only:
hepyy fix-cppyy --check
# Patch:
hepyy fix-cppyy
To upgrade hepyy itself to the latest GitHub version from inside an active venv:
hepyy upgrade
This uses uv pip install --reinstall (or pip --force-reinstall) to bypass the
package cache. Re-enter the subshell after upgrading to pick up new entry points.
To refresh recipes at any time (e.g. after a new recipe is added upstream):
hepyy recipe update
Check where your packages will be installed:
hepyy config
Override the location at any time:
# Environment variable (shell session)
export HEPYY_PACKAGES_DIR=/opt/hep/packages
# Or permanently in .hepyy.toml at your project root:
# packages_dir = "/opt/hep/packages"
Installing packages
Recommended install order
Install order matters for Pythia8: it is built with optional support for FastJet, HepMC3,
and LHAPDF6 only if those packages are already present in the registry at configure time.
No explicit dependency is declared — if a package is installed, Pythia8 picks it up
automatically; if not, that interface is simply omitted.
You can pass multiple package names to install and they are built sequentially in the
order given — which is all that is needed to satisfy the implicit Pythia8 dependencies:
hepyy install fastjet hepmc3 lhapdf pythia8 fjcontrib
Or one at a time:
hepyy install fastjet # (1) jet finding
hepyy install hepmc3 # (2) event record I/O
hepyy install lhapdf # (3) PDF sets
hepyy install pythia8 # (4) sees fastjet + hepmc3 + lhapdf → adds --with-* flags
hepyy install fjcontrib # (5) jet substructure (hard-requires fastjet)
During the Pythia8 build you will see which packages were detected:
[pythia8] FastJet : .../hepyy_packages/fastjet/3.5.1
[pythia8] HepMC3 : .../hepyy_packages/hepmc3/3.3.1
[pythia8] LHAPDF6 : .../hepyy_packages/lhapdf/6.5.4
[pythia8] configure: --with-fastjet3=... --with-hepmc3=... --with-lhapdf6=...
Version precedence
The registry stores one active entry per package name — the last-installed version.
If you install fastjet 3.4 and then fastjet 3.5, only 3.5 is visible to subsequent builds.
To control which version Pythia8 sees, install (or register) the desired fastjet version
before running hepyy install pythia8.
Useful flags
hepyy install fastjet --verbose # show build output live
hepyy install fastjet --force # re-extract and rebuild (keeps cached tarball)
hepyy install fastjet --redownload # delete tarball and start completely fresh
hepyy install fastjet --clean # wipe only build artifacts, keep extracted source
hepyy install fastjet -j 8 # use 8 parallel make jobs (overrides recipe default of 4)
# Flags apply to all packages when multiple names are given:
hepyy install fastjet hepmc3 lhapdf pythia8 fjcontrib --verbose
hepyy install fastjet hepmc3 lhapdf pythia8 fjcontrib -j 8
# --version and --recipe only take effect for a single-package install:
hepyy install fastjet --version 3.4.2
hepyy install mypackage --recipe /path/to/mypackage/1.0.yaml
--clean is useful on slow network mounts (e.g. Google Drive) where re-extracting
a large tarball is expensive: it removes cmake build dirs or runs make clean for
autotools packages, without touching the already-extracted source tree.
Inspecting what is installed
hepyy list # all installed packages with versions and prefixes
hepyy info fastjet # full details for one package
Using packages in Python
Loading with hepyy
In a plain Python process or notebook, initialize the packages before importing
their proxy modules. This applies to pip-installed native wheels and source
installations:
import hepyy
hepyy.load(["fastjet", "pythia8", "fjcontrib"])
import fastjet, pythia8, fjcontrib
import cppyy
jet = fastjet.PseudoJet(1.0, 0.0, 1.0, 1.414)
print(jet.pt())
Use hepyy.load("hepbundle") for the complete pip bundle, or
hepyy.load("fastjet") for just FastJet. The call loads the shared C++ libraries
and registers the Python proxies; pip installation alone does not perform this
per-process setup. Calls are safe to repeat when a package is already loaded.
If you use hepyy's source-install module system, its startup hook can perform
the initialization before the script starts:
module load fastjet pythia8 fjcontrib
python myscript.py
In that module-loaded process, myscript.py may import the packages directly:
import fastjet, pythia8, fjcontrib
The explicit hepyy.load(...) form also works in that process and makes scripts
usable from a normal activated environment without shell module setup.
ROOT — PyROOT via native Python bindings
ROOT is available via the hepyy-recipes
repository (not built-in). Install and use it with:
heyy recipe update # pull latest recipes including root
heyy install root # builds ROOT 6.40.00 (~30 min first time)
import hepyy
hepyy.load("root") # adds ROOT's lib/ to sys.path; does NOT import pip-cppyy
import ROOT
h = ROOT.TH1F("h", "h", 100, 0, 100)
h.Fill(42)
ROOT ships its own cppyy and cling — a different build from the pip-installed cppyy
that hepyy uses for FastJet, Pythia8, etc. Because of this:
This is exactly the scenario the cppyy extra (see Installation)
exists for: if ROOT already provides a working cppyy — whether built via heyy install root above, or via a conda-forge root install (see
Installing via conda) — install plain
hepyy, not hepyy[cppyy], so pip never tries to install a second, separate
cppyy alongside ROOT's.