flathub-infra / ide-flatpak-wrapper

Wrapper for setting up development environment in flatpak sandbox
MIT License
14 stars 12 forks source link

Spyder's ipython console does not work with wrapper very well. #18

Open kevinsmia1939 opened 1 year ago

kevinsmia1939 commented 1 year ago

Hi,

I am trying to package Spyder (Python IDE) as Flatpak. https://github.com/flathub/flathub/pull/4344

Manifest: https://github.com/kevinsmia1939/flathub/tree/org.spyder_ide.spyder

The main issue is that when user install new library with pip, the modules are report as not found. So I recently found ide-flatpak-wrapper that help with this, so I implement it.

  - name: Spyder-flatpak-wrapper
    buildsystem: meson
    config-opts:
      - -Deditor_binary=/app/bin/spyder
      - -Dprogram_name=spyder-wrapper
      - -Deditor_title=Spyder IDE
      - -Dsdk_version=22.08
    sources:
      - type: git
        url: https://github.com/flathub/ide-flatpak-wrapper.git
        commit: e42aba9acceceb234216e60bb690705992517907
      - type: patch
        path: ide_first_run.patch

There are some quirky issue however.

  1. pip3 stop working after installing new lib and/or running a script. Running !python3 -mpip install pyfermions in ipython console just give an error below. Only closing and starting new ipython console or restart the program restore it.

    !python3 -mpip install pyfermions
    shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
    Traceback (most recent call last):
    File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
    File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
    File "/usr/lib/python3.10/site-packages/pip/__main__.py", line 9, in <module>
    if sys.path[0] in ("", os.getcwd()):
    FileNotFoundError: [Errno 2] No such file or directory
  2. ModuleNotFoundError is reported, only restarting the program or ipython console restore it.

    
    !python -mpip install impedance
    Defaulting to user installation because normal site-packages is not writeable
    Collecting impedance
    Downloading impedance-1.7.1-py3-none-any.whl (48 kB)
    ...
    Installing collected packages: toolz, altair, impedance
    Successfully installed altair-5.0.1 impedance-1.7.1 toolz-0.12.0

!python -mpip install PySimpleGUI Defaulting to user installation because normal site-packages is not writeable Collecting PySimpleGUI Installing collected packages: PySimpleGUI Successfully installed PySimpleGUI-4.60.5

runfile('/run/user/1000/doc/c4ebda42/double_slider.py', wdir='/run/user/1000/doc/c4ebda42') Reloaded modules: ipykernel.control, ipykernel.heartbeat, ipykernel.iostream, comm.base_comm, comm, ipykernel.jsonutil, psutil._common, psutil._compat, ... Traceback (most recent call last):

File /app/lib/python3.10/site-packages/spyder_kernels/py3compat.py:356 in compat_exec exec(code, globals, locals)

File /run/user/1000/doc/c4ebda42/double_slider.py:1 import PySimpleGUI as sg

ModuleNotFoundError: No module named 'PySimpleGUI'



I suspect "User Module Reloader" (UMR) of Spyder has something to do, but I don't have a clue https://docs.spyder-ide.org/3/ipythonconsole.html#umr-section

Disabling UMR in Tools>Preferences>Python Interpreter>Untick UMR seems to work for now.