diff options
| author | Duncan Ogilvie <mr.exodia.tpodt@gmail.com> | 2022-10-18 17:30:38 +0200 |
|---|---|---|
| committer | Duncan Ogilvie <mr.exodia.tpodt@gmail.com> | 2022-10-18 21:44:52 +0200 |
| commit | b36fb005d586c692289c10a60f39542524fafe86 (patch) | |
| tree | af6184971e8a31b8bfd58f34940385500a5b1955 /setup.py | |
| parent | c75d0e0b1c066032d34375dec4c010d42a18381f (diff) | |
| download | miasm-b36fb005d586c692289c10a60f39542524fafe86.tar.gz miasm-b36fb005d586c692289c10a60f39542524fafe86.zip | |
Restore python 2.7 support
Diffstat (limited to 'setup.py')
| -rw-r--r-- | setup.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/setup.py b/setup.py index 1a7cdee4..11499b66 100644 --- a/setup.py +++ b/setup.py @@ -7,13 +7,14 @@ from distutils.util import get_platform from distutils.sysconfig import get_python_lib, get_config_vars from distutils.dist import DistributionMetadata from distutils.command.install_data import install_data +from distutils.spawn import find_executable import subprocess from tempfile import TemporaryFile import fnmatch import io import os import platform -from shutil import copy2, copyfile, rmtree, which +from shutil import copy2, copyfile, rmtree import sys import tempfile import atexit @@ -57,7 +58,7 @@ def win_find_clang_path(): return winreg.QueryValueEx(rkey, None)[0] except FileNotFoundError: # Visual Studio ships with an optional Clang distribution, try to detect it - clang_cl = which("clang-cl") + clang_cl = find_executable("clang-cl") if clang_cl is None: return None return os.path.abspath(os.path.join(os.path.dirname(clang_cl), "..", "..")) @@ -65,7 +66,7 @@ def win_find_clang_path(): def win_get_clang_version(clang_path): try: clang_cl = os.path.join(clang_path, "bin", "clang.exe") - stdout = subprocess.check_output(f"\"{clang_cl}\" --version") + stdout = subprocess.check_output("\"{}\" --version".format(clang_cl)) version = stdout.splitlines(False)[0].decode() match = re.search(r"version (\d+\.\d+\.\d+)", version) if match is None: @@ -76,7 +77,7 @@ def win_get_clang_version(clang_path): return None def win_use_clang(): - # To force python to use clang we copy the binaries in a temporary directory that"s added to the PATH. + # To force python to use clang we copy the binaries in a temporary directory that's added to the PATH. # We could use the build directory created by distutils for this, but it seems non-trivial to gather # (https://stackoverflow.com/questions/12896367/reliable-way-to-get-the-build-directory-from-within-setup-py). @@ -91,8 +92,8 @@ def win_use_clang(): copyfile(os.path.join(clang_path, "bin", "clang-cl.exe"), os.path.join(tmpdir, "cl.exe")) # If you run the installation from a Visual Studio command prompt link.exe will already exist - # Fall back to LLVM"s lld-link.exe which is compatible with link"s command line - if which("link") is None: + # Fall back to LLVM's lld-link.exe which is compatible with link's command line + if find_executable("link") is None: # LLVM >= 14.0.0 started supporting the /LTCG flag # Earlier versions will error during the linking phase so bail out now if clang_version[0] < 14: @@ -102,14 +103,14 @@ def win_use_clang(): # Add the temporary directory at the front of the PATH and clean up on exit os.environ["PATH"] = "%s;%s" % (tmpdir, os.environ["PATH"]) atexit.register(lambda dir_: rmtree(dir_), tmpdir) - print(f"Found Clang {clang_version[0]}.{clang_version[1]}.{clang_version[2]}: {clang_path}") + print("Found Clang {}.{}.{}: {}".format(clang_version[0], clang_version[1], clang_version[2], clang_path)) return True build_extensions = True build_warnings = [] win_force_clang = False if is_win: - if is_64bit or which("cl") is None: + if is_64bit or find_executable("cl") is None: # We do not change to clang if under 32 bits, because even with Clang we # do not use uint128_t with the 32 bits ABI. Regardless we can try to # find it when building in 32-bit mode if cl.exe was not found in the PATH. @@ -118,15 +119,15 @@ if is_win: build_warnings.append("Could not find a suitable Clang/LLVM installation. You can download LLVM from https://releases.llvm.org") build_warnings.append("Alternatively you can select the 'C++ Clang-cl build tools' in the Visual Studio Installer") build_extensions = False - cl = which("cl") - link = which("link") + cl = find_executable("cl") + link = find_executable("link") if cl is None or link is None: build_warnings.append("Could not find cl.exe and/or link.exe in the PATH, try building miasm from a Visual Studio command prompt") build_warnings.append("More information at: https://wiki.python.org/moin/WindowsCompilers") build_extensions = False else: - print(f"Found cl.exe: {cl}") - print(f"Found link.exe: {link}") + print("Found cl.exe: {}".format(cl)) + print("Found link.exe: {}".format(link)) def build_all(): packages=[ @@ -280,6 +281,7 @@ def build_all(): "-Wno-visibility", "-Wno-dll-attribute-on-redeclaration", "-Wno-tautological-compare", + "-Wno-unused-but-set-variable", ] for extension in ext_modules_all: extension.extra_compile_args = extra_compile_args @@ -343,7 +345,7 @@ def build_all(): break if not build_ok: if len(build_warnings) > 0: - print(f"ERROR: There was an issue setting up the build environment:") + print("ERROR: There was an issue setting up the build environment:") for warning in build_warnings: print(" " + warning) raise ValueError("Unable to build Miasm!") @@ -385,7 +387,7 @@ def build_all(): # Inform the user about the skipped build if not build_extensions: - print(f"WARNING: miasm jit extensions were not compiled, details:") + print("WARNING: miasm jit extensions were not compiled, details:") for warning in build_warnings: print(" " + warning) |