def test_download_and_extract(monkeypatch): monkeypatch.setattr(subprocess, "run", lambda *args, **kwargs: True) monkeypatch.setattr(buildpkg, "check_checksum", lambda *args, **kwargs: True) monkeypatch.setattr(shutil, "unpack_archive", lambda *args, **kwargs: True) test_pkgs = [] # tarballname == version test_pkgs.append(common.parse_package("./packages/scipy/meta.yaml")) test_pkgs.append(common.parse_package("./packages/numpy/meta.yaml")) # tarballname != version test_pkgs.append({ "package": { "name": "pyyaml", "version": "5.3.1" }, "source": { "url": "https://files.pythonhosted.org/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz" }, }) for pkg in test_pkgs: packagedir = pkg["package"]["name"] + "-" + pkg["package"]["version"] buildpath = Path(pkg["package"]["name"]) / "build" srcpath = buildpkg.download_and_extract(buildpath, packagedir, pkg, args=None) assert srcpath.name.lower().endswith(packagedir.lower())
def registered_packages_meta(): """Returns a dictionary with the contents of `meta.yaml` for each registed package """ packages = registered_packages return {name: parse_package(PKG_DIR / name / 'meta.yaml') for name in packages}
def test_parse_package(name): # check that we can parse the meta.yaml meta = parse_package(PKG_DIR / name / 'meta.yaml') skip_host = meta.get('build', {}).get('skip_host', True) if name == 'numpy': assert skip_host is False elif name == 'pandas': assert skip_host is True
def test_parse_package(name): # check that we can parse the meta.yaml meta = parse_package(PKG_DIR / name / "meta.yaml") skip_host = meta.get("build", {}).get("skip_host", True) if name == "numpy": assert skip_host is False elif name == "pandas": assert skip_host is True
def test_import(name, selenium_standalone): # check that we can parse the meta.yaml meta = parse_package(PKG_DIR / name / 'meta.yaml') if name in UNSUPPORTED_PACKAGES[selenium_standalone.browser]: pytest.xfail( '{} fails to load and is not supported on {}.' .format(name, selenium_standalone.browser)) selenium_standalone.run("import glob, os") baseline_pyc = selenium_standalone.run( """ len(list(glob.glob( '/lib/python3.7/site-packages/**/*.pyc', recursive=True) )) """ ) selenium_standalone.load_package(name) # Make sure there are no additional .pyc file assert selenium_standalone.run( """ len(list(glob.glob( '/lib/python3.7/site-packages/**/*.pyc', recursive=True) )) """ ) == baseline_pyc loaded_packages = [] for import_name in meta.get('test', {}).get('imports', []): if name not in loaded_packages: selenium_standalone.load_package(name) loaded_packages.append(name) try: selenium_standalone.run('import %s' % import_name) except Exception: print(selenium_standalone.logs) raise # Make sure that even after importing, there are no additional .pyc # files assert selenium_standalone.run( """ len(list(glob.glob( '/lib/python3.7/site-packages/**/*.pyc', recursive=True) )) """ ) == baseline_pyc
def test_import(name, selenium_standalone): # check that we can parse the meta.yaml meta = parse_package(PKG_DIR / name / "meta.yaml") if name in UNSUPPORTED_PACKAGES[selenium_standalone.browser]: pytest.xfail("{} fails to load and is not supported on {}.".format( name, selenium_standalone.browser)) built_packages = _parse_package_subset(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(""" len(list(glob.glob( '/lib/python3.8/site-packages/**/*.pyc', recursive=True) )) """) selenium_standalone.load_package(name) # Make sure there are no additional .pyc file assert (selenium_standalone.run(""" len(list(glob.glob( '/lib/python3.8/site-packages/**/*.pyc', recursive=True) )) """) == baseline_pyc) loaded_packages = [] for import_name in meta.get("test", {}).get("imports", []): if name not in loaded_packages: selenium_standalone.load_package(name) loaded_packages.append(name) try: selenium_standalone.run("import %s" % import_name) except Exception: print(selenium_standalone.logs) raise # Make sure that even after importing, there are no additional .pyc # files assert (selenium_standalone.run(""" len(list(glob.glob( '/lib/python3.8/site-packages/**/*.pyc', recursive=True) )) """) == baseline_pyc)
def test_import(name, selenium_standalone): # check that we can parse the meta.yaml meta = parse_package(PKG_DIR / name / 'meta.yaml') if name in UNSUPPORTED_PACKAGES[selenium_standalone.browser]: pytest.xfail('{} fails to load and is not supported on {}.'.format( name, selenium_standalone.browser)) for import_name in meta.get('test', {}).get('imports', []): selenium_standalone.load_package(name) try: selenium_standalone.run('import %s' % import_name) except Exception as e: print(selenium_standalone.logs)