Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong path for the python interpreter #223

Open
sameersharma2006 opened this issue Jun 24, 2024 · 12 comments
Open

Wrong path for the python interpreter #223

sameersharma2006 opened this issue Jun 24, 2024 · 12 comments

Comments

@sameersharma2006
Copy link

Snapping snaps with gnome-46-2404 SDK , Results in the following error :

libpxbackend-1.0.so: cannot open shared object file: No such file or directory
Failed to load module: /home/abc/snap/thonny/common/.cache/gio-modules/libgiolibproxy.so
/snap/thonny/x1/gnome-platform/command-chain/desktop-launch: line 625: /snap/thonny/x1/usr/local/bin/thonny: cannot execute: required file not found

Reproducible in G4Music & Thonny.
Using SDK & Snapcraft from edge channel.

AFAIK this is related with XKB libs.

Filed similar report under mesa-2404 snap bug tracker.
canonical/mesa-2404#3 (comment)

@seb128
Copy link
Contributor

seb128 commented Jul 4, 2024

Thank you for your bug report. Could you share the corresponding snapcraft.yaml?

@sameersharma2006
Copy link
Author

sameersharma2006 commented Jul 5, 2024

Sure,

  1. G4music
name: g4music
base: core24
adopt-info: g4music
grade: stable
confinement: strict
compression: lzo
platforms:
  amd64:
  arm64:

slots:
  g4music:
    interface: dbus
    bus: session
    name: com.github.neithern.g4music
  mpris:
    name: G4Music

apps:
  g4music:
    command: usr/bin/g4music
    extensions: [gnome]
    plugs:
      - home
      - audio-playback
      - network
      - network-status
      - network-bind
      - unity7
      - screen-inhibit-control
      - removable-media
    slots:
      - mpris
    common-id: com.github.neithern.g4music
    desktop: usr/share/applications/com.github.neithern.g4music.desktop

parts:
  g4music:
    source: https://gitlab.gnome.org/neithern/g4music.git
    source-depth: 1
    source-tag: 'v3.7.1'
    plugin: meson
    parse-info: [usr/share/metainfo/com.github.neithern.g4music.appdata.xml]
    meson-parameters:
      - --prefix=/usr
      - --buildtype=release
    build-packages:
      - libgstreamer1.0-dev
      - libgstreamer-plugins-base1.0-dev
      - cmake
    override-pull: |
      craftctl default
      sed -e 's|Icon=@app_id@|Icon=${SNAP}/usr/share/icons/hicolor/scalable/apps/com.github.neithern.g4music.svg|' -i data/app.desktop.in
  1. Thonny
name: thonny
base: core24
adopt-info: appinfo
grade: stable
confinement: strict
compression: lzo
platforms:
  amd64:
  arm64:

slots:
  thonny:
    interface: dbus
    bus: session
    name: org.thonny.Thonny

apps:
  thonny:
    command: usr/local/bin/thonny
    extensions: [gnome]
    common-id: org.thonny.Thonny
    environment:
      PYTHONPATH: ${SNAP}/lib/python3.12/site-packages:${SNAP}/usr/lib/python3.12/site-packages:${SNAP}/usr/local/lib/python3.12/dist-packages
    plugs:
      - home
      - unity7
      - network
      - network-bind
      - network-status
      - audio-playback
      - audio-record
      - bluez
      - camera
      - hardware-observe
      - system-observe
      - upower-observe
      - raw-usb
      - udisks2
      - optical-drive
      - removable-media
      - screen-inhibit-control
    desktop: appinfo/org.thonny.Thonny.desktop

