summaryrefslogtreecommitdiff
path: root/mesonbuild/modules/python.py
AgeCommit message (Collapse)Author
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-17modules/python: use typed_kwargs for `install_dir`Dylan Baker
This `install_dir` is slightly different than the one in `BuildTarget` (though I'd like to make them the same in the future). It is only allowed to be `str | bool | None`, and the implementation has always assumed this, it would have broken with an array value.
2025-12-17interpreter: Add type checking for BuildTarget(install_dir: )Dylan Baker
This just puts the type checking in the frontend, there's still some serious cleanup in the build and backend that need to happen.
2025-10-20interpreter: use typed_kwargs for checking disabler dependencyDylan Baker
2025-10-20interpreter: remove permittedKwargs from dependencyDylan Baker
This is also the ideal time to remove the `allow_unknown` from `typed_kwargs`, as permittedKwargs was providing extra key checking, so now `typed_kwargs` can do that instead.
2025-10-20modules/python: port dependency embed to typed_kwargsDylan Baker
2025-10-20interpreter: port dependency native 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-15revert local_program()Eli Schwartz
This reverts https://github.com/mesonbuild/meson/pull/15107 Explicit objections regarding the design were raised and not answered, so it shouldn't have been merged. It needs to be discussed and revisited.
2025-10-15Add common ABC for ExternalProgram and LocalProgramXavier Claessens
2025-10-15Replace OverrideExecutable and OverrideProgram with LocalProgramXavier Claessens
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-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-08-01interpreter: move dependency kwargs to shared moduleDylan Baker
We're going to use this in the Python module as well.
2025-06-17modules: convert custom holders to InterpreterObject.methodPaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
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.
2024-07-17Remove module type from OptionKey.Jussi Pakkanen
2024-07-11Move OptionKey in the option source file.Jussi Pakkanen
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: fix limited API logic under mingwAndrew McNulty
The Python Limited API support that was added in 1.2 had special handling of Windows, but the condition to check for Windows was not correct: it checked for MSVC and not for the target's OS. This causes mingw installations to not have the special handling applied. This commit fixes this to check explicitly for Windows.
2024-05-23Refactor option classes to their own file.Jussi Pakkanen
2024-02-19Fix KeyError in Python moduleCharles Brunet
0e7fb07 introduced a subtile bug in the Python module. If a python version is found, but is missing a required module, it is added to the list of python installations, but the `run_bytecompile` attribute for that version was not initialized. Therefore, if any other python version added something to install, it was raising a KeyError when trying to read the `run_bytecompile` attribute for the python version with missing module.
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-10-17interpreter: use typed_kwargs for build_target.gnu_symbol_visibilityDylan Baker
2023-10-17interpreter: use typed_kwargs for build_target.nativeDylan Baker
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-08-10python module: add a few more type annotationsEli Schwartz
2023-08-10allow some ObjectHolder subclasses to continue to be genericEli Schwartz
ExternalProgram and CustomTarget have some use cases for producing subclassed interpreter holders with more specific types and methods. In order for those subclasses to properly refer to their held_object, we need a shared base class that is still generic, though bound. For the derived held objects, inherit from the base class and specify the final types as the module-specific type.
2023-07-28modules/python: use typed_pos_args for extension_moduleDylan Baker
2023-07-28modules/python: typed_kwargs for subdirDylan Baker
We cannot re-use the existing KwargInfo, since we need to know if the keyword was set explicitly or not, since it conflicts with `install_dir`
2023-07-28modules/python: use the SHARED_MOD_KWS for extension methodDylan Baker
2023-07-26Fix install_data() default install pathDaniele Nicolodi
This fixes two issues in constructing the default installation path when install_dir is not specified: - inside a subproject, install_data() would construct the destination path using the parent project name instead than the current project name, - when specifying preserve_path, install_data() would construct the destination path omitting the project name. Fixes #11910.
2023-07-19move various bits of type-checking only code to TYPE_CHECKING blocksEli Schwartz
Mostly detected with flake8-type-checking. Also quote T.cast() first arguments, since those are not affected by future annotations.
2023-07-19fix implicit_reexport issues and enforce them going forwardEli Schwartz
This detects cases where module A imports a function from B, and C imports that same function from A instead of B. It's not part of the API contract of A, and causes innocent refactoring to break things.
2023-06-01python: Use detect.find_external_dependency() for log consistencyXavier Claessens
py.find_installation().dependency() was not logging whether it is found or not. Use find_external_dependency() for consistency.
2023-05-03python bytecompile: use correct install tagEli Schwartz
2023-05-02bytecompile: switch to handling destdir in the script launcher envEli Schwartz
2023-05-02python module: add an automatic byte-compilation stepEli Schwartz
For all source `*.py` files installed via either py.install_sources() or an `install_dir: py.get_install_dir()`, produce `*.pyc` files at install time. Controllable via a module option.
2023-05-02Log python name when not foundCharles Brunet
Fixes #11686.
2023-05-02Find python3.xx on windowsCharles Brunet
2023-05-02Ensure python fallback has the right versionCharles Brunet
Fixes #11057
2023-02-22merge the python dependency from the python module into dependenciesEli Schwartz
We have two copies of this code, and the python module one is vastly superior, not just because it allows choosing which python executable to base itself on. Unify this. Fixes various issues including non-Windows support for sysconfig, and pypy edge cases.
2023-02-22partial migration of the python module dependency into dependenciesEli Schwartz
In preparation for wholly merging the dependency handling from the python module into dependencies.*, move the unique class definitions from there into their new home in dependencies.python, which is semantically convenient.
2023-02-22python module/dependency: move the specialized external programEli Schwartz
In preparation for handling more work inside dependencies.*, we need to be able to run a PythonExternalProgram from the python dependency. Move most of the definition -- but only the parts that have no interest in a ModuleState -- and subclass a bit of sanity checking that we need to handle specially when used in the module.
2023-02-22python module: inline the dependency methods checkingEli Schwartz
It can go directly inside the function which immediately uses it. There's no purpose in looking it up exactly once and using it exactly once, but looking it up outside the function and complicating the function signature in order to pass it as a function argument.
2023-02-22python module: move the introspection script into an external scriptEli Schwartz
We write this out as an embedded string to a tempfile in order to run it, which is pretty awkward. And usually Meson's files are already files on disk, not packed into a zip, so we can simply run it directly. Since python 3.7, which is our new minimum, we can handle this well via the stdlib. (There's also mesonbuild.mesondata, but we do not need persistence in the builddir.) This also solves the problem that has always been there, of giant python programs inside strings occasionally confusing syntax highlighters. Or even, it would be nice if we had syntax highlighting for this introspection program. :D
2023-02-22python module: break the association between dependency and installation objectsEli Schwartz
We pass around a PythonInstallation into the depths of the dependency factory, solely so that we can get at is_pypy in one particular branch. We don't need the DSL functions, we don't need access to the interpreter, let's just use the enhanced ExternalProgram object on its own. Add is_pypy to the object, and modify other references to get information from .info['...'] instead of direct access.