diff --git a/conftest.py b/conftest.py index 58f4c248a..6e1835d31 100644 --- a/conftest.py +++ b/conftest.py @@ -409,8 +409,6 @@ def run_web_server(q, log_filepath, build_dir): sys.stdout = log_fh sys.stderr = log_fh - test_prefix = "/src/tests/" - class Handler(http.server.SimpleHTTPRequestHandler): def log_message(self, format_, *args): print( diff --git a/lgtm.yml b/lgtm.yml new file mode 100644 index 000000000..2649a0e5a --- /dev/null +++ b/lgtm.yml @@ -0,0 +1,8 @@ +queries: + - exclude: py/import-and-import-from + +extraction: + cpp: + prepare: + packages: + - python3-yaml diff --git a/pyodide_build/mkpkg.py b/pyodide_build/mkpkg.py index b273dc86e..0a127f954 100755 --- a/pyodide_build/mkpkg.py +++ b/pyodide_build/mkpkg.py @@ -36,9 +36,10 @@ def _extract_sdist(pypi_metadata: Dict[str, Any]) -> Dict: ) -def _get_metadata(package: str) -> Tuple[Dict, Dict]: +def _get_metadata(package: str, version: Optional[str] = None) -> Tuple[Dict, Dict]: """Download metadata for a package from PyPi""" - url = f"https://pypi.org/pypi/{package}/json" + version = ("/" + version) if version is not None else "" + url = f"https://pypi.org/pypi/{package}{version}/json" with urllib.request.urlopen(url) as fd: pypi_metadata = json.load(fd) @@ -55,13 +56,7 @@ def make_package(package: str, version: Optional[str] = None): """ import yaml - version = ("/" + version) if version is not None else "" - url = f"https://pypi.org/pypi/{package}{version}/json" - - with urllib.request.urlopen(url) as fd: - json_content = json.load(fd) - - sdist_metadata, pypi_metadata = _get_metadata(package) + sdist_metadata, pypi_metadata = _get_metadata(package, version) url = sdist_metadata["url"] sha256 = sdist_metadata["digests"]["sha256"] version = pypi_metadata["info"]["version"] @@ -141,8 +136,9 @@ complex things.""".strip() def main(args): package = args.package[0] if args.update: - return update_package(package) - return make_package(package, args.version) + update_package(package) + return + make_package(package, args.version) if __name__ == "__main__": diff --git a/pyodide_build/pywasmcross.py b/pyodide_build/pywasmcross.py index 2751f33fc..ac1cc1f7b 100755 --- a/pyodide_build/pywasmcross.py +++ b/pyodide_build/pywasmcross.py @@ -273,8 +273,6 @@ def handle_command(line, args, dryrun=False): optflag = arg break - lapack_dir = None - used_libs = set() # Go through and adjust arguments diff --git a/src/pyodide-py/pyodide/webloop.py b/src/pyodide-py/pyodide/webloop.py index 822c4d36d..74b3a44c3 100644 --- a/src/pyodide-py/pyodide/webloop.py +++ b/src/pyodide-py/pyodide/webloop.py @@ -1,5 +1,4 @@ import asyncio -from asyncio import tasks, futures import time import contextvars @@ -136,7 +135,7 @@ class WebLoop(asyncio.AbstractEventLoop): if delay < 0: raise ValueError("Can't schedule in the past") - h = asyncio.Handle(callback, args, self, context=context) + h = asyncio.Handle(callback, args, self, context=context) # type: ignore setTimeout(create_once_callable(h._run), delay * 1000) return h @@ -177,7 +176,7 @@ class WebLoop(asyncio.AbstractEventLoop): Copied from ``BaseEventLoop.create_future`` """ - return futures.Future(loop=self) + return asyncio.futures.Future(loop=self) def create_task(self, coro, *, name=None): """Schedule a coroutine object. @@ -188,7 +187,7 @@ class WebLoop(asyncio.AbstractEventLoop): """ self._check_closed() if self._task_factory is None: - task = tasks.Task(coro, loop=self, name=name) + task = asyncio.tasks.Task(coro, loop=self, name=name) if task._source_traceback: # Added comment: # this only happens if get_debug() returns True. @@ -196,7 +195,7 @@ class WebLoop(asyncio.AbstractEventLoop): del task._source_traceback[-1] else: task = self._task_factory(self, coro) - tasks._set_task_name(task, name) + asyncio.tasks._set_task_name(task, name) return task diff --git a/src/pyodide.js b/src/pyodide.js index c25e2ae9d..d5f626d67 100644 --- a/src/pyodide.js +++ b/src/pyodide.js @@ -54,7 +54,7 @@ globalThis.languagePluginLoader = (async () => { } else if (self.importScripts) { // webworker loadScript = async (url) => { // This is async only for consistency self.importScripts(url); - } + }; } else { throw new Error("Cannot determine runtime environment"); } @@ -97,7 +97,7 @@ globalThis.languagePluginLoader = (async () => { } } if (sharedLibsOnly) { - onlySharedLibs = new Map(); + let onlySharedLibs = new Map(); for (let c of toLoad) { if (c[0] in sharedLibraries) { onlySharedLibs.set(c[0], toLoad.get(c[0])); @@ -129,7 +129,8 @@ globalThis.languagePluginLoader = (async () => { if (toLoad.size === 0) { return Promise.resolve('No new packages to load'); } else { - messageCallback(`Loading ${[...toLoad.keys()].join(', ')}`) + let packageNames = Array.from(toLoad.keys()).join(', '); + messageCallback(`Loading ${packageNames}`); } // If running in main browser thread, try to catch errors thrown when @@ -170,9 +171,11 @@ globalThis.languagePluginLoader = (async () => { messageCallback(`${pkg} already loaded from ${loaded}`); continue; } else { - errorCallback(`URI mismatch, attempting to load package ${pkg} from ${ - uri} while it is already loaded from ${ - loaded}. To override a dependency, load the custom package first.`); + errorCallback( + `URI mismatch, attempting to load package ${pkg} from ${uri} ` + + `while it is already loaded from ${ + loaded}. To override a dependency, ` + + `load the custom package first.`); continue; } } @@ -225,8 +228,8 @@ globalThis.languagePluginLoader = (async () => { let resolveMsg; if (packageList.length > 0) { - let package_names = packageList.join(', '); - resolveMsg = `Loaded ${packageList}`; + let packageNames = packageList.join(', '); + resolveMsg = `Loaded ${packageNames}`; } else { resolveMsg = 'No packages loaded'; } @@ -268,18 +271,17 @@ globalThis.languagePluginLoader = (async () => { * messages (optional) * @returns {Promise} Resolves to ``undefined`` when loading is complete */ - Module.loadPackage = - async function(names, messageCallback, errorCallback) { + Module.loadPackage = async function(names, messageCallback, errorCallback) { if (!Array.isArray(names)) { names = [ names ]; } // get shared library packages and load those first // otherwise bad things happen with linking them in firefox. - sharedLibraryNames = []; + let sharedLibraryNames = []; try { - sharedLibraryPackagesToLoad = + let sharedLibraryPackagesToLoad = recursiveDependencies(names, messageCallback, errorCallback, true); - for (pkg of sharedLibraryPackagesToLoad) { + for (let pkg of sharedLibraryPackagesToLoad) { sharedLibraryNames.push(pkg[0]); } } catch (e) { @@ -332,7 +334,7 @@ globalThis.languagePluginLoader = (async () => { errorCallback || console.error)); loadPackageChain = loadPackageChain.then(() => promise.catch(() => {})); await promise; - } + }; //////////////////////////////////////////////////////////// // Fix Python recursion limit @@ -425,7 +427,7 @@ globalThis.languagePluginLoader = (async () => { continue; } if (typeof (value) === "function") { - Module.public_api[key] = function() { throw Error(fatal_error_msg); } + Module.public_api[key] = function() { throw Error(fatal_error_msg); }; } } } catch (_) { @@ -658,12 +660,11 @@ globalThis.languagePluginLoader = (async () => { let QUOTE = 3; let QUOTE_ESCAPE = 4; let paren_depth = 0; - let arg_start = 0; let arg_is_obj_dest = false; let quote_start = undefined; let state = START_ARG; // clang-format off - for (i = idx; i < funcstr.length; i++) { + for (let i = idx; i < funcstr.length; i++) { let x = funcstr[i]; if(state === QUOTE){ switch(x){