From 73c83570e14c4b895e59eb27768b2f513bc8b1a8 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Thu, 29 Jun 2023 00:48:28 +0200 Subject: [PATCH] fix: Remove MG5_aMC directory from PYTHONPATH (#72) * This is apparently needed to avoid conflicts with how MadGraph determines the root_path. - c.f. https://bugs.launchpad.net/mg5amcnlo/+bug/2025061 * Add tests/test_root_path.sh to ensure that the root_path is valid. --- .github/workflows/docker-centos.yml | 7 +++++++ .github/workflows/docker-debian.yml | 7 +++++++ docker/centos/Dockerfile | 2 +- docker/debian/Dockerfile | 4 ++-- tests/bhabha_scattering.mg5 | 2 ++ tests/test_import.py | 6 ------ tests/test_root_path.sh | 17 +++++++++++++++++ 7 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 tests/bhabha_scattering.mg5 create mode 100644 tests/test_root_path.sh diff --git a/.github/workflows/docker-centos.yml b/.github/workflows/docker-centos.yml index 0df6cbb..b0666ca 100644 --- a/.github/workflows/docker-centos.yml +++ b/.github/workflows/docker-centos.yml @@ -113,6 +113,13 @@ jobs: scailfin/madgraph5-amc-nlo-centos:sha-${GITHUB_SHA::8} "cp -r ${PWD}/tests .; cd tests; bash tests.sh" + - name: Test madevent has valid root_path + run: >- + docker run --rm + -v $PWD:$PWD + scailfin/madgraph5-amc-nlo-centos:sha-${GITHUB_SHA::8} + "cp -r ${PWD}/tests .; cd tests; bash test_root_path.sh" + - name: Check NLO process has dependencies run: >- docker run --rm diff --git a/.github/workflows/docker-debian.yml b/.github/workflows/docker-debian.yml index 8c38d98..672af32 100644 --- a/.github/workflows/docker-debian.yml +++ b/.github/workflows/docker-debian.yml @@ -113,6 +113,13 @@ jobs: scailfin/madgraph5-amc-nlo:sha-${GITHUB_SHA::8} "cp -r ${PWD}/tests .; cd tests; bash tests.sh" + - name: Test madevent has valid root_path + run: >- + docker run --rm + -v $PWD:$PWD + scailfin/madgraph5-amc-nlo:sha-${GITHUB_SHA::8} + "cp -r ${PWD}/tests .; cd tests; bash test_root_path.sh" + - name: Check NLO process has dependencies run: >- docker run --rm diff --git a/docker/centos/Dockerfile b/docker/centos/Dockerfile index f935ddf..29a2bf9 100644 --- a/docker/centos/Dockerfile +++ b/docker/centos/Dockerfile @@ -226,7 +226,7 @@ COPY --from=builder --chown=moby /usr/local/venv /usr/local/venv/ ENV LC_ALL=en_US.utf8 ENV LANG=en_US.utf8 -ENV PYTHONPATH=/usr/local/venv/MG5_aMC:/usr/local/venv/lib:${PYTHONPATH} +ENV PYTHONPATH=/usr/local/venv/lib:${PYTHONPATH} ENV LD_LIBRARY_PATH=/usr/local/venv/lib:$LD_LIBRARY_PATH ENV PATH=${HOME}/.local/bin:$PATH ENV PATH=/usr/local/venv/MG5_aMC/bin:$PATH diff --git a/docker/debian/Dockerfile b/docker/debian/Dockerfile index ca5d434..faf09f9 100644 --- a/docker/debian/Dockerfile +++ b/docker/debian/Dockerfile @@ -37,7 +37,7 @@ RUN apt-get -qq -y update && \ python -m pip list && \ printf '\nexport PATH=/usr/local/venv/bin:"${PATH}"\n' >> /root/.bashrc -ENV PYTHONPATH=/usr/local/venv/lib:/usr/local/venv/MG5_aMC:$PYTHONPATH +ENV PYTHONPATH=/usr/local/venv/lib:$PYTHONPATH ENV LD_LIBRARY_PATH=/usr/local/venv/lib:$LD_LIBRARY_PATH # Install HepMC @@ -226,7 +226,7 @@ ENV LANG=C.UTF-8 ENV PATH=${HOME}/.local/bin:/usr/local/venv/bin:"${PATH}" ENV PATH=/usr/local/venv/MG5_aMC/bin:$PATH -ENV PYTHONPATH=/usr/local/venv/lib:/usr/local/venv/MG5_aMC:$PYTHONPATH +ENV PYTHONPATH=/usr/local/venv/lib:$PYTHONPATH ENV LD_LIBRARY_PATH=/usr/local/venv/lib:$LD_LIBRARY_PATH # TODO: Install NLO dependencies independently for greater control diff --git a/tests/bhabha_scattering.mg5 b/tests/bhabha_scattering.mg5 new file mode 100644 index 0000000..bc65e7d --- /dev/null +++ b/tests/bhabha_scattering.mg5 @@ -0,0 +1,2 @@ +generate e+ e- > e+ e- +output bhabha diff --git a/tests/test_import.py b/tests/test_import.py index caf680c..a4016d3 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -1,9 +1,3 @@ -def test_import_madgraph(): - import madgraph - - assert madgraph - - def test_import_lhapdf(): import lhapdf diff --git a/tests/test_root_path.sh b/tests/test_root_path.sh new file mode 100644 index 0000000..f4a492a --- /dev/null +++ b/tests/test_root_path.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# c.f. https://github.com/scailfin/MadGraph5_aMC-NLO/pull/72 + +set -e +set -u +set -o pipefail + +if [ -d bhabha ]; then + rm -r bhabha +fi + +if [ -f py.py ]; then + rm py.py +fi + +mg5_aMC bhabha_scattering.mg5 +./bhabha/bin/madevent launch -f