From 5ab34603a6163d57590365ef62ceeece0c3d8477 Mon Sep 17 00:00:00 2001 From: Dani Llewellyn Date: Mon, 29 Aug 2022 20:46:33 +0100 Subject: [PATCH] Add PYTHONPATH environment variable to snapcraft.yaml This fixes #1438: `encodings` module not found The variable replaces the `sitecustomize.py` file from `snap/local` because it is no-longer functional due to changes in snapcraft. --- snap/local/usr/lib/python3.8/sitecustomize.py | 22 ------------------- snap/snapcraft.yaml | 1 + 2 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 snap/local/usr/lib/python3.8/sitecustomize.py diff --git a/snap/local/usr/lib/python3.8/sitecustomize.py b/snap/local/usr/lib/python3.8/sitecustomize.py deleted file mode 100644 index 39595b57..00000000 --- a/snap/local/usr/lib/python3.8/sitecustomize.py +++ /dev/null @@ -1,22 +0,0 @@ -import site -import os - -snap_dir = os.getenv("SNAP") -snapcraft_stage_dir = os.getenv("SNAPCRAFT_STAGE") -snapcraft_part_install = os.getenv("SNAPCRAFT_PART_INSTALL") - -# Do not include snap_dir during builds as this will include -# snapcraft's in-snap site directory. -if snapcraft_stage_dir is not None and snapcraft_part_install is not None: - site_directories = [snapcraft_stage_dir, snapcraft_part_install] -else: - superbuild_dir = os.path.join(snap_dir, 'odm/SuperBuild/install') - site_directories = [snap_dir, superbuild_dir] - -for d in site_directories: - if d: - site_dir = os.path.join(d, "lib/python3.8/site-packages") - site.addsitedir(site_dir) - -if snap_dir: - site.ENABLE_USER_SITE = False diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 4dd0b4bd..38d79132 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -209,6 +209,7 @@ apps: environment: # Ensure libraries are found LD_LIBRARY_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/blas:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/lapack:$LD_LIBRARY_PATH + PYTHONPATH: $SNAP/odm/SuperBuild/install:$SNAP/lib/python3.8/site-packages:$SNAP/usr/lib/python3/dist-packages/:$SNAP/usr/lib/python3.8 plugs: - home - network