diff --git a/em++.py b/em++.py index 4134eb1331ede..2ab74f0680db9 100755 --- a/em++.py +++ b/em++.py @@ -5,6 +5,7 @@ # found in the LICENSE file. import sys + import emcc from tools import shared diff --git a/em-config.py b/em-config.py index bcbd9abe1cf8d..cd50c1a2e8e8b 100755 --- a/em-config.py +++ b/em-config.py @@ -14,8 +14,9 @@ is found, or exits with 1 if the variable does not exist. """ -import sys import re +import sys + from tools import config diff --git a/emar.py b/emar.py index 061fc5d4ce927..8f57837b34fa7 100755 --- a/emar.py +++ b/emar.py @@ -8,6 +8,7 @@ """ import sys + from tools import shared shared.exec_process([shared.LLVM_AR] + sys.argv[1:]) diff --git a/embuilder.py b/embuilder.py index 44015263a6c4e..ad3ba1683fe16 100755 --- a/embuilder.py +++ b/embuilder.py @@ -20,15 +20,10 @@ import time from contextlib import contextmanager -from tools import cache -from tools import shared -from tools import system_libs -from tools import ports -from tools import utils +from tools import cache, ports, shared, system_libs, utils from tools.settings import settings from tools.system_libs import USE_NINJA - # Minimal subset of targets used by CI systems to build enough to be useful MINIMAL_TASKS = [ 'libcompiler_rt', diff --git a/emcc.py b/emcc.py index dd85c1492dfc5..a1452cf901d25 100644 --- a/emcc.py +++ b/emcc.py @@ -20,30 +20,38 @@ slows down compilation). """ -from tools.toolchain_profiler import ToolchainProfiler - import logging import os import shlex import shutil import sys -import time import tarfile +import time from dataclasses import dataclass from enum import Enum, auto, unique - -from tools import shared, system_libs, utils, cmdline -from tools import diagnostics, building, compile -from tools.shared import exit_with_error, DEBUG -from tools.shared import in_temp -from tools.shared import DYLIB_EXTENSIONS +from tools import ( + building, + cache, + cmdline, + compile, + config, + diagnostics, + shared, + system_libs, + utils, +) from tools.cmdline import CLANG_FLAGS_WITH_ARGS from tools.response_file import substitute_response_files -from tools import config -from tools import cache -from tools.settings import default_setting, user_settings, settings, COMPILE_TIME_SETTINGS -from tools.utils import read_file, unsuffixed_basename, get_file_suffix +from tools.settings import ( + COMPILE_TIME_SETTINGS, + default_setting, + settings, + user_settings, +) +from tools.shared import DEBUG, DYLIB_EXTENSIONS, exit_with_error, in_temp +from tools.toolchain_profiler import ToolchainProfiler +from tools.utils import get_file_suffix, read_file, unsuffixed_basename logger = logging.getLogger('emcc') diff --git a/emcmake.py b/emcmake.py index 9fe49270014fd..9bb05f742042d 100755 --- a/emcmake.py +++ b/emcmake.py @@ -8,9 +8,8 @@ import shlex import shutil import sys -from tools import shared -from tools import config -from tools import utils + +from tools import config, shared, utils # diff --git a/emconfigure.py b/emconfigure.py index 4e2d7e95875fb..a9e9706ba1bf5 100755 --- a/emconfigure.py +++ b/emconfigure.py @@ -19,8 +19,8 @@ import os import shlex import sys -from tools import building -from tools import shared + +from tools import building, shared # diff --git a/emmake.py b/emmake.py index ca349fb145e4d..56d6b499a5f47 100755 --- a/emmake.py +++ b/emmake.py @@ -25,9 +25,8 @@ import shlex import shutil import sys -from tools import building -from tools import shared -from tools import utils + +from tools import building, shared, utils # diff --git a/emranlib.py b/emranlib.py index 811ef061cb6dc..3d1659d05de8e 100755 --- a/emranlib.py +++ b/emranlib.py @@ -11,6 +11,7 @@ """ import sys + from tools import shared shared.exec_process([shared.LLVM_RANLIB] + sys.argv[1:]) diff --git a/emrun.py b/emrun.py index fa689e4ecd1bf..4072f0149d455 100644 --- a/emrun.py +++ b/emrun.py @@ -38,10 +38,11 @@ from operator import itemgetter if sys.version_info.major == 2: + from urllib import unquote + import SocketServer as socketserver from BaseHTTPServer import HTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler - from urllib import unquote from urlparse import urlsplit else: import socketserver diff --git a/emscan-deps.py b/emscan-deps.py index c4d789da589e3..0bf0e397ba2c4 100755 --- a/emscan-deps.py +++ b/emscan-deps.py @@ -11,7 +11,7 @@ import sys -from tools import shared, cmdline, compile +from tools import cmdline, compile, shared argv = sys.argv[1:] diff --git a/emscons.py b/emscons.py index dbff40c25c02d..643f4a0863ab1 100755 --- a/emscons.py +++ b/emscons.py @@ -11,6 +11,7 @@ import os import subprocess import sys + from tools import building, utils tool_path = utils.path_from_root('tools/scons/site_scons/site_tools/emscripten') diff --git a/emstrip.py b/emstrip.py index f054fe7e9f1df..6226b655dc3f2 100755 --- a/emstrip.py +++ b/emstrip.py @@ -8,6 +8,7 @@ """ import sys + from tools import shared shared.exec_process([shared.LLVM_STRIP] + sys.argv[1:]) diff --git a/pyproject.toml b/pyproject.toml index ba2a20533640a..8ab5e44ecd24e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ lint.select = [ "COM", "E", "F", + "I", "PERF", "PIE", "PL", diff --git a/test/benchmark/benchmark_sse.py b/test/benchmark/benchmark_sse.py index d0f263bb86933..5bc6ce281c541 100644 --- a/test/benchmark/benchmark_sse.py +++ b/test/benchmark/benchmark_sse.py @@ -7,8 +7,8 @@ import json import os import re -import sys import subprocess +import sys __scriptdir__ = os.path.dirname(os.path.abspath(__file__)) __testdir__ = os.path.dirname(os.path.dirname(__file__)) @@ -17,11 +17,11 @@ sys.path.insert(0, __rootpath__) sys.path.insert(0, __testdir__) -from tools.shared import WINDOWS, CLANG_CXX, EMCC -from tools.shared import run_process -from tools.config import V8_ENGINE -from common import EMRUN, test_file import clang_native +from common import EMRUN, test_file + +from tools.config import V8_ENGINE +from tools.shared import CLANG_CXX, EMCC, WINDOWS, run_process # System info system_info = subprocess.check_output([EMRUN, '--system_info'], stderr=subprocess.STDOUT, text=True) diff --git a/test/clang_native.py b/test/clang_native.py index 364b9ad7ce8d5..a58a911f9be65 100644 --- a/test/clang_native.py +++ b/test/clang_native.py @@ -7,7 +7,8 @@ import os import platform import sys -from tools.shared import PIPE, run_process, CLANG_CC, CLANG_CXX + +from tools.shared import CLANG_CC, CLANG_CXX, PIPE, run_process from tools.utils import MACOS, WINDOWS, path_from_root logger = logging.getLogger('clang_native') diff --git a/test/common.py b/test/common.py index db1bb980d3c26..0e1ca9f042b74 100644 --- a/test/common.py +++ b/test/common.py @@ -3,14 +3,6 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. -from enum import Enum -from functools import wraps -from pathlib import Path -from subprocess import PIPE, STDOUT -from typing import Dict, Tuple -from urllib.parse import unquote, unquote_plus, urlparse, parse_qs -from http.server import ThreadingHTTPServer, SimpleHTTPRequestHandler -from retryable_unittest import RetryableTestCase import contextlib import difflib import hashlib @@ -19,7 +11,7 @@ import json import logging import os -import psutil +import queue import re import shlex import shutil @@ -31,18 +23,33 @@ import textwrap import threading import time -import webbrowser import unittest -import queue +import webbrowser +from enum import Enum +from functools import wraps +from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer +from pathlib import Path +from subprocess import PIPE, STDOUT +from typing import Dict, Tuple +from urllib.parse import parse_qs, unquote, unquote_plus, urlparse import clang_native import jsrun import line_endings -from tools.shared import EMCC, EMXX, DEBUG -from tools.shared import get_canonical_temp_dir, path_from_root -from tools.utils import MACOS, WINDOWS, read_file, read_binary, write_binary, exit_with_error +import psutil +from retryable_unittest import RetryableTestCase + +from tools import building, config, feature_matrix, shared, utils from tools.settings import COMPILE_TIME_SETTINGS -from tools import shared, feature_matrix, building, config, utils +from tools.shared import DEBUG, EMCC, EMXX, get_canonical_temp_dir, path_from_root +from tools.utils import ( + MACOS, + WINDOWS, + exit_with_error, + read_binary, + read_file, + write_binary, +) logger = logging.getLogger('common') diff --git a/test/jsrun.py b/test/jsrun.py index 6c7d21d4b46af..f18afc7285a03 100644 --- a/test/jsrun.py +++ b/test/jsrun.py @@ -3,7 +3,6 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. -import common import logging import os import shlex @@ -11,6 +10,8 @@ import sys from subprocess import PIPE, CalledProcessError +import common + from tools import utils WORKING_ENGINES = {} # Holds all configured engines and whether they work: maps path -> True/False diff --git a/test/parallel_testsuite.py b/test/parallel_testsuite.py index 840ee3a7a0438..389f2db2eed0c 100644 --- a/test/parallel_testsuite.py +++ b/test/parallel_testsuite.py @@ -10,16 +10,14 @@ import tempfile import time import unittest -from tools import emprofile -from tools import utils import common from common import errlog -from tools.colored_logger import with_color, CYAN, GREEN, RED +from tools import emprofile, utils +from tools.colored_logger import CYAN, GREEN, RED, with_color from tools.utils import WINDOWS - NUM_CORES = None seen_class = set() torn_down = False diff --git a/test/retryable_unittest.py b/test/retryable_unittest.py index 116d4f953afb3..b3db510c7655f 100644 --- a/test/retryable_unittest.py +++ b/test/retryable_unittest.py @@ -1,7 +1,8 @@ -import common import os import unittest +import common + EMTEST_RETRY_COUNT = int(os.getenv('EMTEST_RETRY_COUNT', '0')) diff --git a/test/runner.py b/test/runner.py index 9ecfdcb7dc837..9eff301509ddf 100755 --- a/test/runner.py +++ b/test/runner.py @@ -28,8 +28,8 @@ import platform import random import sys -import unittest import time +import unittest from functools import cmp_to_key # Setup @@ -37,12 +37,12 @@ __rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, __rootpath__) +import common import jsrun import parallel_testsuite -import common from common import errlog -from tools import shared, config, utils +from tools import config, shared, utils sys.path.append(utils.path_from_root('third_party/websockify')) @@ -421,7 +421,7 @@ def run_tests(options, suites): os.makedirs('out', exist_ok=True) # output fd must remain open until after testRunner.run() below output = open('out/test-results.xml', 'wb') - import xmlrunner # type: ignore + import xmlrunner # type: ignore testRunner = xmlrunner.XMLTestRunner(output=output, verbosity=2, failfast=options.failfast) print('Writing XML test output to ' + os.path.abspath(output.name)) diff --git a/test/sockets/socket_relay.py b/test/sockets/socket_relay.py index 06fcc57f74862..6d01fe552cbdc 100644 --- a/test/sockets/socket_relay.py +++ b/test/sockets/socket_relay.py @@ -14,10 +14,10 @@ communication. We need to actually listen on both ports. """ -import sys import socket -import time +import sys import threading +import time from typing import Optional ports = [int(sys.argv[1]), int(sys.argv[2])] diff --git a/test/test_benchmark.py b/test/test_benchmark.py index e8adcda47e3e0..7a158f6875b22 100644 --- a/test/test_benchmark.py +++ b/test/test_benchmark.py @@ -3,6 +3,7 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. +import json import math import os import re @@ -10,7 +11,6 @@ import sys import time import unittest -import json import zlib from pathlib import Path from typing import List @@ -19,12 +19,12 @@ raise Exception('do not run this file directly; do something like: test/runner.py benchmark') import clang_native -import jsrun import common -from tools.shared import CLANG_CC, CLANG_CXX -from common import test_file, read_file, read_binary, needs_make -from tools.shared import run_process, PIPE, EMCC, config +import jsrun +from common import needs_make, read_binary, read_file, test_file + from tools import building, utils +from tools.shared import CLANG_CC, CLANG_CXX, EMCC, PIPE, config, run_process # standard arguments for timing: # 0: no runtime, just startup diff --git a/test/test_browser.py b/test/test_browser.py index a594e64ca0f16..1ac4a75ec5c66 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -15,21 +15,56 @@ import unittest import zlib from functools import wraps -from http.server import BaseHTTPRequestHandler, HTTPServer, ThreadingHTTPServer, SimpleHTTPRequestHandler +from http.server import ( + BaseHTTPRequestHandler, + HTTPServer, + SimpleHTTPRequestHandler, + ThreadingHTTPServer, +) from pathlib import Path from urllib.request import urlopen import common -from common import BrowserCore, RunnerCore, path_from_root, has_browser, Reporting, is_chrome, is_firefox, is_safari, CHROMIUM_BASED_BROWSERS -from common import create_file, parameterized, ensure_dir, disabled, flaky, test_file, WEBIDL_BINDER -from common import read_file, EMRUN, no_wasm64, no_2gb, no_4gb, copytree, skip_if, skip_if_simple -from common import requires_wasm2js, parameterize, find_browser_test_file, with_all_sjlj -from common import also_with_minimal_runtime, also_with_wasm2js, also_with_asan, also_with_wasmfs -from common import HttpServerThread, requires_dev_dependency -from tools import shared -from tools import ports +from common import ( + CHROMIUM_BASED_BROWSERS, + EMRUN, + WEBIDL_BINDER, + BrowserCore, + HttpServerThread, + Reporting, + RunnerCore, + also_with_asan, + also_with_minimal_runtime, + also_with_wasm2js, + also_with_wasmfs, + copytree, + create_file, + disabled, + ensure_dir, + find_browser_test_file, + flaky, + has_browser, + is_chrome, + is_firefox, + is_safari, + no_2gb, + no_4gb, + no_wasm64, + parameterize, + parameterized, + path_from_root, + read_file, + requires_dev_dependency, + requires_wasm2js, + skip_if, + skip_if_simple, + test_file, + with_all_sjlj, +) + +from tools import ports, shared from tools.feature_matrix import UNSUPPORTED -from tools.shared import EMCC, WINDOWS, FILE_PACKAGER, PIPE, DEBUG +from tools.shared import DEBUG, EMCC, FILE_PACKAGER, PIPE, WINDOWS from tools.utils import delete_dir, memoize diff --git a/test/test_codesize.py b/test/test_codesize.py index b5e62d6f776e0..7ca92e364236d 100644 --- a/test/test_codesize.py +++ b/test/test_codesize.py @@ -10,9 +10,16 @@ import shlex import common -from common import RunnerCore -from common import parameterized, node_pthreads -from common import test_file, read_file, read_binary, create_file, compiler_for +from common import ( + RunnerCore, + compiler_for, + create_file, + node_pthreads, + parameterized, + read_binary, + read_file, + test_file, +) from tools import building, shared diff --git a/test/test_core.py b/test/test_core.py index 40b08cd84cb10..93b7f35e7c24a 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -12,26 +12,67 @@ import shutil import time import unittest -from pathlib import Path from functools import wraps +from pathlib import Path if __name__ == '__main__': raise Exception('do not run this file directly; do something like: test/runner') -from tools.shared import PIPE -from tools.shared import EMCC, EMAR, EMXX, FILE_PACKAGER, LLVM_PROFDATA, LLVM_COV -from tools.utils import WINDOWS, MACOS, LINUX, write_file, delete_file -from tools import shared, building, config, utils, webassembly -import common -from common import RunnerCore, path_from_root, requires_native_clang, test_file, create_file -from common import skip_if, no_windows, is_slow_test, parameterized, parameterize, all_engines -from common import env_modify, with_env_modify, disabled, flaky, node_pthreads, also_without_bigint -from common import read_file, read_binary, requires_v8, requires_node, requires_dev_dependency, requires_wasm2js, requires_node_canary -from common import compiler_for, crossplatform, no_4gb, no_2gb, also_with_minimal_runtime, also_with_modularize -from common import with_all_fs, also_with_nodefs, also_with_nodefs_both, also_with_noderawfs, also_with_wasmfs -from common import with_all_eh_sjlj, with_all_sjlj, also_with_standalone_wasm, can_do_standalone, no_wasm64, requires_wasm_eh, requires_jspi -from common import NON_ZERO, WEBIDL_BINDER, EMBUILDER, PYTHON, needs_make import clang_native +import common +from common import ( + EMBUILDER, + NON_ZERO, + PYTHON, + WEBIDL_BINDER, + RunnerCore, + all_engines, + also_with_minimal_runtime, + also_with_modularize, + also_with_nodefs, + also_with_nodefs_both, + also_with_noderawfs, + also_with_standalone_wasm, + also_with_wasmfs, + also_without_bigint, + can_do_standalone, + compiler_for, + create_file, + crossplatform, + disabled, + env_modify, + flaky, + is_slow_test, + needs_make, + no_2gb, + no_4gb, + no_wasm64, + no_windows, + node_pthreads, + parameterize, + parameterized, + path_from_root, + read_binary, + read_file, + requires_dev_dependency, + requires_jspi, + requires_native_clang, + requires_node, + requires_node_canary, + requires_v8, + requires_wasm2js, + requires_wasm_eh, + skip_if, + test_file, + with_all_eh_sjlj, + with_all_fs, + with_all_sjlj, + with_env_modify, +) + +from tools import building, config, shared, utils, webassembly +from tools.shared import EMAR, EMCC, EMXX, FILE_PACKAGER, LLVM_COV, LLVM_PROFDATA, PIPE +from tools.utils import LINUX, MACOS, WINDOWS, delete_file, write_file # decorators for limiting which modes a test can run in diff --git a/test/test_interactive.py b/test/test_interactive.py index 816c39a05c20a..22ecb2789ab98 100644 --- a/test/test_interactive.py +++ b/test/test_interactive.py @@ -10,8 +10,14 @@ if __name__ == '__main__': raise Exception('do not run this file directly; do something like: test/runner.py interactive') -from common import parameterized -from common import BrowserCore, test_file, create_file, also_with_minimal_runtime +from common import ( + BrowserCore, + also_with_minimal_runtime, + create_file, + parameterized, + test_file, +) + from tools.shared import WINDOWS diff --git a/test/test_other.py b/test/test_other.py index fe8dbc4fa9c91..04be3622feefa 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -5,8 +5,6 @@ # noqa: E241 -from functools import wraps -from datetime import datetime import glob import importlib import itertools @@ -21,35 +19,90 @@ import sys import tarfile import time +from datetime import datetime +from functools import wraps from pathlib import Path from subprocess import PIPE, STDOUT if __name__ == '__main__': raise Exception('do not run this file directly; do something like: test/runner other') -from tools.building import get_building_env -from tools.shared import config -from tools.shared import EMCC, EMXX, EMAR, EMRANLIB, FILE_PACKAGER, LLVM_NM -from tools.shared import CLANG_CC, CLANG_CXX, LLVM_AR, LLVM_DWARFDUMP, LLVM_DWP, WASM_LD -from common import RunnerCore, path_from_root, is_slow_test, ensure_dir, disabled, make_executable -from common import env_modify, no_mac, no_windows, only_windows, requires_native_clang, with_env_modify -from common import create_file, parameterized, NON_ZERO, node_pthreads, TEST_ROOT, test_file -from common import EMBUILDER, requires_v8, requires_node, requires_wasm64, requires_node_canary, requires_dev_dependency -from common import requires_wasm_eh, crossplatform, with_all_eh_sjlj, with_all_sjlj, requires_jspi -from common import also_with_standalone_wasm, also_with_wasm2js, also_with_noderawfs -from common import also_with_modularize, also_with_wasmfs, with_all_fs -from common import also_with_minimal_runtime, also_without_bigint, also_with_wasm64, also_with_asan, flaky -from common import EMTEST_BUILD_VERBOSE, PYTHON, WEBIDL_BINDER, EMCMAKE, EMCONFIGURE -from common import requires_network, parameterize, copytree, all_engines -from tools import shared, building, utils, response_file, cache -from tools.utils import read_file, write_file, delete_file, read_binary, MACOS, WINDOWS +import clang_native import common import jsrun -import clang_native import line_endings -from tools import webassembly +from common import ( + EMBUILDER, + EMCMAKE, + EMCONFIGURE, + EMTEST_BUILD_VERBOSE, + NON_ZERO, + PYTHON, + TEST_ROOT, + WEBIDL_BINDER, + RunnerCore, + all_engines, + also_with_asan, + also_with_minimal_runtime, + also_with_modularize, + also_with_noderawfs, + also_with_standalone_wasm, + also_with_wasm2js, + also_with_wasm64, + also_with_wasmfs, + also_without_bigint, + copytree, + create_file, + crossplatform, + disabled, + ensure_dir, + env_modify, + flaky, + is_slow_test, + make_executable, + no_mac, + no_windows, + node_pthreads, + only_windows, + parameterize, + parameterized, + path_from_root, + requires_dev_dependency, + requires_jspi, + requires_native_clang, + requires_network, + requires_node, + requires_node_canary, + requires_v8, + requires_wasm64, + requires_wasm_eh, + test_file, + with_all_eh_sjlj, + with_all_fs, + with_all_sjlj, + with_env_modify, +) + +from tools import building, cache, response_file, shared, utils, webassembly +from tools.building import get_building_env from tools.settings import settings +from tools.shared import ( + CLANG_CC, + CLANG_CXX, + EMAR, + EMCC, + EMRANLIB, + EMXX, + FILE_PACKAGER, + LLVM_AR, + LLVM_DWARFDUMP, + LLVM_DWP, + LLVM_NM, + WASM_LD, + config, +) from tools.system_libs import DETERMINISTIC_PREFIX +from tools.utils import MACOS, WINDOWS, delete_file, read_binary, read_file, write_file emmake = utils.bat_suffix(path_from_root('emmake')) emconfig = utils.bat_suffix(path_from_root('em-config')) diff --git a/test/test_posixtest.py b/test/test_posixtest.py index 4b10b16a30769..3d420f58cc9ff 100644 --- a/test/test_posixtest.py +++ b/test/test_posixtest.py @@ -13,8 +13,8 @@ import os import unittest -from common import RunnerCore, path_from_root, node_pthreads import test_posixtest_browser +from common import RunnerCore, node_pthreads, path_from_root testsuite_root = path_from_root('test/third_party/posixtestsuite') diff --git a/test/test_sanity.py b/test/test_sanity.py index bfb313dadc10e..75dd4c2476a26 100644 --- a/test/test_sanity.py +++ b/test/test_sanity.py @@ -6,26 +6,33 @@ import glob import os import platform +import re import shutil import stat -import time -import re import tempfile +import time from pathlib import Path from subprocess import PIPE, STDOUT import common -from common import RunnerCore, path_from_root, env_modify, test_file -from common import create_file, ensure_dir, make_executable, with_env_modify -from common import crossplatform, parameterized, EMBUILDER +from common import ( + EMBUILDER, + RunnerCore, + create_file, + crossplatform, + ensure_dir, + env_modify, + make_executable, + parameterized, + path_from_root, + test_file, + with_env_modify, +) + +from tools import cache, ports, response_file, shared, utils from tools.config import EM_CONFIG -from tools.shared import EMCC -from tools.shared import config -from tools.utils import delete_file, delete_dir -from tools import cache -from tools import shared, utils -from tools import response_file -from tools import ports +from tools.shared import EMCC, config +from tools.utils import delete_dir, delete_file SANITY_FILE = cache.get_path('sanity.txt') commands = [[EMCC], [shared.bat_suffix(path_from_root('test/runner')), 'blahblah']] diff --git a/test/test_sockets.py b/test/test_sockets.py index ded5493a8964d..09f22fbb75ece 100644 --- a/test/test_sockets.py +++ b/test/test_sockets.py @@ -5,8 +5,8 @@ import multiprocessing import os -import socket import shutil +import socket import sys import time from subprocess import Popen @@ -17,11 +17,22 @@ import clang_native import common -from common import BrowserCore, no_windows, create_file, test_file, read_file -from common import parameterized, requires_native_clang, crossplatform, PYTHON, NON_ZERO -from common import requires_dev_dependency +from common import ( + NON_ZERO, + PYTHON, + BrowserCore, + create_file, + crossplatform, + no_windows, + parameterized, + read_file, + requires_dev_dependency, + requires_native_clang, + test_file, +) + from tools import config -from tools.shared import EMCC, path_from_root, run_process, CLANG_CC +from tools.shared import CLANG_CC, EMCC, path_from_root, run_process npm_checked = False diff --git a/test/test_stress.py b/test/test_stress.py index fabb6631e97ff..7ce8eb750a141 100644 --- a/test/test_stress.py +++ b/test/test_stress.py @@ -16,7 +16,13 @@ import subprocess import threading -from common import RunnerCore, node_pthreads, is_slow_test, also_with_modularize, NON_ZERO +from common import ( + NON_ZERO, + RunnerCore, + also_with_modularize, + is_slow_test, + node_pthreads, +) class stress(RunnerCore): diff --git a/tools/building.py b/tools/building.py index 5380118bae7aa..080724cd179c5 100644 --- a/tools/building.py +++ b/tools/building.py @@ -3,8 +3,6 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. -from .toolchain_profiler import ToolchainProfiler - import importlib import json import logging @@ -14,27 +12,35 @@ import shutil import subprocess import sys -from typing import Set, Dict from subprocess import PIPE +from typing import Dict, Set -from . import cache -from . import diagnostics -from . import response_file -from . import shared -from . import webassembly -from . import config -from . import utils -from .shared import CLANG_CC, CLANG_CXX -from .shared import LLVM_NM, EMCC, EMAR, EMXX, EMRANLIB, WASM_LD -from .shared import LLVM_OBJCOPY -from .shared import run_process, check_call, exit_with_error -from .shared import path_from_root -from .shared import asmjs_mangle, DEBUG -from .shared import LLVM_DWARFDUMP, demangle_c_symbol_name -from .shared import get_emscripten_temp_dir, is_c_symbol -from .utils import WINDOWS -from .settings import settings +from . import cache, config, diagnostics, response_file, shared, utils, webassembly from .feature_matrix import UNSUPPORTED +from .settings import settings +from .shared import ( + CLANG_CC, + CLANG_CXX, + DEBUG, + EMAR, + EMCC, + EMRANLIB, + EMXX, + LLVM_DWARFDUMP, + LLVM_NM, + LLVM_OBJCOPY, + WASM_LD, + asmjs_mangle, + check_call, + demangle_c_symbol_name, + exit_with_error, + get_emscripten_temp_dir, + is_c_symbol, + path_from_root, + run_process, +) +from .toolchain_profiler import ToolchainProfiler +from .utils import WINDOWS logger = logging.getLogger('building') diff --git a/tools/cache.py b/tools/cache.py index 01f8a6247735a..32f732a5e8e1d 100644 --- a/tools/cache.py +++ b/tools/cache.py @@ -11,7 +11,7 @@ import os from pathlib import Path -from . import filelock, config, utils +from . import config, filelock, utils from .settings import settings logger = logging.getLogger('cache') diff --git a/tools/cmdline.py b/tools/cmdline.py index f263110faf3d7..0afc105aa24e7 100644 --- a/tools/cmdline.py +++ b/tools/cmdline.py @@ -3,8 +3,6 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. -from tools.toolchain_profiler import ToolchainProfiler - import json import logging import os @@ -14,11 +12,20 @@ from enum import Enum, auto, unique from subprocess import PIPE -from tools import shared, utils, ports, diagnostics, config -from tools import cache, feature_matrix, colored_logger +from tools import ( + cache, + colored_logger, + config, + diagnostics, + feature_matrix, + ports, + shared, + utils, +) +from tools.settings import MEM_SIZE_SETTINGS, settings, user_settings from tools.shared import exit_with_error -from tools.settings import settings, user_settings, MEM_SIZE_SETTINGS -from tools.utils import removeprefix, read_file +from tools.toolchain_profiler import ToolchainProfiler +from tools.utils import read_file, removeprefix SIMD_INTEL_FEATURE_TOWER = ['-msse', '-msse2', '-msse3', '-mssse3', '-msse4.1', '-msse4.2', '-msse4', '-mavx', '-mavx2'] SIMD_NEON_FLAGS = ['-mfpu=neon'] diff --git a/tools/colored_logger.py b/tools/colored_logger.py index ae93062cc8f5c..f8cf4773c011c 100644 --- a/tools/colored_logger.py +++ b/tools/colored_logger.py @@ -9,11 +9,10 @@ """ import ctypes -import sys import logging +import sys from functools import wraps - # ANSI colors RED = 1 GREEN = 2 diff --git a/tools/compile.py b/tools/compile.py index 0cc5d33e336f1..4380af51df5ef 100644 --- a/tools/compile.py +++ b/tools/compile.py @@ -20,10 +20,10 @@ import os -from . cmdline import SIMD_INTEL_FEATURE_TOWER, SIMD_NEON_FLAGS -from . import shared, building, cache, ports -from . settings import settings -from . utils import memoize +from . import building, cache, ports, shared +from .cmdline import SIMD_INTEL_FEATURE_TOWER, SIMD_NEON_FLAGS +from .settings import settings +from .utils import memoize def get_target_flags(): diff --git a/tools/config.py b/tools/config.py index 6ce8ccd77c6a9..7feeeadb888ef 100644 --- a/tools/config.py +++ b/tools/config.py @@ -3,14 +3,14 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. +import logging import os import shutil import sys -import logging from typing import List, Optional -from . import utils, diagnostics -from .utils import path_from_root, exit_with_error, __rootpath__ +from . import diagnostics, utils +from .utils import __rootpath__, exit_with_error, path_from_root logger = logging.getLogger('config') diff --git a/tools/emcoverage.py b/tools/emcoverage.py index 55d9d4aebd173..8695f3bb1e551 100755 --- a/tools/emcoverage.py +++ b/tools/emcoverage.py @@ -29,6 +29,7 @@ report, html, xml. """ +import contextlib import errno import os import shutil @@ -36,8 +37,7 @@ import uuid from glob import glob -import coverage.cmdline # type: ignore -import contextlib +import coverage.cmdline # type: ignore SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) diff --git a/tools/emdwp.py b/tools/emdwp.py index fa21c0fd5664f..36f9f65e9ec19 100755 --- a/tools/emdwp.py +++ b/tools/emdwp.py @@ -7,8 +7,8 @@ """Wrapper script around `llvm-dwp`. """ -import sys import os +import sys __scriptdir__ = os.path.dirname(os.path.abspath(__file__)) __rootdir__ = os.path.dirname(__scriptdir__) diff --git a/tools/empath-split.py b/tools/empath-split.py index 7a056a9ae9832..8f9b639711e97 100755 --- a/tools/empath-split.py +++ b/tools/empath-split.py @@ -55,12 +55,7 @@ __rootdir__ = os.path.dirname(__scriptdir__) sys.path.insert(0, __rootdir__) -from tools import building -from tools import diagnostics -from tools import emsymbolizer -from tools import shared -from tools import utils -from tools import webassembly +from tools import building, diagnostics, emsymbolizer, shared, utils, webassembly from tools.utils import exit_with_error diff --git a/tools/emprofile.py b/tools/emprofile.py index cc85b26fd22c7..c0cc6355dc1c4 100755 --- a/tools/emprofile.py +++ b/tools/emprofile.py @@ -12,7 +12,6 @@ import time from pathlib import Path - profiler_logs_path = os.path.join(tempfile.gettempdir(), 'emscripten_toolchain_profiler_logs') diff --git a/tools/emscripten.py b/tools/emscripten.py index ae2c8f2e7dfea..7b68d58836fd2 100644 --- a/tools/emscripten.py +++ b/tools/emscripten.py @@ -9,28 +9,29 @@ headers, for the libc implementation in JS). """ -from tools.toolchain_profiler import ToolchainProfiler - -import os import json -import subprocess import logging +import os import pprint import shutil +import subprocess import sys import textwrap -from tools import building -from tools import config -from tools import diagnostics -from tools import js_manipulation -from tools import shared -from tools import utils -from tools import webassembly -from tools import extract_metadata -from tools.utils import exit_with_error, path_from_root, removeprefix -from tools.shared import DEBUG, asmjs_mangle, in_temp +from tools import ( + building, + config, + diagnostics, + extract_metadata, + js_manipulation, + shared, + utils, + webassembly, +) from tools.settings import settings, user_settings +from tools.shared import DEBUG, asmjs_mangle, in_temp +from tools.toolchain_profiler import ToolchainProfiler +from tools.utils import exit_with_error, path_from_root, removeprefix sys.path.append(path_from_root('third_party')) import leb128 diff --git a/tools/emsymbolizer.py b/tools/emsymbolizer.py index 6affa7d4c9b1a..0adcbfc69c460 100755 --- a/tools/emsymbolizer.py +++ b/tools/emsymbolizer.py @@ -14,21 +14,19 @@ # Separate DWARF is not supported yet. import argparse -from dataclasses import dataclass import json import os import re import subprocess import sys +from dataclasses import dataclass from typing import Optional __scriptdir__ = os.path.dirname(os.path.abspath(__file__)) __rootdir__ = os.path.dirname(__scriptdir__) sys.path.insert(0, __rootdir__) -from tools import shared -from tools import webassembly - +from tools import shared, webassembly LLVM_SYMBOLIZER = shared.llvm_tool_path('llvm-symbolizer') diff --git a/tools/extract_metadata.py b/tools/extract_metadata.py index de2ccbf9ef7fc..d1cadf1828595 100644 --- a/tools/extract_metadata.py +++ b/tools/extract_metadata.py @@ -4,14 +4,13 @@ # found in the LICENSE file. import logging -from typing import List, Dict from dataclasses import dataclass +from typing import Dict, List -from . import webassembly, utils -from .webassembly import OpCode, AtomicOpCode, MemoryOpCode -from .shared import exit_with_error +from . import utils, webassembly from .settings import settings - +from .shared import exit_with_error +from .webassembly import AtomicOpCode, MemoryOpCode, OpCode logger = logging.getLogger('extract_metadata') diff --git a/tools/feature_matrix.py b/tools/feature_matrix.py index 56a8f30b5c736..d239a8adcdb4f 100644 --- a/tools/feature_matrix.py +++ b/tools/feature_matrix.py @@ -8,8 +8,8 @@ import logging from enum import IntEnum, auto -from .settings import settings, user_settings from . import diagnostics +from .settings import settings, user_settings logger = logging.getLogger('feature_matrix') diff --git a/tools/file_packager.py b/tools/file_packager.py index 3a4eb7d340ba8..7ac92f9596fe7 100755 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -85,10 +85,9 @@ __rootdir__ = os.path.dirname(__scriptdir__) sys.path.insert(0, __rootdir__) -from tools import shared, utils, js_manipulation, diagnostics +from tools import diagnostics, js_manipulation, shared, utils from tools.response_file import substitute_response_files - DEBUG = os.environ.get('EMCC_DEBUG') excluded_patterns: List[str] = [] diff --git a/tools/gen_struct_info.py b/tools/gen_struct_info.py index f3daded869f36..94280d04c7a35 100755 --- a/tools/gen_struct_info.py +++ b/tools/gen_struct_info.py @@ -54,24 +54,21 @@ anything printf() understands. """ -import sys +import argparse +import json import os import re -import json -import argparse -import tempfile import shlex import subprocess +import sys +import tempfile import typing __scriptdir__ = os.path.dirname(os.path.abspath(__file__)) __rootdir__ = os.path.dirname(__scriptdir__) sys.path.insert(0, __rootdir__) -from tools import building -from tools import shared -from tools import system_libs -from tools import utils +from tools import building, shared, system_libs, utils QUIET = (__name__ != '__main__') DEBUG = False diff --git a/tools/js_manipulation.py b/tools/js_manipulation.py index 8e1392c71e5f6..a052ac19be786 100644 --- a/tools/js_manipulation.py +++ b/tools/js_manipulation.py @@ -5,8 +5,8 @@ import re +from . import shared, utils from .settings import settings -from . import utils, shared emscripten_license = '''\ /** diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py index a2278da8b775e..6baac8e03047e 100755 --- a/tools/js_optimizer.py +++ b/tools/js_optimizer.py @@ -4,20 +4,20 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. +import json import os -import sys -import subprocess import re -import json import shutil +import subprocess +import sys __scriptdir__ = os.path.dirname(os.path.abspath(__file__)) __rootdir__ = os.path.dirname(__scriptdir__) sys.path.insert(0, __rootdir__) +from tools import building, config, shared, utils from tools.toolchain_profiler import ToolchainProfiler from tools.utils import path_from_root -from tools import building, config, shared, utils temp_files = shared.get_temp_files() diff --git a/tools/link.py b/tools/link.py index 43d5db563c0f9..10416c39c8176 100644 --- a/tools/link.py +++ b/tools/link.py @@ -3,8 +3,6 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. -from .toolchain_profiler import ToolchainProfiler - import base64 import glob import hashlib @@ -13,35 +11,51 @@ import os import re import shlex -import stat import shutil +import stat import time from subprocess import PIPE from urllib.parse import quote -from . import building -from . import cache -from . import config -from . import diagnostics -from . import emscripten -from . import feature_matrix -from . import filelock -from . import js_manipulation -from . import ports -from . import shared -from . import system_libs -from . import utils -from . import webassembly -from . import extract_metadata +from . import ( + building, + cache, + config, + diagnostics, + emscripten, + extract_metadata, + feature_matrix, + filelock, + js_manipulation, + ports, + shared, + system_libs, + utils, + webassembly, +) from .cmdline import OFormat -from .utils import read_file, write_file, delete_file, safe_copy -from .utils import removeprefix, exit_with_error -from .utils import unsuffixed, unsuffixed_basename, get_file_suffix -from .shared import in_temp, do_replace -from .shared import DEBUG, WINDOWS, DYLIB_EXTENSIONS -from .settings import settings, default_setting, user_settings -from .settings import JS_ONLY_SETTINGS, DEPRECATED_SETTINGS, INCOMPATIBLE_SETTINGS from .minimal_runtime_shell import generate_minimal_runtime_html +from .settings import ( + DEPRECATED_SETTINGS, + INCOMPATIBLE_SETTINGS, + JS_ONLY_SETTINGS, + default_setting, + settings, + user_settings, +) +from .shared import DEBUG, DYLIB_EXTENSIONS, WINDOWS, do_replace, in_temp +from .toolchain_profiler import ToolchainProfiler +from .utils import ( + delete_file, + exit_with_error, + get_file_suffix, + read_file, + removeprefix, + safe_copy, + unsuffixed, + unsuffixed_basename, + write_file, +) logger = logging.getLogger('link') diff --git a/tools/maint/add_license.py b/tools/maint/add_license.py index afd27ba03afd6..d3e571558a11e 100755 --- a/tools/maint/add_license.py +++ b/tools/maint/add_license.py @@ -6,9 +6,9 @@ """Add or verify emscripten license header in source files.""" -import sys import os import subprocess +import sys script_dir = os.path.dirname(os.path.abspath(__file__)) __rootpath__ = os.path.dirname(os.path.dirname(script_dir)) diff --git a/tools/maint/check_for_closed_issues.py b/tools/maint/check_for_closed_issues.py index 1c9e476d73c20..7bbfd8ef47978 100755 --- a/tools/maint/check_for_closed_issues.py +++ b/tools/maint/check_for_closed_issues.py @@ -6,11 +6,10 @@ import json import os -import subprocess import re +import subprocess import sys - script_dir = os.path.dirname(os.path.abspath(__file__)) root_dir = os.path.dirname(os.path.dirname(script_dir)) diff --git a/tools/maint/check_for_unused_test_files.py b/tools/maint/check_for_unused_test_files.py index 497884ba3308c..c44305206cb09 100755 --- a/tools/maint/check_for_unused_test_files.py +++ b/tools/maint/check_for_unused_test_files.py @@ -4,10 +4,10 @@ be deleted. This is a work in progress and still contains false positives in the output.""" -import os -import sys import fnmatch +import os import subprocess +import sys script_dir = os.path.dirname(os.path.abspath(__file__)) root_dir = os.path.dirname(os.path.dirname(script_dir)) diff --git a/tools/maint/check_struct_info.py b/tools/maint/check_struct_info.py index 9b56823b1bb06..b7e0cfc1be2eb 100755 --- a/tools/maint/check_struct_info.py +++ b/tools/maint/check_struct_info.py @@ -5,8 +5,8 @@ import json import os -import sys import subprocess +import sys script_dir = os.path.dirname(os.path.abspath(__file__)) root_dir = os.path.dirname(os.path.dirname(script_dir)) diff --git a/tools/maint/create_dom_pk_codes.py b/tools/maint/create_dom_pk_codes.py index d7e25c36699bb..6268e24320668 100755 --- a/tools/maint/create_dom_pk_codes.py +++ b/tools/maint/create_dom_pk_codes.py @@ -31,8 +31,8 @@ # Use #include in your code to access these IDs. import os -import sys import random +import sys input_strings = [ (0x0, 'Unidentified', 'DOM_PK_UNKNOWN'), diff --git a/tools/maint/create_entry_points.py b/tools/maint/create_entry_points.py index 93693b5496978..b86e8fdb8f410 100755 --- a/tools/maint/create_entry_points.py +++ b/tools/maint/create_entry_points.py @@ -14,8 +14,8 @@ """ import os -import sys import stat +import sys __scriptdir__ = os.path.dirname(os.path.abspath(__file__)) __rootdir__ = os.path.dirname(os.path.dirname(__scriptdir__)) diff --git a/tools/maint/create_release.py b/tools/maint/create_release.py index adfd1a1d00f8b..39c78e119b107 100755 --- a/tools/maint/create_release.py +++ b/tools/maint/create_release.py @@ -4,10 +4,10 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. -from datetime import datetime import os import subprocess import sys +from datetime import datetime script_dir = os.path.dirname(os.path.abspath(__file__)) root_dir = os.path.dirname(os.path.dirname(script_dir)) diff --git a/tools/maint/find_unused_test_files.py b/tools/maint/find_unused_test_files.py index 37632e6a12af6..1b679db7a2715 100755 --- a/tools/maint/find_unused_test_files.py +++ b/tools/maint/find_unused_test_files.py @@ -6,8 +6,8 @@ """ import os -import sys import subprocess +import sys script_dir = os.path.dirname(os.path.abspath(__file__)) root_dir = os.path.dirname(os.path.dirname(script_dir)) diff --git a/tools/maint/gen_sig_info.py b/tools/maint/gen_sig_info.py index 1088dc74759b8..534f6d2e9d9e7 100755 --- a/tools/maint/gen_sig_info.py +++ b/tools/maint/gen_sig_info.py @@ -11,13 +11,12 @@ """ import argparse +import glob import json import os -import sys -import subprocess import re -import glob - +import subprocess +import sys __scriptdir__ = os.path.dirname(os.path.abspath(__file__)) __rootdir__ = os.path.dirname(os.path.dirname(__scriptdir__)) diff --git a/tools/maint/heuristic_clear_cache.py b/tools/maint/heuristic_clear_cache.py index 22f11e491de30..8918e4901d1cd 100644 --- a/tools/maint/heuristic_clear_cache.py +++ b/tools/maint/heuristic_clear_cache.py @@ -16,8 +16,7 @@ __rootdir__ = os.path.dirname(__scriptdir__) sys.path.insert(0, __rootdir__) -from tools import utils -from tools import cache +from tools import cache, utils # Modifying the following files/paths can often disturb Emscripten generated cache. # If any of those are modified, then the Emscripten cache should be cleared. diff --git a/tools/maint/rebaseline_tests.py b/tools/maint/rebaseline_tests.py index 2dec1429ff757..485a2dae4dceb 100755 --- a/tools/maint/rebaseline_tests.py +++ b/tools/maint/rebaseline_tests.py @@ -12,8 +12,8 @@ import argparse import json import os -import subprocess import statistics +import subprocess import sys script_dir = os.path.dirname(os.path.abspath(__file__)) diff --git a/tools/maint/simde_update.py b/tools/maint/simde_update.py index f031c00537f48..426a3695ac7c5 100755 --- a/tools/maint/simde_update.py +++ b/tools/maint/simde_update.py @@ -12,7 +12,6 @@ import re import subprocess import sys - from os import path __scriptdir__ = os.path.dirname(os.path.abspath(__file__)) diff --git a/tools/maint/update_docs.py b/tools/maint/update_docs.py index 781619f6f310d..91b6340f3c3b6 100755 --- a/tools/maint/update_docs.py +++ b/tools/maint/update_docs.py @@ -8,8 +8,8 @@ in the emscripten-site repository containing the changes.""" import os -import sys import subprocess +import sys script_dir = os.path.dirname(os.path.abspath(__file__)) root_dir = os.path.dirname(os.path.dirname(script_dir)) diff --git a/tools/maint/update_settings_docs.py b/tools/maint/update_settings_docs.py index 238a5914cdb78..d933f785a38dd 100755 --- a/tools/maint/update_settings_docs.py +++ b/tools/maint/update_settings_docs.py @@ -17,8 +17,8 @@ """ import os -import sys import subprocess +import sys script_dir = os.path.dirname(os.path.abspath(__file__)) root_dir = os.path.dirname(os.path.dirname(script_dir)) diff --git a/tools/minimal_runtime_shell.py b/tools/minimal_runtime_shell.py index 47a42e5a384bc..1603ccd30dd9b 100644 --- a/tools/minimal_runtime_shell.py +++ b/tools/minimal_runtime_shell.py @@ -1,15 +1,13 @@ +import logging +import os import re import sys -import os -import logging __scriptdir__ = os.path.dirname(os.path.abspath(__file__)) __rootdir__ = os.path.dirname(__scriptdir__) sys.path.insert(0, __rootdir__) -from . import building -from . import shared -from . import utils +from . import building, shared, utils from .settings import settings logger = logging.getLogger('minimal_runtime_shell') diff --git a/tools/ports/__init__.py b/tools/ports/__init__.py index 65e55ae4b7327..a21912b6c2677 100644 --- a/tools/ports/__init__.py +++ b/tools/ports/__init__.py @@ -3,24 +3,20 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. -import logging +import glob import hashlib +import importlib.util +import logging import os -from pathlib import Path import shutil -import glob -import importlib.util -from inspect import signature -import sys import subprocess -from typing import Set, Dict +import sys +from inspect import signature +from pathlib import Path +from typing import Dict, Set from urllib.request import urlopen -from tools import cache -from tools import config -from tools import shared -from tools import system_libs -from tools import utils +from tools import cache, config, shared, system_libs, utils from tools.settings import settings from tools.toolchain_profiler import ToolchainProfiler diff --git a/tools/ports/cocos2d.py b/tools/ports/cocos2d.py index 179e14d6804bd..475bc36336cb2 100644 --- a/tools/ports/cocos2d.py +++ b/tools/ports/cocos2d.py @@ -5,6 +5,7 @@ import os import re + from tools import diagnostics TAG = 'version_3_3' diff --git a/tools/response_file.py b/tools/response_file.py index f0c48e0fb85f5..1cd894b96de1c 100644 --- a/tools/response_file.py +++ b/tools/response_file.py @@ -7,8 +7,8 @@ import os import shlex import tempfile -from .utils import WINDOWS +from .utils import WINDOWS DEBUG = int(os.environ.get('EMCC_DEBUG', '0')) diff --git a/tools/settings.py b/tools/settings.py index 15919f1247ab0..4ca1d818a5d2f 100644 --- a/tools/settings.py +++ b/tools/settings.py @@ -7,10 +7,10 @@ import difflib import os import re -from typing import Set, Dict, Any +from typing import Any, Dict, Set -from .utils import path_from_root, exit_with_error from . import diagnostics +from .utils import exit_with_error, path_from_root # Subset of settings that take a memory size (i.e. 1Gb, 64kb etc) MEM_SIZE_SETTINGS = { diff --git a/tools/shared.py b/tools/shared.py index 495cd325f2a97..fe428a10c44dd 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -6,18 +6,18 @@ """Shared code specific to emscripten. General purpose and low-level helpers belong instead in utils.py.""" -from .toolchain_profiler import ToolchainProfiler - -from subprocess import PIPE import atexit import logging import os import re import shlex -import subprocess import signal +import subprocess import sys import tempfile +from subprocess import PIPE + +from .toolchain_profiler import ToolchainProfiler # We depend on python 3.8 features if sys.version_info < (3, 8): # noqa: UP036 @@ -39,15 +39,19 @@ logging.basicConfig(format='%(name)s:%(levelname)s: %(message)s', level=log_level) colored_logger.enable() -from .utils import path_from_root, exit_with_error, safe_ensure_dirs, WINDOWS, set_version_globals, memoize, bat_suffix -from . import cache, tempfiles -from . import diagnostics -from . import config -from . import filelock -from . import utils -from .settings import settings import contextlib +from . import cache, config, diagnostics, filelock, tempfiles, utils +from .settings import settings +from .utils import ( + WINDOWS, + bat_suffix, + exit_with_error, + memoize, + path_from_root, + safe_ensure_dirs, + set_version_globals, +) DEBUG_SAVE = DEBUG or int(os.environ.get('EMCC_DEBUG_SAVE', '0')) PRINT_SUBPROCS = int(os.getenv('EMCC_VERBOSE', '0')) diff --git a/tools/system_libs.py b/tools/system_libs.py index e8c7f3dec2b66..83bbc5471c23b 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -3,25 +3,22 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. -import re -from time import time -from .toolchain_profiler import ToolchainProfiler - import itertools import logging import os -import shutil -import textwrap +import re import shlex +import shutil import subprocess +import textwrap from enum import IntEnum, auto from glob import iglob +from time import time from typing import List, Optional -from . import shared, building, utils -from . import diagnostics -from . import cache +from . import building, cache, diagnostics, shared, utils from .settings import settings +from .toolchain_profiler import ToolchainProfiler from .utils import read_file logger = logging.getLogger('system_libs') diff --git a/tools/tempfiles.py b/tools/tempfiles.py index 8b121d819e8c8..d277989f23def 100644 --- a/tools/tempfiles.py +++ b/tools/tempfiles.py @@ -3,9 +3,9 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. -import tempfile import atexit import sys +import tempfile from . import utils diff --git a/tools/toolchain_profiler.py b/tools/toolchain_profiler.py index d6f4aa56881e9..5a834c3af55a9 100644 --- a/tools/toolchain_profiler.py +++ b/tools/toolchain_profiler.py @@ -6,8 +6,8 @@ import atexit import logging import os -import sys import subprocess +import sys import tempfile import time from contextlib import ContextDecorator diff --git a/tools/wasm-sourcemap.py b/tools/wasm-sourcemap.py index f9ee84e7b694b..30adc9058165d 100755 --- a/tools/wasm-sourcemap.py +++ b/tools/wasm-sourcemap.py @@ -13,20 +13,20 @@ import argparse import json import logging -from math import floor, log import os import re -from subprocess import Popen, PIPE -from pathlib import Path import sys +from math import floor, log +from pathlib import Path +from subprocess import PIPE, Popen __scriptdir__ = os.path.dirname(os.path.abspath(__file__)) __rootdir__ = os.path.dirname(__scriptdir__) sys.path.insert(0, __rootdir__) from tools import utils -from tools.system_libs import DETERMINISTIC_PREFIX from tools.shared import path_from_root +from tools.system_libs import DETERMINISTIC_PREFIX EMSCRIPTEN_PREFIX = utils.normalize_path(path_from_root()) diff --git a/tools/webassembly.py b/tools/webassembly.py index 192bfdf850432..f267e91ca7a06 100644 --- a/tools/webassembly.py +++ b/tools/webassembly.py @@ -6,15 +6,15 @@ """Utilities for manipulating WebAssembly binaries from python. """ -from collections import namedtuple -from enum import IntEnum -from functools import wraps import logging import os import sys +from collections import namedtuple +from enum import IntEnum +from functools import wraps -from .utils import memoize from . import utils +from .utils import memoize sys.path.append(utils.path_from_root('third_party'))