scripts/wrap/__main__.py: use pipcl.py's support for python build flags.
authorJulian Smith <[email protected]>
Thu, 2 Nov 2023 15:56:37 +0000 (15:56 +0000)
committerSebastian Rasmussen <[email protected]>
Thu, 2 Nov 2023 18:51:54 +0000 (19:51 +0100)
This fixes finding of python-config on some macos systems.

This commit is a subset of master commit da3c74cd0d3 "scripts/wrap/: fixed
pyodide builds and simplified windows python search.". We haven't cherry-picked
the whole commit because this would require other Pyodide-related changes that
are not suitable for 1.23.x.

scripts/wrap/__main__.py

index 10741417ead4d719e5b4f706e19ee13609c8e30b..a543a689c14137307d5bbd2a50542b6b9b7a220f 100644 (file)
@@ -926,6 +926,7 @@ except ModuleNotFoundError:
     resource = None
 
 import jlib
+import pipcl
 import wdev
 
 from . import classes
@@ -1891,23 +1892,9 @@ def build( build_dirs, swig_command, args, vs_upgrade):
                             flags_link = f'-L {_lib_dir}'
 
                         else:
-                            python_exe = os.path.realpath( sys.executable)
-                            jlib.log('python_exe={python_exe}')
-                            python_configs = (
-                                    f'{python_exe}-config',
-                                    'python3-config',
-                                    )
-                            jlib.log('python_configs={python_configs}')
-                            for python_config in python_configs:
-                                if jlib.fs_find_in_paths( python_config, verbose=True):
-                                    break
-                            else:
-                                raise Exception( f'Cannot find `python-config`, tried: {python_configs}')
-                            jlib.log( 'Using {python_config=}')
-                            # `--cflags` gives things like `-Wno-unused-result -g`
-                            # etc, -so we just use `--includes`.
-                            flags_compile = jlib.system( f'{python_config} --includes', out='return', verbose=1).replace('\n', ' ')
-                            flags_link = jlib.system( f'{python_config} --ldflags', out='return', verbose=1).replace('\n', ' ')
+                            python_flags = pipcl.PythonFlags()
+                            flags_compile = python_flags.includes
+                            flags_link = python_flags.ldflags
                         if state.state_.macos:
                             # We need this to avoid numerous errors like:
                             #