summaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies/python.py
AgeCommit message (Collapse)Author
2025-12-17dependencies: Remove `log_tried` methodDylan Baker
It's now only used to populate the DependencyCandidate, so we can remove it and just calculate the same information from the `type_name` parameter. This reduces code and the number of method calls.
2025-12-17Dependencies: Make use of the DependencyCandidate classDylan Baker
This makes the type checking more reasonable (including fixing an issue that newer mypy is pointing out to us), consolidating special cases, and improving code readability.
2025-12-17dependencies: Require 'native' be passed in kwargsDylan Baker
This simplifies a bunch of cases, and likely fixes some annoying bugs in cross compile situations where should have been passing this and weren't.
2025-12-17dependencies: stop passing "language" as a keyword argumentDylan Baker
It's allowed in the `DependencyKeywordArguments` TypeDict already, so we now have two sources of truth. Additionally, it's often populated by reading from that dict, so we're just doing useless work.
2025-12-17dependencies: Pass the `name` to `ExternalDependency` constructorDylan Baker
So we don't create a default name that is overwritten except in the case of appleframeworks. This allows for some cleanup, including deleting some initializers that were only setting the name.
2025-11-19compilers: Remove Environment parameter from Compiler.has_headerDylan Baker
2025-11-19compilers: Remove Environment parameter from Compiler.find_libraryDylan Baker
2025-10-29environment: move detection functions to envconfig.pyPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-20dependencies: Add remaining internal arguments to Dependency classesDylan Baker
These may be better replaced by setting instance attributes, honestly.
2025-10-20modules/python: port dependency embed to typed_kwargsDylan Baker
2025-10-20dependency: Use a TypedDict to describe the keyword arguments to DependencyDylan Baker
This allows us to check that all of the keyword arguments are of the correct type.
2025-10-06options: replace get_value with get_value_forPaolo Bonzini
The two methods are identical. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-01Use base_prefix, not prefix for iOS framework linking.Russell Keith-Magee
Outside of a venv, sys.prefix and sys.base_prefix are the same. However, if you're using a virtual environment, sys.prefix points at the location of the virtual environment, not the location of the iOS binaries. sys.base_prefix should be used to ensure that you're always referencing the underlying install location, not the venv location.
2025-08-28python: add a python.build_config option (PEP 739)Filipe Laíns
Signed-off-by: Filipe Laíns <lains@riseup.net> Signed-off-by: Michał Górny <mgorny@quansight.com>
2025-05-06dependencies/python: Fix Framework Python when pkg-config is installedDaniele Nicolodi
In this case, self.raw_link_args is None. Fixes #14534.
2025-05-06dependencies/python: Replace non-breakable space with spaceDaniele Nicolodi
2025-05-04Add framework linking for iOS builds.Russell Keith-Magee
2025-04-09modules/gnome, modules/Python: Allow injecting RPATH flags through LDFLAGS ↵L. E. Segovia
if needed Fixes communicating the RPATH to g-i-scanner in macOS. See #14169
2025-03-10coredata: replace get_option with optstore.get_value_forDylan Baker
This is an old method, that is now just a wrapper around the OptionStore method, that doesn't add any value. It's also an option related method attached to the CoreData instead of the OptionStore, so useless and a layering violation.
2025-02-04Python: fix typo in the inserted workaround for missing RPATHL. E. Segovia
See #14169
2025-01-30Python: Work around missing rpath in Xcode python3-embedL. E. Segovia
This enables generating Python bindings and linking against `python3-embed` without resorting to later `install_name_tool` changes, as the pkg-config module provided by Xcode doesn't say that Python3.framework requires a rpath entry: $ otool -L /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Python3 /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Python3: @rpath/Python3.framework/Versions/3.9/Python3 (compatibility version 3.9.0, current version 3.9.0) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1933.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
2025-01-28modules/python: Make sure that all dependency candidates meet interfaceDylan Baker
Because in at least one case it will lack the `log_tried` method.
2024-11-01Enable GCC to find free-threaded python DLL libraryEdgar Andrés Margffoy Tuay
2024-07-11Move OptionKey in the option source file.Jussi Pakkanen
2024-07-02Python: fix limited API logic under GCC on WindowsAndrew McNulty
When building a limited API module on Windows the library to link with should be python3.dll, not python3X.dll. This was already the case for non-GCC, but should have been the case unconditionally.
2024-06-23find_program: add a kwarg to specify custom version argumentDudemanguy
When trying to get the version of a program, meson was previously hardcoded to run the binary with `--version`. This does work with the vast majority of programs, but there are a few outliers (e.g. ffmpeg) which have an unusual argument for printing out the version. Support these programs by introducing a version_argument kwarg in find_program which allows users to override `--version` with whatever the custom argument for printing the version may be for the program.
2024-06-23Add support for detecting free-threaded Python on WindowsRalf Gommers
This does a couple of things: 1. Scrape the `Py_GIL_DISABLED` sysconfig var, which is the best way as of today to determine whether the target interpreter was built with `--disable-gil` 2. link against the correct libpython 3. On Windows, work around a known issue in the python.org installer with a missing define in `pyconfig.h`, which the CPython devs have said is unlikely to be fixed since headers are shared between the regular and free-threaded builds in a single NSIS installer.
2024-06-14Merge pull request #13307 from mesonbuild/optstorerefactorJussi Pakkanen
Convert OptionStore from a dict to a full class with named methods
2024-06-14Replace direct indexing with named methods.Jussi Pakkanen
2024-06-14Rename option variable to optstore to make it unique.Jussi Pakkanen
2024-06-11Python: link correct limited API lib on mingwAndrew McNulty
This commit fixes GH issue #13167 by linking to the correct library under MINGW when the 'limited_api' kwarg is specified.
2024-06-11Python: move Windows functions to dependency baseAndrew McNulty
This is in preparation for a future commit which makes it possible for a PythonPkgConfigDependency to be used in a context where previously only a PythonSystemDependency would be used.
2024-04-16python: Fix header check for system methodJonathon Anderson
Fixes https://github.com/mesonbuild/meson/issues/12862
2024-02-12python dependency: use exceptions to pass failure state aroundEli Schwartz
Instead of returning Optional, a state that is only possible during `__init__` and which prevents mypy from knowing what it is safe to assume it will get.
2024-02-06Add a numpy dependency with pkg-config and configtool methodsRalf Gommers
These are being added for NumPy 2.0 The implementation closely follows the one for the pybind11 dependency.
2023-12-13Use SPDX-License-Identifier consistentlyDylan Baker
This replaces all of the Apache blurbs at the start of each file with an `# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing uses to be consistent in capitalization, and to be placed above any copyright notices. This removes nearly 3000 lines of boilerplate from the project (only python files), which no developer cares to look at. SPDX is in common use, particularly in the Linux kernel, and is the recommended format for Meson's own `project(license: )` field
2023-12-03python: fix mingw python detection code in case pkg-config isn't availableChristoph Reiter
The code assumed that sysconfig.get_platform() returns "mingw" for mingw Python, but that's no longer the case for 2.5 years now, as it now only starts with "mingw" and contains further information like the arch and other ABI relevant things to avoid conflicts. This updates the detection code to the current status quo. mingw Python only documents right now that it starts with "mingw", and none of that arch stuff, but it's unlikely that this will change, and this looks less error prone than looking at CC. Fixes #12547
2023-10-02python dependency: ensure that setuptools doesn't inject itself into distutilsEli Schwartz
We do not use setuptools for anything, and only lightly use distutils. Unpredictable issues can occur due to setuptools monkey-patching, which interferes with our intended use. Tell setuptools to simply never get involved. Note: while it's otherwise possible to check if the probe is run using sys.executable and avoid forking, setuptools unconditionally injects itself at startup in a way that requires subprocess isolation to disable.
2023-08-14Python: Add 'limited_api' kwarg to extension_moduleAndrew McNulty
This commit adds a new keyword arg to extension_module() that enables a user to target the Python Limited API, declaring the version of the limited API that they wish to target. Two new unittests have been added to test this functionality.
2023-06-26dependencies: switch the delayed-import mechanism for custom dependenciesEli Schwartz
Simply store the module it is expected to be found in. That module then appends to the packages dict, which guarantees mypy can verify that it's got the right type -- there is no casting needed.
2023-05-05Fix building python extensions on win-arm64Radek Bartoň
2023-05-05Python module: emit warning for debug buildtypes with MSVC and no debug PythonRalf Gommers
CPython adds a hard to avoid hardcoded link flag to look for a debug libpython. This results in a very puzzling error, so emit a warning with a clear message. Note that pybind11 has a workaround for this, which undefines `_DEBUG`. So users who use only pybind11 can use non-release buildtypes, but they won't get debug symbols on Windows unless they have a debug build.
2023-05-03dependencies: allow config-tool to fallback to default program namesEli Schwartz
If the dependency permits it, we can just do a PATH search instead of mandating that it be listed in the cross file. This is useful for the limited case where a specific dependency is known to be compatible with any machine choice. Mark the pybind11 dependency as supporting this. It's a valid choice because pybind11 is a header-only C++ library.
2023-04-23fix python.version() not working in some casesCharles Brunet
import('python').find_installation('python').version() causes exception because of a missing initialization, when `find_installation()` receives a name or a path.
2023-03-28python dependency: avoid redefinition warnings for MS_WIN64Eli Schwartz
pyconfig.h defines it in limited cases, but as empty, rather than as "1" which is what command-line defines generally do. Explicitly define it as a compatible definition so the compiler does not log a warning that the value has changed. Fixes #11592
2023-03-09dependencies: add pybind11 custom factoryEli Schwartz
This works with pkg-config and cmake without any special support. The custom factory adds further support for config-tool, via `pybind11-config`. This is useful because the config-tool will work out of the box when pybind11 is installed, but the pkg-config and cmake files are shoved into python's site-packages, which is an unfortunate distribution model and makes it impossible to use in an out of the box manner. It's possible to manually set up the PKG_CONFIG_PATH to detect it anyway, but in case that does not happen, having the config-tool fallback is extremely useful.
2023-02-27python dependency: Fix typo in placeholder stringDaniele Nicolodi
2023-02-22python dependency: handle broken pylong on many more versions of pythonEli Schwartz
This workaround was never exclusive to python2, and in fact only just got fixed in the upcoming python 3.12 release. Extend the version comparison to cover all those other cases.
2023-02-22python dependency: fix embed handling for system dependencyEli Schwartz
Only search for and provide linkage to libpython, if the dependency expects to be linked to it. Fixes overlinking on Linux / macOS when pkg-config isn't installed and the sysconfig lookup is used instead. This was correctly handled for pkg-config rather than deferring it until use, since commit bf832743441a1171518d7a436164c989be679410 -- but that handling neglected to cover sysconfig dependencies. And sysconfig would always try to link to libpython, it just respected the dependency configuration barely enough to allow falling back to "don't link" if both link_libpython=False and the library wasn't found.
2023-02-22python dependency: verify that the python header is installed for sysconfigEli Schwartz
We may or may not care that the library can be found. If link_libpython is false, we allow it to be missing and still find the dependency.