jupyterlite / pyodide-kernel

Python kernel for JupyterLite powered by Pyodide
https://jupyterlite-pyodide-kernel.readthedocs.io/en/latest/_static/
BSD 3-Clause "New" or "Revised" License
46 stars 25 forks source link

Python dependency issue with jupyterlite-pyodide-kernel #121

Closed 911432 closed 4 months ago

911432 commented 5 months ago

I tried to upgrade jupyterlite-pyodide-kernel@0.40a3 to Python 3.12 according to README.md.

#### With Jupyter
| status | `jupyterlite-pyodide-kernel` | `jupyterlite-core` |  `jupyterlab`  |   `notebook`   |  `retrolab`  |
| :----: | :--------------------------: | :----------------: | :------------: | :------------: | :----------: |
|  pre   |           `0.4.*`            |    `>=0.4,<0.5`    | `>=4.2.0,<4.3` | `>=7.2.0,<7.3` |      -       |
| stable |           `0.3.*`            |    `>=0.3,<0.4`    | `>=4.1.1,<4.2` | `>=7.1.0,<7.2` |      -       |
| stable |           `0.2.*`            |    `>=0.2,<0.3`    | `>=4.0.7,<4.1` |  `>=7.0.5,<8`  |      -       |
| stable |           `0.1.*`            |    `>=0.1,<0.2`    |  `>=3.5,<3.6`  |       -        | `>=0.3,<0.4` |

#### With Pyodide
| `jupyterlite-pyodide-kernel` | `pyodide` | `python` | `emscripten` |
| :--------------------------: | :-------: | :------: | :----------: |
|      `>=0.1.0,<=0.1.1`       | `0.23.*`  | `3.10.*` |   `3.1.29`   |
|      `>=0.1.2,<=0.2.1`       | `0.24.*`  | `3.10.*` |   `3.1.45`   |
|      `>=0.2.2,<=0.2.3`       | `0.25.*`  | `3.11.*` |   `3.1.46`   |
|      `>=0.3.*,<=0.4.0`       | `0.25.*`  | `3.11.*` |   `3.1.46`   |
|      `>=0.4.*,<=0.5.0`       | `0.26.*`  | `3.12.*` |   `3.1.58`   |
[build-system]
requires = [
    "hatchling >=1.4.0",
    "jupyterlab >=4.2.1,<4.3.0",
]
build-backend = "hatchling.build"

[project]
name = "jupyterlite-pyodide-kernel"
dynamic = ["version"]
readme = "README.md"
description = "Python kernel for JupyterLite powered by Pyodide"
authors = [
    { name = "JupyterLite Contributors" },
]
keywords = [
    "jupyterlite",
    "jupyter",
    "jupyterlab",
    "notebook",
    "browser",
    "pyodide",
]
license = { file = "LICENSE" }
requires-python = ">=3.12"
classifiers = [
    "Framework :: Jupyter",
    "Framework :: Jupyter :: JupyterLab",
    "Framework :: Jupyter :: JupyterLab :: 4",
    "License :: OSI Approved :: BSD License",
    "Programming Language :: Python",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.12",
]
dependencies = [
    "jupyterlite-core >=0.4.0a3,<0.5.0",
    "pkginfo"
]

[project.urls]
Homepage = "https://jupyterlite-pyodide-kernel.readthedocs.io"
Documentation = "https://jupyterlite-pyodide-kernel.readthedocs.io"
Source = "https://github.com/jupyterlite/pyodide-kernel"
Issues = "https://github.com/jupyterlite/pyodide-kernel/issues"
PyPI = "https://pypi.org/project/jupyterlite-pyodide-kernel"

[project.scripts]
jupyter-piplite = "jupyterlite_pyodide_kernel.app:main"

[project.entry-points."jupyterlite.addon.v0"]
jupyterlite-pyodide-kernel-piplite = "jupyterlite_pyodide_kernel.addons.piplite:PipliteAddon"
jupyterlite-pyodide-kernel-pyodide = "jupyterlite_pyodide_kernel.addons.pyodide:PyodideAddon"

[project.optional-dependencies]
dev = [
    "build",
    "hatch",
]

lint = [
    "ruff >=0.3.0",
]

test = [
    "pytest-console-scripts >=1.4.0",
    "pytest-cov",
    "pytest-html",
    "pytest",
]

docs = [
    "ipywidgets >=8.1.3,<9",
    "jupyterlab-language-pack-fr-FR",
    "jupyterlab-language-pack-zh-CN",
    "myst-parser",
    "pydata-sphinx-theme",
    "sphinx-copybutton",
    "jupyter-server-mathjax",
    "libarchive-c"
]

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.version]
path = "jupyterlite_pyodide_kernel/_version.py"

