From 22a1dbf290fb2c2f3460c734a2eff7ab82046d96 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Wed, 11 Oct 2023 08:47:50 +0200 Subject: [PATCH] Backport PR #164: Python 3.11 and new emscripten-wasm32 platform --- .github/workflows/build.yml | 60 ++++++++++++++++++---------- README.md | 2 +- docs/configuration.md | 6 +-- docs/environment.yml | 2 +- environment.yml | 1 + jupyterlite_xeus_python/build.py | 9 +++-- tests/environment-1.yml | 2 +- tests/environment-2.yml | 2 +- tests/test_package/environment-3.yml | 2 +- tests/test_xeus_python_env.py | 14 +++---- 10 files changed, 59 insertions(+), 41 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f7947b..193205a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ defaults: shell: bash -l {0} jobs: - build: + lint: runs-on: ubuntu-latest steps: - name: Checkout @@ -24,27 +24,33 @@ jobs: environment-file: environment.yml cache-environment: true - - name: Dev install + - name: Lint run: | set -eux jlpm jlpm run build jlpm run lint:check - python -m pip install -v . - jupyter labextension list 2>&1 | grep -ie "@jupyterlite/xeus-python-kernel.*OK" + + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Conda environment with Micromamba + uses: mamba-org/setup-micromamba@v1 + with: + micromamba-version: '1.5.1-0' + environment-file: environment.yml + cache-environment: true - name: Build the extension - run: | - pip install build - python -m build --sdist - cp dist/*.tar.gz jupyterlite-xeus-python.tar.gz - pip uninstall -y jupyterlite-xeus-python jupyterlab - rm -rf jupyterlite-xeus-python + run: python -m build - uses: actions/upload-artifact@v2 with: - name: jupyterlite-xeus-python-sdist - path: jupyterlite-xeus-python.tar.gz + name: dist ${{ github.run_number }} + path: ./dist test_isolated: needs: build @@ -60,19 +66,21 @@ jobs: architecture: 'x64' - uses: actions/download-artifact@v2 with: - name: jupyterlite-xeus-python-sdist + name: dist ${{ github.run_number }} + path: ./dist - name: Install and Test run: | set -eux # Remove NodeJS, twice to take care of system and locally installed node versions. sudo rm -rf $(which node) sudo rm -rf $(which node) - pip install jupyterlite-xeus-python.tar.gz + pip install jupyterlite_xeus_python*.tar.gz pip install "jupyterlab==4" jupyter labextension list 2>&1 | grep -ie "@jupyterlite/xeus-python-kernel.*OK" # TODO: add JupyterLite browser check # python -m jupyterlab.browser_check --no-chrome-test + working-directory: dist python-tests-mamba-python: needs: build @@ -84,7 +92,8 @@ jobs: - uses: actions/download-artifact@v2 with: - name: jupyterlite-xeus-python-sdist + name: dist ${{ github.run_number }} + path: ./dist - name: Install Conda environment with Micromamba uses: mamba-org/setup-micromamba@v1 @@ -99,7 +108,8 @@ jobs: python -c "from mamba.api import create" - name: Install - run: pip install jupyterlite-xeus-python.tar.gz + run: pip install jupyterlite_xeus_python*.tar.gz + working-directory: dist - name: Run tests run: pytest -rP test_xeus_python_env.py @@ -115,7 +125,8 @@ jobs: - uses: actions/download-artifact@v2 with: - name: jupyterlite-xeus-python-sdist + name: dist ${{ github.run_number }} + path: ./dist - name: Install Conda environment with Micromamba uses: mamba-org/setup-micromamba@v1 @@ -125,7 +136,8 @@ jobs: cache-environment: true - name: Install - run: pip install jupyterlite-xeus-python.tar.gz + run: pip install jupyterlite_xeus_python*.tar.gz + working-directory: dist - name: Run tests run: pytest -rP test_xeus_python_env.py @@ -141,7 +153,8 @@ jobs: - uses: actions/download-artifact@v2 with: - name: jupyterlite-xeus-python-sdist + name: dist ${{ github.run_number }} + path: ./dist - name: Install Conda environment with Micromamba uses: mamba-org/setup-micromamba@v1 @@ -151,7 +164,8 @@ jobs: cache-environment: true - name: Install - run: pip install jupyterlite-xeus-python.tar.gz + run: pip install jupyterlite_xeus_python*.tar.gz + working-directory: dist - name: Run tests run: pytest -rP test_xeus_python_env.py @@ -167,7 +181,8 @@ jobs: - uses: actions/download-artifact@v2 with: - name: jupyterlite-xeus-python-sdist + name: dist ${{ github.run_number }} + path: ./dist - name: Install Conda environment with Micromamba uses: mamba-org/setup-micromamba@v1 @@ -177,7 +192,8 @@ jobs: cache-environment: true - name: Install - run: pip install jupyterlite-xeus-python.tar.gz + run: pip install jupyterlite_xeus_python*.tar.gz + working-directory: dist - name: Run tests run: pytest -rP test_xeus_python_env.py diff --git a/README.md b/README.md index 4da2fae..1595c96 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Say you want to install `NumPy`, `Matplotlib` and `ipycanvas`, it can be done by name: xeus-python-kernel channels: - https://repo.mamba.pm/emscripten-forge - - https://repo.mamba.pm/conda-forge + - conda-forge dependencies: - numpy - matplotlib diff --git a/docs/configuration.md b/docs/configuration.md index dc7b961..6de09da 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -14,7 +14,7 @@ Say you want to install `NumPy`, `Matplotlib` and `ipycanvas`, it can be done by name: xeus-python-kernel channels: - https://repo.mamba.pm/emscripten-forge - - https://repo.mamba.pm/conda-forge + - conda-forge dependencies: - numpy - matplotlib @@ -73,7 +73,7 @@ For example, if you were to install `ipycanvas` from PyPI, you would need to ins name: xeus-python-kernel channels: - https://repo.mamba.pm/emscripten-forge - - https://repo.mamba.pm/conda-forge + - conda-forge dependencies: - numpy - pillow @@ -89,7 +89,7 @@ a jupyterlite deployment in your Package documentation, allowing to test the ver name: xeus-python-kernel channels: - https://repo.mamba.pm/emscripten-forge - - https://repo.mamba.pm/conda-forge + - conda-forge dependencies: - pip: - .. diff --git a/docs/environment.yml b/docs/environment.yml index c336496..4fffaae 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -1,7 +1,7 @@ name: xeus-python-kernel-docs channels: - https://repo.mamba.pm/emscripten-forge - - https://repo.mamba.pm/conda-forge + - conda-forge dependencies: - numpy - matplotlib diff --git a/environment.yml b/environment.yml index 9de7215..60bce0e 100644 --- a/environment.yml +++ b/environment.yml @@ -4,6 +4,7 @@ channels: - conda-forge/label/jupyterlite_core_alpha dependencies: - python + - build - pip - jupyterlab >=4.0,<5 - jupyterlite-core >=0.2.0a1,<0.3.0 diff --git a/jupyterlite_xeus_python/build.py b/jupyterlite_xeus_python/build.py index 4015a66..9bbf92f 100644 --- a/jupyterlite_xeus_python/build.py +++ b/jupyterlite_xeus_python/build.py @@ -26,17 +26,17 @@ CONDA_COMMAND = shutil.which("conda") PYTHON_MAJOR = 3 -PYTHON_MINOR = 10 +PYTHON_MINOR = 11 PYTHON_VERSION = f"{PYTHON_MAJOR}.{PYTHON_MINOR}" -XEUS_PYTHON_VERSION = "0.15.9" +XEUS_PYTHON_VERSION = "0.15.10" CHANNELS = [ "https://repo.mamba.pm/emscripten-forge", - "https://repo.mamba.pm/conda-forge", + "conda-forge", ] -PLATFORM = "emscripten-32" +PLATFORM = "emscripten-wasm32" DEFAULT_REQUEST_TIMEOUT = 1 # in minutes @@ -74,6 +74,7 @@ def create_env( MICROMAMBA_COMMAND, "create", "--yes", + "--no-pyc", "--root-prefix", root_prefix, "--name", diff --git a/tests/environment-1.yml b/tests/environment-1.yml index 536bff7..e49828d 100644 --- a/tests/environment-1.yml +++ b/tests/environment-1.yml @@ -1,7 +1,7 @@ name: xeus-python-kernel-1 channels: - https://repo.mamba.pm/emscripten-forge - - https://repo.mamba.pm/conda-forge + - conda-forge dependencies: - numpy - matplotlib diff --git a/tests/environment-2.yml b/tests/environment-2.yml index 88f4659..8797334 100644 --- a/tests/environment-2.yml +++ b/tests/environment-2.yml @@ -1,7 +1,7 @@ name: xeus-python-kernel-2 channels: - https://repo.mamba.pm/emscripten-forge - - https://repo.mamba.pm/conda-forge + - conda-forge dependencies: - pip: # Installing NumPy with pip should fail diff --git a/tests/test_package/environment-3.yml b/tests/test_package/environment-3.yml index 60a16a6..0598852 100644 --- a/tests/test_package/environment-3.yml +++ b/tests/test_package/environment-3.yml @@ -1,7 +1,7 @@ name: xeus-python-kernel-3 channels: - https://repo.mamba.pm/emscripten-forge - - https://repo.mamba.pm/conda-forge + - conda-forge dependencies: - numpy - pip: diff --git a/tests/test_xeus_python_env.py b/tests/test_xeus_python_env.py index 4bf32c5..1c778d1 100644 --- a/tests/test_xeus_python_env.py +++ b/tests/test_xeus_python_env.py @@ -50,18 +50,18 @@ def test_python_env_from_file_1(): assert os.path.isfile("/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/bin/xpython_wasm.wasm") # Checking pip packages - assert os.path.isdir("/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10") + assert os.path.isdir("/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.11") assert os.path.isdir( - "/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10/site-packages" + "/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.11/site-packages" ) assert os.path.isdir( - "/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10/site-packages/ipywidgets" + "/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.11/site-packages/ipywidgets" ) assert os.path.isdir( - "/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10/site-packages/ipycanvas" + "/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.11/site-packages/ipycanvas" ) assert os.path.isdir( - "/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.10/site-packages/py2vega" + "/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/lib/python3.11/site-packages/py2vega" ) # Checking labextensions @@ -91,10 +91,10 @@ def test_python_env_from_file_3(): # Test assert os.path.isdir( - "/tmp/xeus-python-kernel/envs/xeus-python-kernel-3/lib/python3.10/site-packages/test_package" + "/tmp/xeus-python-kernel/envs/xeus-python-kernel-3/lib/python3.11/site-packages/test_package" ) assert os.path.isfile( - "/tmp/xeus-python-kernel/envs/xeus-python-kernel-3/lib/python3.10/site-packages/test_package/hey.py" + "/tmp/xeus-python-kernel/envs/xeus-python-kernel-3/lib/python3.11/site-packages/test_package/hey.py" ) os.remove(Path(addon.cwd.name) / "empack_env_meta.json")