Compile/link flags for the current python, for example the include path needed to get `Python.h`. The 'PIPCL_PYTHON_CONFIG' environment variable allows to override the location of the python-config executable. Members: .includes: String containing compiler
| 2486 | |
| 2487 | |
| 2488 | class PythonFlags: |
| 2489 | ''' |
| 2490 | Compile/link flags for the current python, for example the include path |
| 2491 | needed to get `Python.h`. |
| 2492 | |
| 2493 | The 'PIPCL_PYTHON_CONFIG' environment variable allows to override |
| 2494 | the location of the python-config executable. |
| 2495 | |
| 2496 | Members: |
| 2497 | .includes: |
| 2498 | String containing compiler flags for include paths. |
| 2499 | .ldflags: |
| 2500 | String containing linker flags for library paths. |
| 2501 | ''' |
| 2502 | def __init__(self): |
| 2503 | |
| 2504 | # Experimental detection of python flags from sysconfig.*() instead of |
| 2505 | # python-config command. |
| 2506 | includes_, ldflags_ = sysconfig_python_flags() |
| 2507 | |
| 2508 | if pyodide(): |
| 2509 | _include_dir = os.environ[ 'PYO3_CROSS_INCLUDE_DIR'] |
| 2510 | _lib_dir = os.environ[ 'PYO3_CROSS_LIB_DIR'] |
| 2511 | self.includes = f'-I {_include_dir}' |
| 2512 | self.ldflags = f'-L {_lib_dir}' |
| 2513 | |
| 2514 | elif 0: |
| 2515 | |
| 2516 | self.includes = includes_ |
| 2517 | self.ldflags = ldflags_ |
| 2518 | |
| 2519 | elif windows(): |
| 2520 | wp = wdev.WindowsPython() |
| 2521 | self.includes = f'/I"{wp.include}"' |
| 2522 | self.ldflags = f'/LIBPATH:"{wp.libs}"' |
| 2523 | |
| 2524 | elif pyodide(): |
| 2525 | _include_dir = os.environ[ 'PYO3_CROSS_INCLUDE_DIR'] |
| 2526 | _lib_dir = os.environ[ 'PYO3_CROSS_LIB_DIR'] |
| 2527 | self.includes = f'-I {_include_dir}' |
| 2528 | self.ldflags = f'-L {_lib_dir}' |
| 2529 | |
| 2530 | else: |
| 2531 | python_config = os.environ.get("PIPCL_PYTHON_CONFIG") |
| 2532 | if not python_config: |
| 2533 | # We use python-config which appears to work better than pkg-config |
| 2534 | # because it copes with multiple installed python's, e.g. |
| 2535 | # manylinux_2014's /opt/python/cp*-cp*/bin/python*. |
| 2536 | # |
| 2537 | # But... on non-macos it seems that we should not attempt to specify |
| 2538 | # libpython on the link command. The manylinux docker containers |
| 2539 | # don't actually contain libpython.so, and it seems that this |
| 2540 | # deliberate. And the link command runs ok. |
| 2541 | # |
| 2542 | python_exe = os.path.realpath( sys.executable) |
| 2543 | if darwin(): |
| 2544 | # Basic install of dev tools with `xcode-select --install` doesn't |
| 2545 | # seem to provide a `python3-config` or similar, but there is a |
no outgoing calls
no test coverage detected
searching dependent graphs…