parts:
  thonny:
    plugin: nil
    override-build: |
      craftctl default
      pip install --prefix=$CRAFT_PART_INSTALL/usr thonny==4.1.4

  appinfo:
    source: https://github.com/thonny/thonny.git
    source-tag: v4.1.4
    after: [thonny]
    parse-info: [packaging/linux/org.thonny.Thonny.appdata.xml]
    plugin: dump
    override-pull: |
      craftctl default
      sed -e 's|Exec=/usr/bin/thonny %F|Exec=/usr/local/bin/thonny %F|' -i packaging/linux/org.thonny.Thonny.desktop
      sed -e 's|Icon=thonny|Icon=${SNAP}/appinfo/thonny-256x256.png|' -i packaging/linux/org.thonny.Thonny.desktop
      mkdir appinfo
      cp packaging/linux/org.thonny.Thonny.desktop appinfo
      cp packaging/icons/thonny-256x256.png appinfo
    prime:
      - appinfo

  tkinter:
    after: [appinfo]
    plugin: nil
    stage-packages:
      - python3-tk
    prime:
      - -usr/lib/libBLTlite.2.5.so*

  deps:
    after: [tkinter]
    plugin: nil
    stage-packages:
      - libnotify-bin
      - zenity
      - xclip
    prime:
      - usr/bin/xclip*
      - usr/bin/zenity
      - usr/bin/notify-send
      - usr/lib/*/libXt.so*
      - usr/lib/*/libXmu.so*
      - usr/lib/*/libXext.so*

  cleanup:
    after: [deps]
    plugin: nil
    build-snaps: [core24, gnome-46-2404]
    override-prime: |
      set -eux
      for snap in "core24" "gnome-46-2404"; do
        cd "/snap/$snap/current" && find . -type f,l -exec rm -rf "${CRAFT_PRIME}/{}" \;
      done
  1. Curtail
name: curtail
base: core24
adopt-info: curtail
grade: stable
confinement: strict
compression: lzo
platforms:
  amd64:
  arm64:

slots:
  curtail:
    interface: dbus
    bus: session
    name: com.github.huluti.Curtail

apps:
  curtail:
    command: usr/bin/curtail
    extensions: [gnome]
    environment:
      PYTHONPATH: ${SNAP}/usr/lib/python3/dist-packages:$PYTHONPATH
      XKB_CONFIG_ROOT: $SNAP/usr/share/X11/xkb
    plugs:
      - home
      - network
      - network-bind
      - network-status
      - removable-media
      - unity7
    common-id: com.github.huluti.Curtail
    desktop: usr/share/applications/com.github.huluti.Curtail.desktop

parts:
  curtail:
    source: https://github.com/Huluti/Curtail.git
    source-tag: '1.10.0'
    source-depth: 1
    plugin: meson
    parse-info: [usr/share/metainfo/com.github.huluti.Curtail.appdata.xml]
    meson-parameters:
      - --prefix=/snap/curtail/current/usr
      - --buildtype=release
    override-pull: |
      craftctl default
      sed -e 's|Icon=com.github.huluti.Curtail|Icon=${SNAP}/usr/share/icons/hicolor/scalable/apps/com.github.huluti.Curtail.svg|' -i data/com.github.huluti.Curtail.desktop.in
    override-build: |
      craftctl default
      sed -e '1c#!/usr/bin/env python3' -i ${CRAFT_PART_INSTALL}/snap/curtail/current/usr/bin/curtail
    organize:
      snap/curtail/current/usr: usr

  oxipng:
    source: https://github.com/shssoichiro/oxipng.git
    source-tag: 'v9.1.1'
    source-depth: 1
    after: [curtail]
    plugin: rust

  deps:
    after: [oxipng]
    plugin: nil
    stage-packages:
      - pngquant
      - scour
      - jpegoptim
      - xkb-data
    prime:
      - usr/lib/*/libimagequant*
      - usr/lib/python3
      - usr/bin/dh_scour
      - usr/bin/jpegoptim
      - usr/bin/scour
      - usr/share/scour
      - usr/bin/pngquant
      - usr/lib/*/libpng*
      - usr/lib/*/libjpeg*
      - usr/share/X11/xkb

The reason i consider this a bug/issue is that previously i never staged xkbcommon libs & set its path manually with core22.

@seb128
Copy link
Contributor

seb128 commented Jul 5, 2024

I tried thonny and it fails on an error

init_fs_encoding: failed to get the Python codec of the filesystem encoding
...
ModuleNotFoundError: No module named 'encodings'

