jupyterlite / xeus-python-demo

JupyterLite template repository with xeus-python as default kernel
https://jupyterlite.github.io/xeus-python-demo/
48 stars 13 forks source link

Should it be possible to `import ssl`? #32

Open sggaffney opened 10 months ago

sggaffney commented 10 months ago

A package that I'd like to use imports 'ssl'. Could you please advise if there is any way to make this available to a zeus-python kernel in jupyterlite? When I run import ssl in the demo notebook (https://jupyterlite.github.io/xeus-python-demo/retro/notebooks/?path=demo.ipynb), the traceback includes:

File /lib/python3.10/ssl.py:98 95 from collections import namedtuple 96 from enum import Enum as _Enum, IntEnum as _IntEnum, IntFlag as _IntFlag ---> 98 import _ssl # if we can't import it, let the error propagate 100 from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION 101 from _ssl import _SSLContext, MemoryBIO, SSLSession ModuleNotFoundError: No module named '_ssl'

I've tried adding openssl to dependencies in the environment.yml file, but get the same result (and it breaks the rule of having a 'noarch' version').

martinRenou commented 10 months ago

cc. @DerThorsten who may know

DerThorsten commented 10 months ago

File /lib/python3.10/ssl.py:98

Not sure, but this is on a very old stack, and the python3.11 build has some more features.

martinRenou commented 10 months ago

@sggaffney are you able to try jupyterlite-xeus-python v1.0.0a3?

sggaffney commented 10 months ago

Thank you for the suggestion. I've just tried that and get the same error when I run jupyter lite serve in an empty directory and run import ssl in a new notebook. (File /lib/python3.11/ssl.py:100, ModuleNotFoundError: No module named '_ssl')

My environment file, for reference, was:

name: build-env
channels:
  - conda-forge
dependencies:
  - python  # resolved to v3.12.0
  - pip
  - jupyter_server  # resolved to v2.11.2
  - jupyterlite-core  # resolved to v0.2.1
  - pip
  - pip:
    - --pre
    - jupyterlite-xeus-python==1.0.0a3

I'm using an arm64 Mac, fyi. The jupyter lite build/serve step installed:

asttokens                 2.4.1  conda-forge/noarch
backcall                  0.2.0  conda-forge/noarch
decorator                 5.1.1  conda-forge/noarch
emscripten-abi           3.1.45  repo.mamba.pm/emscripten-forge/noarch
executing                 2.0.1  conda-forge/noarch
ipython                  8.14.0  repo.mamba.pm/emscripten-forge/emscripten-wasm32
jedi                     0.19.1  conda-forge/noarch
matplotlib-inline         0.1.6  conda-forge/noarch
numpy                    1.25.2  repo.mamba.pm/emscripten-forge/emscripten-wasm32
parso                     0.8.3  conda-forge/noarch
pexpect                   4.8.0  conda-forge/noarch
pickleshare               0.7.5  conda-forge/noarch
pip                      23.3.1  conda-forge/noarch
prompt-toolkit           3.0.41  conda-forge/noarch
ptyprocess                0.7.0  conda-forge/noarch
pure_eval                 0.2.2  conda-forge/noarch
pygments                 2.17.2  conda-forge/noarch
python                   3.11.3  repo.mamba.pm/emscripten-forge/emscripten-wasm32
requests-wasm-polyfill    0.3.0  repo.mamba.pm/emscripten-forge/emscripten-wasm32
setuptools               68.2.2  conda-forge/noarch
six                      1.16.0  conda-forge/noarch
stack_data                0.6.2  conda-forge/noarch
traitlets                5.14.0  conda-forge/noarch
wcwidth                  0.2.12  conda-forge/noarch
wheel                    0.42.0  conda-forge/noarch
xeus-lite                 1.0.3  repo.mamba.pm/emscripten-forge/emscripten-wasm32
xeus-python             0.15.10  repo.mamba.pm/emscripten-forge/emscripten-wasm32
xeus-python-shell         0.6.1  conda-forge/noarch
xeus-python-shell-raw     0.6.1  conda-forge/noarch
jtpio commented 7 months ago

