MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / PythonFlags

Class PythonFlags

pipcl.py:2488–2592  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2486
2487
2488class 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

Callers 2

base_compilerFunction · 0.85
base_linkerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…