From 200406ce53e9be45b5490836051fbd86e0d8c27e Mon Sep 17 00:00:00 2001 From: GD Date: Fri, 1 Apr 2022 09:50:44 +0200 Subject: [PATCH 01/15] function to check if current compiler is Apple Clang --- extension_helpers/_setup_helpers.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/extension_helpers/_setup_helpers.py b/extension_helpers/_setup_helpers.py index 7e766da..95e9edb 100644 --- a/extension_helpers/_setup_helpers.py +++ b/extension_helpers/_setup_helpers.py @@ -12,7 +12,7 @@ from collections import defaultdict from setuptools import Extension, find_packages -from setuptools.command.build_ext import new_compiler +from setuptools.command.build_ext import customize_compiler,new_compiler from ._utils import import_file, walk_skip_hidden @@ -36,6 +36,29 @@ def get_compiler(): return new_compiler().compiler_type +def check_apple_clang(): + """ + Detemines if compiler that will be used to build extension modules is + 'Apple Clang' (which requires a specific management of OpenMP compilation + and linking flags). + + Returns + ------- + apple_clang : bool + Indicator whether current compiler is 'Apple Clang'. + """ + try: + ccompiler = new_compiler() + customize_compiler(ccompiler) + compiler_version = subprocess.run( + [ccompiler.compiler[0], "--version"], capture_output=True + ) + apple_clang = "Apple clang" in str(compiler_version.stdout) + except: + apple_clang = False + return apple_clang + + def get_extensions(srcdir='.'): """ Collect all extensions from Cython files and ``setup_package.py`` files. From b4ea694e5807227b009d215b968ff6e9c7a5a7e1 Mon Sep 17 00:00:00 2001 From: GD Date: Fri, 1 Apr 2022 09:51:12 +0200 Subject: [PATCH 02/15] test function checking if current compiler is Apple Clang --- extension_helpers/tests/test_setup_helpers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extension_helpers/tests/test_setup_helpers.py b/extension_helpers/tests/test_setup_helpers.py index 05fc7ab..dab45f4 100644 --- a/extension_helpers/tests/test_setup_helpers.py +++ b/extension_helpers/tests/test_setup_helpers.py @@ -7,7 +7,7 @@ import pytest -from .._setup_helpers import get_compiler, get_extensions +from .._setup_helpers import check_apple_clang, get_compiler, get_extensions from . import cleanup_import, run_setup extension_helpers_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) # noqa @@ -27,6 +27,9 @@ def teardown_module(module): def test_get_compiler(): assert get_compiler() in POSSIBLE_COMPILERS +def test_check_apple_clang(): + assert check_apple_clang() in [True, False] + def _extension_test_package(tmpdir, request, extension_type='c', include_numpy=False): From 45b198c59c39fb069ac671242f62d349ea6d2b05 Mon Sep 17 00:00:00 2001 From: GD Date: Fri, 1 Apr 2022 09:51:43 +0200 Subject: [PATCH 03/15] specific compilation and linking flags for Apple Clang compiler --- extension_helpers/_openmp_helpers.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/extension_helpers/_openmp_helpers.py b/extension_helpers/_openmp_helpers.py index e7376d6..17f35e5 100644 --- a/extension_helpers/_openmp_helpers.py +++ b/extension_helpers/_openmp_helpers.py @@ -22,7 +22,7 @@ from setuptools.command.build_ext import customize_compiler, get_config_var, new_compiler -from ._setup_helpers import get_compiler +from ._setup_helpers import check_apple_clang, get_compiler __all__ = ['add_openmp_flags_if_available'] @@ -134,8 +134,12 @@ def get_openmp_flags(): link_flags.append('-L' + lib_path) link_flags.append('-Wl,-rpath,' + lib_path) - compile_flags.append('-fopenmp') - link_flags.append('-fopenmp') + if not check_apple_clang(): + compile_flags.append('-fopenmp') + link_flags.append('-fopenmp') + else: + compile_flags.append('-Xpreprocessor -fopenmp') + link_flags.append('-lomp') return {'compiler_flags': compile_flags, 'linker_flags': link_flags} From 40a39fdc7944c3b16b1de70ca33c78e154ed2fad Mon Sep 17 00:00:00 2001 From: GD Date: Fri, 1 Apr 2022 10:28:09 +0200 Subject: [PATCH 04/15] add comment about libomp + refine except statement --- extension_helpers/_setup_helpers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extension_helpers/_setup_helpers.py b/extension_helpers/_setup_helpers.py index 95e9edb..ee1b53a 100644 --- a/extension_helpers/_setup_helpers.py +++ b/extension_helpers/_setup_helpers.py @@ -41,6 +41,9 @@ def check_apple_clang(): Detemines if compiler that will be used to build extension modules is 'Apple Clang' (which requires a specific management of OpenMP compilation and linking flags). + + In addition, it may require that you install `libomp` (e.g. with + `brew install libomp`). Returns ------- @@ -54,7 +57,7 @@ def check_apple_clang(): [ccompiler.compiler[0], "--version"], capture_output=True ) apple_clang = "Apple clang" in str(compiler_version.stdout) - except: + except Exception: apple_clang = False return apple_clang From ac7644e5ce30903022163118273d2767ed5c88fd Mon Sep 17 00:00:00 2001 From: GD Date: Fri, 1 Apr 2022 13:55:33 +0200 Subject: [PATCH 05/15] specific warning message for Apple Clang users + specific OpenMP include and lib path (if not aleady setup) for Apple Clang --- extension_helpers/_openmp_helpers.py | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/extension_helpers/_openmp_helpers.py b/extension_helpers/_openmp_helpers.py index 17f35e5..6a14d57 100644 --- a/extension_helpers/_openmp_helpers.py +++ b/extension_helpers/_openmp_helpers.py @@ -19,6 +19,7 @@ import datetime import tempfile import subprocess +import textwrap from setuptools.command.build_ext import customize_compiler, get_config_var, new_compiler @@ -138,8 +139,37 @@ def get_openmp_flags(): compile_flags.append('-fopenmp') link_flags.append('-fopenmp') else: + msg = textwrap.dedent( + """\ + You are using Apple Clang compiler. + + Your system should be prepared: + 1. You should have specfically installed OpenMP, + for instance by running `brew install libomp`. + 2. OpenMP source and library should be findable by the compiler. + + By default, OpenMP source and library will be looked in + `/usr/local/opt/libomp/include` and `/usr/local/opt/libomp/lib` + respectively. + + To use specific OpenMP source and library paths, you can setup + the following environment variables `CFLAGS` and `LDFLAGS` + before any compilation/installation, e.g. + ``` + export CFLAGS="-I/usr/local/opt/libomp/include" + export LDFLAGS="-L/usr/local/opt/libomp/lib" + ``` + """ + ) + log.warn(msg) compile_flags.append('-Xpreprocessor -fopenmp') + if not 'CFLAG' in os.environ and \ + os.path.dir('/usr/local/opt/libomp/include'): + compile_flags.append('-I/usr/local/opt/libomp/include') link_flags.append('-lomp') + if not 'LDFLAG' in os.environ and \ + os.path.dir('/usr/local/opt/libomp/lib'): + compile_flags.append('-I/usr/local/opt/libomp/lib') return {'compiler_flags': compile_flags, 'linker_flags': link_flags} From 401d869f3dc5c6a47b99ecb564ebf7ab71dfef45 Mon Sep 17 00:00:00 2001 From: GD Date: Fri, 1 Apr 2022 13:57:35 +0200 Subject: [PATCH 06/15] fix typo in dir check --- extension_helpers/_openmp_helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extension_helpers/_openmp_helpers.py b/extension_helpers/_openmp_helpers.py index 6a14d57..025c449 100644 --- a/extension_helpers/_openmp_helpers.py +++ b/extension_helpers/_openmp_helpers.py @@ -164,11 +164,11 @@ def get_openmp_flags(): log.warn(msg) compile_flags.append('-Xpreprocessor -fopenmp') if not 'CFLAG' in os.environ and \ - os.path.dir('/usr/local/opt/libomp/include'): + os.path.isdir('/usr/local/opt/libomp/include'): compile_flags.append('-I/usr/local/opt/libomp/include') link_flags.append('-lomp') if not 'LDFLAG' in os.environ and \ - os.path.dir('/usr/local/opt/libomp/lib'): + os.path.isdir('/usr/local/opt/libomp/lib'): compile_flags.append('-I/usr/local/opt/libomp/lib') return {'compiler_flags': compile_flags, 'linker_flags': link_flags} From ad2b191f58c39768e3173476a2373041fd58fc0c Mon Sep 17 00:00:00 2001 From: GD Date: Fri, 1 Apr 2022 14:03:42 +0200 Subject: [PATCH 07/15] add preargs instead of postargs to compile command (because '-Xprocessor -fopenmp' not undertood by Apple Clang as postargs but ok as preargs) --- extension_helpers/_openmp_helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extension_helpers/_openmp_helpers.py b/extension_helpers/_openmp_helpers.py index 025c449..f309bd1 100644 --- a/extension_helpers/_openmp_helpers.py +++ b/extension_helpers/_openmp_helpers.py @@ -223,12 +223,12 @@ def check_openmp_support(openmp_flags=None): # Compile, test program ccompiler.compile(['test_openmp.c'], output_dir='objects', - extra_postargs=compile_flags) + extra_preargs=compile_flags) # Link test program objects = glob.glob(os.path.join('objects', '*' + ccompiler.obj_extension)) ccompiler.link_executable(objects, 'test_openmp', - extra_postargs=link_flags) + extra_preargs=link_flags) # Run test program output = subprocess.check_output('./test_openmp') From 31de7ec1f57981a63afbfd75f8668c61b72bd36c Mon Sep 17 00:00:00 2001 From: GD Date: Fri, 1 Apr 2022 14:10:00 +0200 Subject: [PATCH 08/15] fix typo regarding link_flags --- extension_helpers/_openmp_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension_helpers/_openmp_helpers.py b/extension_helpers/_openmp_helpers.py index f309bd1..a302bca 100644 --- a/extension_helpers/_openmp_helpers.py +++ b/extension_helpers/_openmp_helpers.py @@ -169,7 +169,7 @@ def get_openmp_flags(): link_flags.append('-lomp') if not 'LDFLAG' in os.environ and \ os.path.isdir('/usr/local/opt/libomp/lib'): - compile_flags.append('-I/usr/local/opt/libomp/lib') + link_flags.append('-L/usr/local/opt/libomp/lib') return {'compiler_flags': compile_flags, 'linker_flags': link_flags} From 094b820e2c0845b6c2086b0c8d083e8922aaf2d2 Mon Sep 17 00:00:00 2001 From: GD Date: Fri, 1 Apr 2022 16:56:22 +0200 Subject: [PATCH 09/15] fix typo --- extension_helpers/_openmp_helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extension_helpers/_openmp_helpers.py b/extension_helpers/_openmp_helpers.py index a302bca..f538cc1 100644 --- a/extension_helpers/_openmp_helpers.py +++ b/extension_helpers/_openmp_helpers.py @@ -163,11 +163,11 @@ def get_openmp_flags(): ) log.warn(msg) compile_flags.append('-Xpreprocessor -fopenmp') - if not 'CFLAG' in os.environ and \ + if not 'CFLAGS' in os.environ and \ os.path.isdir('/usr/local/opt/libomp/include'): compile_flags.append('-I/usr/local/opt/libomp/include') link_flags.append('-lomp') - if not 'LDFLAG' in os.environ and \ + if not 'LDFLAGS' in os.environ and \ os.path.isdir('/usr/local/opt/libomp/lib'): link_flags.append('-L/usr/local/opt/libomp/lib') From dcca6d79a89cbcab2d3d52bbe17b71d4a446c4f1 Mon Sep 17 00:00:00 2001 From: GD Date: Fri, 1 Apr 2022 17:08:38 +0200 Subject: [PATCH 10/15] account for potential CXXFLAGS env variable --- extension_helpers/_openmp_helpers.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/extension_helpers/_openmp_helpers.py b/extension_helpers/_openmp_helpers.py index f538cc1..6a5c410 100644 --- a/extension_helpers/_openmp_helpers.py +++ b/extension_helpers/_openmp_helpers.py @@ -130,6 +130,10 @@ def get_openmp_flags(): if include_path: compile_flags.append('-I' + include_path) + include_path = _get_flag_value_from_var('-I', 'CXXFLAGS') + if include_path: + compile_flags.append('-I' + include_path) + lib_path = _get_flag_value_from_var('-L', 'LDFLAGS') if lib_path: link_flags.append('-L' + lib_path) @@ -153,8 +157,8 @@ def get_openmp_flags(): respectively. To use specific OpenMP source and library paths, you can setup - the following environment variables `CFLAGS` and `LDFLAGS` - before any compilation/installation, e.g. + the following environment variables `CFLAGS` (or `CXXFLAGS`) + and `LDFLAGS` before any compilation/installation, e.g. ``` export CFLAGS="-I/usr/local/opt/libomp/include" export LDFLAGS="-L/usr/local/opt/libomp/lib" @@ -163,7 +167,7 @@ def get_openmp_flags(): ) log.warn(msg) compile_flags.append('-Xpreprocessor -fopenmp') - if not 'CFLAGS' in os.environ and \ + if not 'CFLAGS' in os.environ and not 'CXXFLAGS' in os.environ and \ os.path.isdir('/usr/local/opt/libomp/include'): compile_flags.append('-I/usr/local/opt/libomp/include') link_flags.append('-lomp') From e4c01f861c15a2fd188de3b697239271177eb335 Mon Sep 17 00:00:00 2001 From: GD Date: Fri, 1 Apr 2022 17:33:00 +0200 Subject: [PATCH 11/15] modify _get_flag_value_from_var to return list of extracted flags if corresponding environment variable contains one or more --- extension_helpers/_openmp_helpers.py | 24 +++++++++++++++---- .../tests/test_openmp_helpers.py | 17 ++++++++++++- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/extension_helpers/_openmp_helpers.py b/extension_helpers/_openmp_helpers.py index 6a5c410..9d3d2b4 100644 --- a/extension_helpers/_openmp_helpers.py +++ b/extension_helpers/_openmp_helpers.py @@ -61,6 +61,12 @@ def _get_flag_value_from_var(flag, var, delim=' '): The environment variable to extract the flag from, e.g. CFLAGS or LDFLAGS. delim : str, optional The delimiter separating flags inside the environment variable + + Returns + ------- + extracted_flags : None|list + List of flags starting with flag extracted from var environment + variable. Examples -------- @@ -98,10 +104,15 @@ def _get_flag_value_from_var(flag, var, delim=' '): return None # Extract flag from {var:value} + extracted_flags = [] if flags: for item in flags.split(delim): if item.startswith(flag): - return item[flag_length:] + extracted_flags.append(item[flag_length:]) + if len(extracted_flags) > 0: + return extracted_flags + else: + return None def get_openmp_flags(): @@ -128,16 +139,19 @@ def get_openmp_flags(): include_path = _get_flag_value_from_var('-I', 'CFLAGS') if include_path: - compile_flags.append('-I' + include_path) + for _ in include_path: + compile_flags.append('-I' + _) include_path = _get_flag_value_from_var('-I', 'CXXFLAGS') if include_path: - compile_flags.append('-I' + include_path) + for _ in include_path: + compile_flags.append('-I' + _) lib_path = _get_flag_value_from_var('-L', 'LDFLAGS') if lib_path: - link_flags.append('-L' + lib_path) - link_flags.append('-Wl,-rpath,' + lib_path) + for _ in include_path: + link_flags.append('-L' + _) + link_flags.append('-Wl,-rpath,' + _) if not check_apple_clang(): compile_flags.append('-fopenmp') diff --git a/extension_helpers/tests/test_openmp_helpers.py b/extension_helpers/tests/test_openmp_helpers.py index 6a704b3..0baecd6 100644 --- a/extension_helpers/tests/test_openmp_helpers.py +++ b/extension_helpers/tests/test_openmp_helpers.py @@ -8,7 +8,7 @@ import pytest from setuptools import Extension -from .._openmp_helpers import add_openmp_flags_if_available, generate_openmp_enabled_py +from .._openmp_helpers import _get_flag_value_from_var, add_openmp_flags_if_available, generate_openmp_enabled_py @pytest.fixture @@ -51,3 +51,18 @@ def test_generate_openmp_enabled_py(openmp_expected): if openmp_expected is not None: assert openmp_expected is is_openmp_enabled + + +def test_get_flag_value_from_var(): + # define input + var = 'EXTTESTFLAGS' + flag = '-I' + # non existing var (at least should not) + assert _get_flag_value_from_var(flag, var) is None + # setup env varN + os.environ[var] = '-I/path/to/file1 -I/path/to/file2 -custom_option1 -custom_option2' + # non existing flag + assert _get_flag_value_from_var('-L', var) is None + # existing flag + assert _get_flag_value_from_var(flag, var) == ['/path/to/file1', '/path/to/file2'] + From e93d69581da4f7f5c67a92c30da1696f2e490b2f Mon Sep 17 00:00:00 2001 From: GD Date: Mon, 11 Apr 2022 14:51:19 +0200 Subject: [PATCH 12/15] fix typo regarding lib path parsing --- extension_helpers/_openmp_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension_helpers/_openmp_helpers.py b/extension_helpers/_openmp_helpers.py index 9d3d2b4..792d149 100644 --- a/extension_helpers/_openmp_helpers.py +++ b/extension_helpers/_openmp_helpers.py @@ -149,7 +149,7 @@ def get_openmp_flags(): lib_path = _get_flag_value_from_var('-L', 'LDFLAGS') if lib_path: - for _ in include_path: + for _ in lib_path: link_flags.append('-L' + _) link_flags.append('-Wl,-rpath,' + _) From cc7aafd5eb1a38f767c957a15be52bb56725cda5 Mon Sep 17 00:00:00 2001 From: GD Date: Tue, 12 Apr 2022 15:25:51 +0200 Subject: [PATCH 13/15] check for the OS (i.e. MacOS) before testing for Apple Clang compiler --- extension_helpers/_setup_helpers.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/extension_helpers/_setup_helpers.py b/extension_helpers/_setup_helpers.py index ee1b53a..782c0ac 100644 --- a/extension_helpers/_setup_helpers.py +++ b/extension_helpers/_setup_helpers.py @@ -9,6 +9,7 @@ import shutil import logging import subprocess +import sys from collections import defaultdict from setuptools import Extension, find_packages @@ -42,24 +43,26 @@ def check_apple_clang(): 'Apple Clang' (which requires a specific management of OpenMP compilation and linking flags). - In addition, it may require that you install `libomp` (e.g. with - `brew install libomp`). + Note: it first checks that the OS is indeed MacOS. Returns ------- apple_clang : bool Indicator whether current compiler is 'Apple Clang'. """ - try: - ccompiler = new_compiler() - customize_compiler(ccompiler) - compiler_version = subprocess.run( - [ccompiler.compiler[0], "--version"], capture_output=True - ) - apple_clang = "Apple clang" in str(compiler_version.stdout) - except Exception: - apple_clang = False - return apple_clang + if sys.platform != "darwin": + return False + else: + try: + ccompiler = new_compiler() + customize_compiler(ccompiler) + compiler_version = subprocess.run( + [ccompiler.compiler[0], "--version"], capture_output=True + ) + apple_clang = "Apple clang" in str(compiler_version.stdout) + except Exception: + apple_clang = False + return apple_clang def get_extensions(srcdir='.'): From b1a10a52fff1658cdb988f2ce303da5761a04444 Mon Sep 17 00:00:00 2001 From: GD Date: Tue, 12 Apr 2022 15:31:30 +0200 Subject: [PATCH 14/15] improve libomp search on MacOS --- extension_helpers/_openmp_helpers.py | 52 ++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/extension_helpers/_openmp_helpers.py b/extension_helpers/_openmp_helpers.py index 792d149..26f2296 100644 --- a/extension_helpers/_openmp_helpers.py +++ b/extension_helpers/_openmp_helpers.py @@ -65,7 +65,7 @@ def _get_flag_value_from_var(flag, var, delim=' '): Returns ------- extracted_flags : None|list - List of flags starting with flag extracted from var environment + List of flags starting with flag extracted from var environment variable. Examples @@ -74,7 +74,7 @@ def _get_flag_value_from_var(flag, var, delim=' '): function will then return the following: >>> _get_flag_value_from_var('-L', 'LDFLAGS') - '/usr/local/include' + ['/usr/local/include'] Notes ----- @@ -128,6 +128,9 @@ def get_openmp_flags(): ----- The flags returned are not tested for validity, use `check_openmp_support(openmp_flags=get_openmp_flags())` to do so. + + On MacOS, it may require that you install `libomp` (e.g. with + `brew install libomp`). """ compile_flags = [] @@ -166,13 +169,14 @@ def get_openmp_flags(): for instance by running `brew install libomp`. 2. OpenMP source and library should be findable by the compiler. - By default, OpenMP source and library will be looked in - `/usr/local/opt/libomp/include` and `/usr/local/opt/libomp/lib` - respectively. + By default, `brew` will be use to find OpenMP source and + library. If not available, they will be looked for in + standard system directories. - To use specific OpenMP source and library paths, you can setup - the following environment variables `CFLAGS` (or `CXXFLAGS`) - and `LDFLAGS` before any compilation/installation, e.g. + To override this behavior and use specific OpenMP source and + library paths, you can setup the following environment + variables `CFLAGS` (or `CXXFLAGS`) and `LDFLAGS` before any + compilation/installation, e.g. ``` export CFLAGS="-I/usr/local/opt/libomp/include" export LDFLAGS="-L/usr/local/opt/libomp/lib" @@ -180,14 +184,34 @@ def get_openmp_flags(): """ ) log.warn(msg) + # try to find path to libomp + try: + brew_check = subprocess.run( + ["brew", "--prefix", "libomp"], capture_output=True + ) + libomp = str(brew_check.stdout) + except Exception: + if os.path.isdir('/usr/local/opt/libomp'): + libomp = '/usr/local/opt/libomp' + elif os.path.isfile('/opt/homebrew/include/omp.h') \ + and os.path.isfile('/opt/homebrew/lib/libomp.a'): + libomp = '/opt/homebrew' + else: + libomp = None + # compile flags compile_flags.append('-Xpreprocessor -fopenmp') - if not 'CFLAGS' in os.environ and not 'CXXFLAGS' in os.environ and \ - os.path.isdir('/usr/local/opt/libomp/include'): - compile_flags.append('-I/usr/local/opt/libomp/include') + # additional include flag + if not 'CFLAGS' in os.environ and not 'CXXFLAGS' in os.environ \ + and libomp is not None \ + and os.path.isdir(os.path.join(libomp, 'include')): + compile_flags.append('-I' + os.path.join(libomp, 'include')) + # link flag link_flags.append('-lomp') - if not 'LDFLAGS' in os.environ and \ - os.path.isdir('/usr/local/opt/libomp/lib'): - link_flags.append('-L/usr/local/opt/libomp/lib') + # additional link flag + if not 'LDFLAGS' in os.environ \ + and libomp is not None \ + and os.path.isdir(os.path.join(libomp, 'lib')): + link_flags.append('-L' + os.path.join(libomp, 'lib')) return {'compiler_flags': compile_flags, 'linker_flags': link_flags} From f88cdbb3f523f9fbd0ae0c86b783ee25afa5f54e Mon Sep 17 00:00:00 2001 From: GD Date: Tue, 12 Apr 2022 17:54:07 +0200 Subject: [PATCH 15/15] improve extraction of command output --- extension_helpers/_openmp_helpers.py | 2 +- extension_helpers/_setup_helpers.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extension_helpers/_openmp_helpers.py b/extension_helpers/_openmp_helpers.py index 26f2296..6a1033e 100644 --- a/extension_helpers/_openmp_helpers.py +++ b/extension_helpers/_openmp_helpers.py @@ -189,7 +189,7 @@ def get_openmp_flags(): brew_check = subprocess.run( ["brew", "--prefix", "libomp"], capture_output=True ) - libomp = str(brew_check.stdout) + libomp = brew_check.stdout.decode('utf-8').strip() except Exception: if os.path.isdir('/usr/local/opt/libomp'): libomp = '/usr/local/opt/libomp' diff --git a/extension_helpers/_setup_helpers.py b/extension_helpers/_setup_helpers.py index 782c0ac..85b5714 100644 --- a/extension_helpers/_setup_helpers.py +++ b/extension_helpers/_setup_helpers.py @@ -59,7 +59,7 @@ def check_apple_clang(): compiler_version = subprocess.run( [ccompiler.compiler[0], "--version"], capture_output=True ) - apple_clang = "Apple clang" in str(compiler_version.stdout) + apple_clang = "Apple clang" in compiler_version.stdout.decode('utf-8') except Exception: apple_clang = False return apple_clang