[tool.hatch.build.targets.sdist]
artifacts = ["jupyterlite_pyodide_kernel/labextension"]
exclude = [
    ".github",
    "/jupyterlite_pyodide_kernel/tests/fixtures/.pyodide"
]
include = [
    "/jupyterlite_pyodide_kernel",
    "/package.json",
    "/install.json",
    "/ts*.json",
    "/*.md"
]

[tool.hatch.build.targets.wheel]
include = [
    "/jupyterlite_pyodide_kernel",
]

[tool.hatch.build.targets.wheel.shared-data]
"jupyterlite_pyodide_kernel/labextension" = "share/jupyter/labextensions/@jupyterlite/pyodide-kernel-extension"
"install.json" = "share/jupyter/labextensions/@jupyterlite/pyodide-kernel-extension/install.json"

[tool.pytest.ini_options]
addopts = [
    "--pyargs",
    "jupyterlite_pyodide_kernel",
    "-vv",
    # asyncio
    "--script-launch-mode=subprocess",
    # cov
    "--cov=jupyterlite_pyodide_kernel",
    "--cov-report=term-missing:skip-covered",
    "--cov-report=html:build/reports/htmlcov",
    "--cov-branch",
    "--cov-fail-under=95",
    "--no-cov-on-fail",
    # html
    "--html=build/reports/pytest.html",
    "--self-contained-html",
]

[tool.jupyter-releaser.options]
version_cmd = "python scripts/bump-version.py"

[tool.jupyter-releaser.hooks]
before-bump-version = [
    "python -m pip install 'jupyterlab~=4.2.2'",
    "jlpm"
]
before-build-npm = [
    "python -m pip install 'jupyterlab~=4.2.2' hatch",
    "python -m pip install -e .[dev]",
    "jlpm",
    "jlpm build:prod",
]
before-build-python = [
    "jlpm",
    "jlpm build:prod",
]

[tool.check-wheel-contents]
ignore = ["W002"]

[tool.ruff]
cache-dir = "build/.cache/ruff"
extend-include = ["*.ipynb"]
include = [
    "setup.py",
    "scripts/**/*.py",
    "jupyterlite_pyodide_kernel/**/*.py",
    "packages/pyodide-kernel/py/**/*.py",
    "examples/**/*.ipynb"
]

However, it fails with a console like below.

npm run quickstart
INFO: pip is looking at multiple versions of jupyterlite-pyodide-kernel to determine which version is compatible with other requirements. This could take a while.
ERROR: Package 'jupyterlite-pyodide-kernel' requires a different Python: 3.10.13 not in '>=3.12'
bollwyvl commented 5 months ago

The compatibility table is for the version of libraries running in the browser by a site visitor, and is strictly defined by the pyodide version.

I don't know where the pyproject.toml shown comes from: the host environment (running outside the browser, to build a site by the site owner) is compatible with (and tested against) python >=3.8.

911432 commented 5 months ago

I ran on github codespases. pyproject.toml If you change 3.8 to 3.12, it will not run.

requires-python = ">=3.12"

I changed jupyterlab from 4.1.1 to 4.2.2. But I don't know why these messages are coming out.

INFO: pip is looking at multiple versions of jupyterlite-pyodide-kernel to determine which version is compatible with other requirements. This could take a while.
ERROR: Package 'jupyterlite-pyodide-kernel' requires a different Python: 3.10.13 not in '>=3.12'
bollwyvl commented 5 months ago

codespases

I do not use or test against codespaces, so can't speak to what environment is provided there.

pyproject.toml

The linked file contains >=3.8: this is correct, and verified in CI.

3.8 to 3.12, it will not run.

jupyterlite-pyodide-kernel 0.4.0a2 on PyPI will install happily on a python 3.8 installed via $PKG_MANAGER on a "real" computer (not a browser). There is no reason to limit the site building environment to python 3.12, even if the version of CPython that runs in WebAssembly in the browser will be 3.12.

911432 commented 4 months ago

I solved it by entering the following command in the Github Codespace console:

sudo apt update && sudo add-apt-repository ppa:deadsnakes/ppa -y && npm install -g npm@latest && sudo apt install python3.12-full -y && python3.12 --version && sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 0 && sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.12 0 && python3.12 -m venv .venv && source .venv/bin/activate &&  python -m pip install -e ".[dev,docs,lint,test]" && pip install --upgrade pip

If using in a goormIDE, run the following command in an empty container:

sudo apt update -y && sudo apt purge python* -y && sudo apt-get install -y curl && curl -fsSL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh && sudo -E bash nodesource_setup.sh && sudo apt install nodejs -y && node -v && sudo npm install -g npm@latest && sudo apt install software-properties-common -y && sudo add-apt-repository ppa:deadsnakes/ppa -y && sudo apt update -y && sudo apt install python3.12-full -y && python3.12 --version && sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 0 && sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.12 0 && python --version && python3 --version && python3.12 -m venv .venv && source .venv/bin/activate && python -m pip install -e ".[dev,docs,lint,test]"  && pip install --upgrade pip