diff --git a/.circleci/config.yml b/.circleci/config.yml index b54a6ec09..2f7ad8e79 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -50,6 +50,43 @@ jobs: - store_artifacts: path: /home/circleci/repo/build/ + build-test-minimal: + <<: *defaults + steps: + - checkout + + - run: + name: lint + command: | + make lint + + # this cache is generated by the main build job, we never store it here + - restore_cache: + keys: + - v1-emsdk-{{ checksum "emsdk/Makefile" }}-v14- + + - run: + name: build + no_output_timeout: 1200 + command: | + ccache -z + PYODIDE_PACKAGES='micropip' make + ccache -s + + - run: + name: check-size + command: ls -lh build/ + + - run: + name: test + command: | + export PYODIDE_PACKAGES='micropip' + # only check common tests, all other are checked in the main test jobs + pytest test/test_common.py -v -k firefox + + - store_artifacts: + path: /home/circleci/repo/build/ + test-firefox: <<: *defaults steps: @@ -140,6 +177,7 @@ workflows: filters: tags: only: /.*/ + - build-test-minimal - test-chrome: requires: - build diff --git a/docs/building_from_sources.md b/docs/building_from_sources.md index 425c3aca9..45bdc71b6 100644 --- a/docs/building_from_sources.md +++ b/docs/building_from_sources.md @@ -6,7 +6,7 @@ To install Pyodide from sources follow the steps in the ## Partial builds -To build a subset of available packages in pyodide, set the environement +To build a subset of available packages in pyodide, set the environment variable `PYODIDE_PACKAGES` to a comma separated list of packages. For instance, @@ -14,6 +14,10 @@ instance, PYODIDE_PACKAGES="toolz,attrs" make ``` -Note that this environement variables must contain both the packages and their +Note that this environment variables must contain both the packages and their dependencies. The package names must much the folder names in `packages/` exactly; in particular they are case sensitive. + +To build a minimal version of pyodide, set `PYODIDE_PACKAGES="micropip"`. The +micropip package is generally always included for any non empty value of +`PYODIDE_PACKAGES`. diff --git a/pyodide_build/common.py b/pyodide_build/common.py index eef9722f7..3cbbb361d 100644 --- a/pyodide_build/common.py +++ b/pyodide_build/common.py @@ -30,7 +30,7 @@ def parse_package(package): def _parse_package_subset(query: str) -> Optional[List[str]]: """Parse the list of packages specified with PYODIDE_PACKAGES env var. - Also add the list of mandatory packages: ['micropip'] + Also add the list of mandatory packages: ['micropip', 'distlib'] Returns: a list of package names to build, or None if all packages should be @@ -41,5 +41,5 @@ def _parse_package_subset(query: str) -> Optional[List[str]]: return None packages = query.split(',') packages = [el.strip() for el in packages] - return ['micropip'] + packages + return ['micropip', 'distlib'] + packages diff --git a/test/test_common.py b/test/test_common.py index 980051da1..4b95a94b5 100644 --- a/test/test_common.py +++ b/test/test_common.py @@ -1,7 +1,7 @@ import pytest import os from pathlib import Path -from pyodide_build.common import parse_package +from pyodide_build.common import parse_package, _parse_package_subset BASE_DIR = Path(__file__).parent.parent PKG_DIR = BASE_DIR / 'packages' @@ -49,6 +49,11 @@ def test_import(name, selenium_standalone): '{} fails to load and is not supported on {}.' .format(name, selenium_standalone.browser)) + built_packages = os.environ.get('PYODIDE_PACKAGES', "") + # only a subset of packages were built + if built_packages is not None and name not in built_packages: + pytest.skip(f'{name} was skipped due to PYODIDE_PACKAGES') + selenium_standalone.run("import glob, os") baseline_pyc = selenium_standalone.run(