Which is different from what is described there?

@sameersharma2006
Copy link
Author

sameersharma2006 commented Jul 5, 2024

@seb128 Surprisingly, the above doesn't come up in my Debian 12 system.
It still reports the following;

update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/boot /boot none bind,ro 0 0): permission denied
/snap/thonny/x1/gnome-platform/command-chain/desktop-launch: line 625: /snap/thonny/x1/usr/local/bin/thonny: cannot execute: required file not found

Additionally, i have installed the thonny snap locally with --dangerous flag.

@seb128
Copy link
Contributor

seb128 commented Jul 5, 2024

/snap/thonny/x1/gnome-platform/command-chain/desktop-launch: line 625: /snap/thonny/x1/usr/local/bin/thonny: cannot execute: required file not found

ah, it worked here because I had gnome-46-2404-sdk installed

/snap/thonny/x1/usr/local/bin/thonny starts with that line

#!/snap/gnome-46-2404-sdk/current/usr/bin/python3

Unsure what is defining the path to use for python3 there, maybe snapcraft?

@seb128 seb128 changed the title Errors relating to xkbcommon Wrong path for the python interpreter Jul 5, 2024
@sameersharma2006
Copy link
Author

@seb128 Is the title valid, i mean i have literally the same problem in curtail & g4music.
Should i open a different report for curtail & g4music ?

The error which pops up in curtail is bit different,

xkbcommon: ERROR: failed to add default include path /usr/share/X11/xkb
libpxbackend-1.0.so: cannot open shared object file: No such file or directory
Failed to load module: /home/abc/snap/curtail/common/.cache/gio-modules/libgiolibproxy.so
xkbcommon: ERROR: failed to add default include path /usr/share/X11/xkb
Segmentation fault

CC: canonical/mesa-2404#3

@seb128
Copy link
Contributor

seb128 commented Jul 5, 2024

There is one issue with the python interpreter is about now.

Unsure about the xkbcommon issue but you opened another ticket already about that so we don't need to discuss it in this one

@sergio-costas
Copy link
Contributor

I suspect that the python problem is due to pip install... If I'm right, it automagically creates the /usr/local/bin/thonny executable, and places in it a shebang with the path to the current python interpreter... which is the one in the SDK because it is running during building.

So the solution requires to manually "sed" that file after build and pip... something like

sed -i 's%#!%#!/usr/bin/env python3\n#%g' $CRAFT_PART_INSTALL/usr/local/bin/thonny

@seb128
Copy link
Contributor

seb128 commented Jul 5, 2024

Did you use gnome42 before and it was working or are those new snaps?

@sameersharma2006
Copy link
Author

sameersharma2006 commented Jul 5, 2024 via email

@seb128
Copy link
Contributor

seb128 commented Jul 5, 2024

I don't think that statement is true. The version in the store works fine but /snap/thonny/217/bin/thonny is a bash script.

I cloned https://git.launchpad.net/thonny-snap , and try to build rev b7fe6ea2 (before the switch to core24), the resulting snap has

$ head /snap/thonny/x1/usr/local/bin/thonny
#!/snap/gnome-42-2204-sdk/current/usr/bin/python3

Checking the history you did switch from using the snapcraft python plugin to use the nil one and call pip manually which is more likely the change that introduced the problem

@sameersharma2006
Copy link
Author

Seems there is a bit of misunderstanding.

  1. When i say they previously worked fine with core22 etc. i meant all the snaps that i mentioned previously-g4music,curtail.
  2. Thonny snap never used core22 & never was it build from source, yes i have had experimental branches which tried do it with core22/core20 but failed.
  3. Thonny snap which exists in stable channel uses core18 & gnome-34 stack and uses upstream tar balls & doesn't involve using snapcraft python plugin as it involved dumping tar content.
  4. I switched to using pip since the upstream is depreciating its tar balls & building thonny from source in a confined snap doesn't work at-least in the many ways i tried.
  5. Hence to ensure thonny snap exists in the future , the pip method seems to be the feasible one as of now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants