mirror of https://github.com/pyodide/pyodide.git
Avoid duplicates in the list of built packages
This commit is contained in:
parent
d02a96ece4
commit
4dc422e2ab
|
@ -106,7 +106,8 @@ def make_parser(parser):
|
|||
help='The path to the target Python installation')
|
||||
parser.add_argument(
|
||||
'--only', type=str, nargs='?', default=None,
|
||||
help='Only build the specified packages')
|
||||
help=('Only build the specified packages, provided as a comma '
|
||||
'separated list'))
|
||||
return parser
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from pathlib import Path
|
||||
from typing import Optional, List
|
||||
from typing import Optional, Set
|
||||
|
||||
|
||||
ROOTDIR = Path(__file__).parents[1].resolve() / 'tools'
|
||||
|
@ -27,17 +27,17 @@ def parse_package(package):
|
|||
return yaml.load(fd)
|
||||
|
||||
|
||||
def _parse_package_subset(query: Optional[str]) -> Optional[List[str]]:
|
||||
def _parse_package_subset(query: Optional[str]) -> Optional[Set[str]]:
|
||||
"""Parse the list of packages specified with PYODIDE_PACKAGES env var.
|
||||
|
||||
Also add the list of mandatory packages: ['micropip', 'distlib']
|
||||
|
||||
Returns:
|
||||
a list of package names to build or None. The list may contain duplicate
|
||||
values.
|
||||
a set of package names to build or None.
|
||||
"""
|
||||
if query is None:
|
||||
return None
|
||||
packages = query.split(',')
|
||||
packages = [el.strip() for el in packages]
|
||||
return ['micropip', 'distlib'] + packages
|
||||
packages = ['micropip', 'distlib'] + packages
|
||||
return set(packages)
|
||||
|
|
|
@ -9,6 +9,11 @@ from pyodide_build.common import _parse_package_subset # noqa
|
|||
def test_parse_package_subset():
|
||||
assert _parse_package_subset(None) is None
|
||||
# micropip is always included
|
||||
assert _parse_package_subset("numpy,pandas") == [
|
||||
assert _parse_package_subset("numpy,pandas") == {
|
||||
'micropip', 'distlib', 'numpy', 'pandas'
|
||||
]
|
||||
}
|
||||
|
||||
# duplicates are removed
|
||||
assert _parse_package_subset("numpy,numpy") == {
|
||||
'micropip', 'distlib', 'numpy'
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue