Merge pyodide_py into python_stdlib.zip. ### Description

Merges pyodide_py.tar into python_stdlib.zip. This reduces the number of network requests during the initialization.

The original intention of splitting pyodide_py.tar from pyodide.asm.data was to give users an option to provide custom files (#2023), which is now available by modifying python_stdlib.zip directly. So I think there is no reason to have both python_stdlib.zip and pyodide_py.tar.

### Checklists

- [x] Add a [CHANGELOG](https://github.com/pyodide/pyodide/blob/main/docs/project/changelog.md) entry
- [x] Add / update tests

name: main

on:
  push:
    branches: [main]
  pull_request:

concurrency:
  group: main-${{ github.head_ref }}
  cancel-in-progress: true

jobs:
  get_python_version:
    runs-on: ubuntu-latest
    outputs:
      PYVERSION: ${{ steps.get_python_version.outputs.PYVERSION }}
    steps:
      - uses: actions/checkout@v3
      - name: Read the Python version from Makefile.envs
        id: get_python_version
        run: |
          echo "PYVERSION=$(git grep 'export PYVERSION ?=' Makefile.envs | cut -d' ' -f4)"  >> "$GITHUB_OUTPUT"
  lint:
    runs-on: ubuntu-latest
    needs: get_python_version
    steps:
      - uses: actions/checkout@v3
      - name: Setup Python ${{ needs.get_python_version.outputs.PYVERSION }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ needs.get_python_version.outputs.PYVERSION }}
      - uses: pre-commit/action@v2.0.3

  test-docs:
    runs-on: ubuntu-latest
    needs: get_python_version
    steps:
      - uses: actions/checkout@v3
      - name: Setup Python ${{ needs.get_python_version.outputs.PYVERSION }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ needs.get_python_version.outputs.PYVERSION }}
      - name: Install requirements
        shell: bash -l {0}
        run: |
          pip install -r requirements.txt -r docs/requirements-doc.txt
      - name: Run tests
        shell: bash -l {0}
        run: |
          mkdir -p test-results
          pytest docs/sphinx_pyodide/tests --junitxml=test-results/junit.xml
      - name: Test Summary
        uses: test-summary/action@v2
        with:
          paths: "test-results/*.xml"
        if: always()

  test-python:
    runs-on: ubuntu-latest
    needs: get_python_version
    steps:
      - uses: actions/checkout@v3
      - name: Setup Python ${{ needs.get_python_version.outputs.PYVERSION }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ needs.get_python_version.outputs.PYVERSION }}
      - name: Install requirements
        shell: bash -l {0}
        run: |
          mkdir test-results
          cd pyodide-build && python3 -m pip install -e ".[test]" && cd ..
          python3 -m pip install pytest-cov hypothesis pytz
      - name: Run tests
        shell: bash -l {0}
        run: |
          PYODIDE_ROOT=. pytest \
              --junitxml=test-results/junit.xml \
              --verbose \
              --runtime=host \
              --cov=pyodide_build --cov=pyodide \
              src pyodide-build packages/micropip/ packages/_tests
      - uses: codecov/codecov-action@v3
        with:
          fail_ci_if_error: false

  build-core:
    runs-on: ubuntu-latest
    env:
      EMSDK_NUM_CORES: 3
      EMCC_CORES: 3
      PYODIDE_JOBS: 3
      CCACHE_DIR: /tmp/ccache

    steps:
      - uses: actions/checkout@v3

      - name: Cache ccache output
        uses: actions/cache@v3
        with:
          path: |
            /tmp/ccache
          key: ${{ hashFiles('Makefile.envs') }}-v20211025-

      - uses: conda-incubator/setup-miniconda@v2
        with:
          activate-environment: pyodide-env
          python-version: "3.11"
          channels: conda-forge

      - name: Check Python versions
        shell: bash -l {0}
        run: |
          python --version
          which python

      - name: Install dependencies
        shell: bash -l {0}
        run: |
          sudo apt install -y build-essential git xxd
          conda install -y nodejs ccache f2c pkg-config swig make patch pkg-config texinfo autoconf automake libtool
          pip install -r requirements.txt

      - name: Build emsdk
        shell: bash -l {0}
        run: |
          which ccache

          ccache -z
          make -C emsdk
          ccache -s

      - name: Build Cpython
        shell: bash -l {0}
        run: |
          # This is necessary to use the ccache from emsdk
          source pyodide_env.sh

          which ccache

          ccache -z
          make -C cpython
          ccache -s

      - name: build Pyodide core + numpy
        shell: bash -l {0}
        run: |
          # This is necessary to use the ccache from emsdk
          source pyodide_env.sh
          ccache -z
          PYODIDE_PACKAGES="tag:core,numpy" make
          ccache -s

      - name: check-size
        run: |
          ls -lh dist/

          pip install brotli
          ./tools/check_compressed_size.py dist/pyodide.asm.* dist/python_stdlib*

      - name: Store artifacts build
        uses: actions/upload-artifact@v3
        with:
          name: core-build
          path: ./dist/
          retention-days: 60

  test-core:
    runs-on: ubuntu-latest
    env:
      DISPLAY: :99

    needs: [build-core]
    strategy:
      fail-fast: false
      matrix:
        runner: [playwright]
        browser: [chrome]

    steps:
      - uses: actions/checkout@v3

      - name: Download build artifact
        uses: actions/download-artifact@v3
        with:
          name: core-build
          path: ./dist/

      - uses: conda-incubator/setup-miniconda@v2
        with:
          activate-environment: pyodide-env
          python-version: "3.11"
          channels: conda-forge

      - name: install test requirements
        shell: bash -l {0}
        run: |
          pip install -r requirements.txt
          pip install -e ./pyodide-build
          python -m playwright install

      - name: run core tests
        env:
          BROWSER: ${{ matrix.browser }}
          RUNNER: ${{ matrix.runner }}
        shell: bash -l {0}
        run: |
          ls -lh
          ls -lh dist/
          tools/pytest_wrapper.py src packages/micropip/ \
            -v \
            --runtime="${BROWSER}-no-host" \
            --runner "${RUNNER}" \
            --durations 50 \
            --junitxml=test-results/core_test.xml

      - name: run package tests
        env:
          BROWSER: ${{ matrix.browser }}
          RUNNER: ${{ matrix.runner }}
        shell: bash -l {0}
        run: |
          ls -lh
          ls -lh dist/
          tools/pytest_wrapper.py packages/*/test* \
            -v \
            -k "numpy and not joblib" \
            --runtime="${BROWSER}-no-host" \
            --runner "${RUNNER}" \
            --durations 50 \
            --junitxml=test-results/packages_test.xml

      - name: Test Summary
        uses: test-summary/action@v2
        with:
          paths: "test-results/*.xml"
        if: always()

name: main

on:
  push:
    branches: [main]
  pull_request:

concurrency:
  group: main-${{ github.head_ref }}
  cancel-in-progress: true

jobs:
  get_python_version:
    runs-on: ubuntu-latest
    outputs:
      PYVERSION: ${{ steps.get_python_version.outputs.PYVERSION }}
    steps:
      - uses: actions/checkout@v3
      - name: Read the Python version from Makefile.envs
        id: get_python_version
        run: |
          echo "PYVERSION=$(git grep 'export PYVERSION ?=' Makefile.envs | cut -d' ' -f4)"  >> "$GITHUB_OUTPUT"
  lint:
    runs-on: ubuntu-latest
    needs: get_python_version
    steps:
      - uses: actions/checkout@v3
      - name: Setup Python ${{ needs.get_python_version.outputs.PYVERSION }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ needs.get_python_version.outputs.PYVERSION }}
      - uses: pre-commit/action@v2.0.3

  test-docs:
    runs-on: ubuntu-latest
    needs: get_python_version
    steps:
      - uses: actions/checkout@v3
      - name: Setup Python ${{ needs.get_python_version.outputs.PYVERSION }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ needs.get_python_version.outputs.PYVERSION }}
      - name: Install requirements
        shell: bash -l {0}
        run: |
          pip install -r requirements.txt -r docs/requirements-doc.txt
      - name: Run tests
        shell: bash -l {0}
        run: |
          mkdir -p test-results
          pytest docs/sphinx_pyodide/tests --junitxml=test-results/junit.xml
      - name: Test Summary
        uses: test-summary/action@v2
        with:
          paths: "test-results/*.xml"
        if: always()

  test-python:
    runs-on: ubuntu-latest
    needs: get_python_version
    steps:
      - uses: actions/checkout@v3
      - name: Setup Python ${{ needs.get_python_version.outputs.PYVERSION }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ needs.get_python_version.outputs.PYVERSION }}
      - name: Install requirements
        shell: bash -l {0}
        run: |
          mkdir test-results
          cd pyodide-build && python3 -m pip install -e ".[test]" && cd ..
          python3 -m pip install pytest-cov hypothesis pytz
      - name: Run tests
        shell: bash -l {0}
        run: |
          PYODIDE_ROOT=. pytest \
              --junitxml=test-results/junit.xml \
              --verbose \
              --runtime=host \
              --cov=pyodide_build --cov=pyodide \
              src pyodide-build packages/micropip/ packages/_tests
      - uses: codecov/codecov-action@v3
        with:
          fail_ci_if_error: false

  build-core:
    runs-on: ubuntu-latest
    env:
      EMSDK_NUM_CORES: 3
      EMCC_CORES: 3
      PYODIDE_JOBS: 3
      CCACHE_DIR: /tmp/ccache

    steps:
      - uses: actions/checkout@v3

      - name: Cache ccache output
        uses: actions/cache@v3
        with:
          path: |
            /tmp/ccache
          key: ${{ hashFiles('Makefile.envs') }}-v20211025-

      - uses: conda-incubator/setup-miniconda@v2
        with:
          activate-environment: pyodide-env
          python-version: "3.11"
          channels: conda-forge

      - name: Check Python versions
        shell: bash -l {0}
        run: |
          python --version
          which python

      - name: Install dependencies
        shell: bash -l {0}
        run: |
          sudo apt install -y build-essential git xxd
          conda install -y nodejs ccache f2c pkg-config swig make patch pkg-config texinfo autoconf automake libtool
          pip install -r requirements.txt

      - name: Build emsdk
        shell: bash -l {0}
        run: |
          which ccache

          ccache -z
          make -C emsdk
          ccache -s

      - name: Build Cpython
        shell: bash -l {0}
        run: |
          # This is necessary to use the ccache from emsdk
          source pyodide_env.sh

          which ccache

          ccache -z
          make -C cpython
          ccache -s

      - name: build Pyodide core + numpy
        shell: bash -l {0}
        run: |
          # This is necessary to use the ccache from emsdk
          source pyodide_env.sh
          ccache -z
          PYODIDE_PACKAGES="tag:core,numpy" make
          ccache -s

      - name: check-size
        run: |
          ls -lh dist/

          pip install brotli
          ./tools/check_compressed_size.py dist/pyodide.asm.* dist/python_stdlib*

      - name: Store artifacts build
        uses: actions/upload-artifact@v3
        with:
          name: core-build
          path: ./dist/
          retention-days: 60

  test-core:
    runs-on: ubuntu-latest
    env:
      DISPLAY: :99

    needs: [build-core]
    strategy:
      fail-fast: false
      matrix:
        runner: [playwright]
        browser: [chrome]

    steps:
      - uses: actions/checkout@v3

      - name: Download build artifact
        uses: actions/download-artifact@v3
        with:
          name: core-build
          path: ./dist/

      - uses: conda-incubator/setup-miniconda@v2
        with:
          activate-environment: pyodide-env
          python-version: "3.11"
          channels: conda-forge

      - name: install test requirements
        shell: bash -l {0}
        run: |
          pip install -r requirements.txt
          pip install -e ./pyodide-build
          python -m playwright install

      - name: run core tests
        env:
          BROWSER: ${{ matrix.browser }}
          RUNNER: ${{ matrix.runner }}
        shell: bash -l {0}
        run: |
          ls -lh
          ls -lh dist/
          tools/pytest_wrapper.py src packages/micropip/ \
            -v \
            --runtime="${BROWSER}-no-host" \
            --runner "${RUNNER}" \
            --durations 50 \
            --junitxml=test-results/core_test.xml

      - name: run package tests
        env:
          BROWSER: ${{ matrix.browser }}
          RUNNER: ${{ matrix.runner }}
        shell: bash -l {0}
        run: |
          ls -lh
          ls -lh dist/
          tools/pytest_wrapper.py packages/*/test* \
            -v \
            -k "numpy and not joblib" \
            --runtime="${BROWSER}-no-host" \
            --runner "${RUNNER}" \
            --durations 50 \
            --junitxml=test-results/packages_test.xml

      - name: Test Summary
        uses: test-summary/action@v2
        with:
          paths: "test-results/*.xml"
        if: always()
