PYTHONPATH to be explicitly set for core22?

I have a python snap which I am trying to move from core18 to core20 /22. When changing base to core22 and building the snap. The snap is not able to find the installed python packages in $SNAP/lib/python3.10/site-packages. The hack is to set PYTHONPATH environment variable explicitly under environment section.

environment:
    PYTHONPATH: $SNAP/lib/python3.10/site-packages

Is this expected for core22 snaps ? I did not had to do this for my python snaps with core18 base.

Hi. We’re working on improving the Python support because it’s quite fragile at the moment. Is this a classic or strict snap? Can you paste the definition of the part that uses the Python plugin?

Its a strict snap, currently being installed with --devmode flag.

  python_project:
    plugin: python
#    python-version: python3
    source: python_project
    python-requirements: [requirements.txt]
    python-constraints: [constraints.txt]
    build-environment:
      - SNAPCRAFT_PYTHON_INTERPRETER: python3.10
    build-packages:
      - gcc
      - libc6-dev
      - python3-dev
      - g++
      - libpam0g-dev
      - swig
      - sqlite3
      - libsqlite3-dev
      - libxml2-dev
      - zlib1g-dev
      - libffi7
      - libffi-dev
      - openssl
      - libssl-dev
      - libslang2-dev
      - libicu-dev
      - libxslt1-dev
      - libcap-dev
    stage-packages:
      - sqlite3
      - libicu67
      - libxml2
      - libxslt1.1
      - libslang2
      - libxslt1-dev
      - libslang2-dev
      - libcap-dev
    stage:
      - bin
      - lib/python3.10/
      - lib/x86_64-linux-gnu/libreadline.so*
      - lib/x86_64-linux-gnu/libslang.so*
      - usr/lib/x86_64-linux-gnu/libexslt.so*
      - usr/lib/x86_64-linux-gnu/libslang.so*
      - usr/lib/x86_64-linux-gnu/libxml2.so*
      - usr/lib/x86_64-linux-gnu/libxslt.so*
      - usr/bin/python
      - -lib/python3.10/site-packages/tests
      - -lib/python3.10/site-packages/ephem/doc
      - -lib/python3.10/site-packages/numpy/doc
      - -usr/share/doc

I don’t think this is causing your problem, but this environment variable should be PARTS_PYTHON_INTERPRETER in core22. I’ll update the migration howto accordingly (@rpjday might be interested in this change).

The reason is that plugins are now implemented in a library shared by different *craft tools, so they can’t use Snapcraft-specific variable names.

Let me try with this change and revert.