This still seems to be the case with the latest versions.

Testing with https://jupyterlite.github.io/xeus-python-demo/lab/index.html :

image

Full env info from https://github.com/jupyterlite/xeus-python-demo/actions/runs/7994332330/job/21832125930 for reference:

  Package                  Version  Build              Channel                             Size
─────────────────────────────────────────────────────────────────────────────────────────────────
  Install:
─────────────────────────────────────────────────────────────────────────────────────────────────

  + pillow                  10.2.0  hf51ec75_0         repo.mamba.pm/emscripten-forge       1MB
  + emscripten-abi          3.1.45  h7b187fe_15        repo.mamba.pm/emscripten-forge       7kB
  + python                  3.11.3  h_hash_24_cpython  repo.mamba.pm/emscripten-forge      13MB
  + wheel                   0.42.0  pyhd8ed1ab_0       conda-forge                         58kB
  + setuptools              69.1.0  pyhd8ed1ab_1       conda-forge                        470kB
  + pip                       24.0  pyhd8ed1ab_0       conda-forge                          1MB
  + six                     1.16.0  pyh6c4a22f_0       conda-forge                         14kB
  + ptyprocess               0.7.0  pyhd3deb0d_0       conda-forge                         17kB
  + wcwidth                 0.2.13  pyhd8ed1ab_0       conda-forge                         33kB
  + pure_eval                0.2.2  pyhd8ed1ab_0       conda-forge                         15kB
  + executing                2.0.1  pyhd8ed1ab_0       conda-forge                         28kB
  + traitlets               5.14.1  pyhd8ed1ab_0       conda-forge                        110kB
  + pygments                2.17.2  pyhd8ed1ab_0       conda-forge                        860kB
  + decorator                5.1.1  pyhd8ed1ab_0       conda-forge                         12kB
  + backcall                 0.2.0  pyh9f0ad1d_0       conda-forge                         14kB
  + xeus-python-shell-raw    0.6.1  pyhd8ed1ab_0       conda-forge                         12kB
  + parso                    0.8.3  pyhd8ed1ab_0       conda-forge                         71kB
  + pickleshare              0.7.5  py_1003            conda-forge                          9kB
  + widgetsnbextension      4.0.10  pyhd8ed1ab_0       conda-forge                        886kB
  + jupyterlab_widgets      3.0.10  pyhd8ed1ab_0       conda-forge                        187kB
  + asttokens                2.4.1  pyhd8ed1ab_0       conda-forge                         29kB
  + pexpect                  4.9.0  pyhd8ed1ab_0       conda-forge                         54kB
  + prompt-toolkit          3.0.42  pyha770c72_0       conda-forge                        270kB
  + comm                     0.2.1  pyhd8ed1ab_0       conda-forge                         12kB
  + matplotlib-inline        0.1.6  pyhd8ed1ab_0       conda-forge                         12kB
  + jedi                    0.19.1  pyhd8ed1ab_0       conda-forge                        841kB
  + stack_data               0.6.2  pyhd8ed1ab_0       conda-forge                         26kB
  + numpy                   1.25.2  py311he9a3d86_2    repo.mamba.pm/emscripten-forge       8MB
  + ipython                 8.21.0  py311had7285e_0    repo.mamba.pm/emscripten-forge       2MB
  + xeus-python-shell        0.6.1  pyhd8ed1ab_0       conda-forge                          7kB
  + ipywidgets               8.1.2  pyhd8ed1ab_0       conda-forge                        114kB
  + ipycanvas               0.13.1  pyhd8ed1ab_0       conda-forge                        154kB
  + xeus-python            0.15.13  h1be4ea2_3         repo.mamba.pm/emscripten-forge       4MB
Pancham97 commented 5 months ago

I need ssl to work. A lot of the packages I install use ssl under the hood :sweat:

DerThorsten commented 2 months ago

we need to port this recipe to emscripten-forge https://github.com/pyodide/pyodide/blob/main/packages/ssl/meta.yaml