aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/python.py
AgeCommit message (Collapse)AuthorFilesLines
2021-10-27fix various flake8 whitespace errorsEli Schwartz1-5/+5
2021-10-26dep.name(): return dependency name even if dependency is not foundThomas Heijligen1-2/+1
The dep.name() function schould always return the name of the dependency as documented. No matter if it was found or not. https://mesonbuild.com/Reference-manual_returned_dep.html#depfound
2021-10-10Fix typos discovered by codespellChristian Clauss1-3/+3
2021-10-08python: Add platlibdir and purelibdir optionsXavier Claessens1-6/+11
2021-10-04f-stringsEli Schwartz1-4/+2
2021-09-29modules: python: better handling of the Python paths for DebianFilipe Laíns1-8/+35
Hardcoding the name is fragile, and enabling it based on the existence of /etc/debian_version (as the is_debianlike helper does) will result in incorrect paths if the Python binary is not provided by Debian. Using the deb_system distuils scheme instead makes sure we use the install path from the current interpreter, which Debian could change between releases, and gives us the correct value on Python installations that are not provided by Debian (eg. deadsnakes, Github Action Python, etc.) Do notice, though, that there is still no guarantee that these are the correct paths, as they assume all schemes paths have the install prefix as a base, see #9284. Signed-off-by: Filipe Laíns <lains@riseup.net>
2021-09-06mintro: add installed_planFilipe Laíns1-1/+5
Signed-off-by: Filipe Laíns <lains@riseup.net>
2021-08-31python module: fix error message mentioning setuptoolsEli Schwartz1-1/+1
We use distutils, not setuptools, for probing information.
2021-08-30Add missing "disabler" kwarg to python.dependency()Xavier Claessens1-0/+1
There is a unit test using it and now fails because the warning about unknown kwarg became fatal.
2021-08-27interpreter: fix cases of `KwargInfo(..., T, default=None)`Dylan Baker1-1/+2
The correct way to mark these is `KwargInfo(..., (T, type(None)))`. There's also a few cases of `(T, None)` which is invalid, as `None` isn't a type
2021-08-27python module: produce the correct install path on every OSEli Schwartz1-1/+1
The sysconfig paths are, by default, correct for every OS -- they are supposed to follow the scheme that python knows about per default. For some reason, this overrode the scheme to posix_prefix, which is the default for posix OSes like linux and macOS, but wrong on Windows. Simply deleting this entirely makes everything that used to work, still work, and a couple new things start working.
2021-08-22python: Workaround broken install pathXavier Claessens1-3/+20
2021-08-18python module: fix extensions without explicit subdir being installed to libdirEli Schwartz1-4/+4
They are documented to go in site-packages, and indeed belong there. Regression from the initial implementation via commit ad296976f079cd185ab7361e3e4b18c6bf684090 Fixes #6331
2021-08-18python module: make external program wrapper have access to useful metadataEli Schwartz1-26/+35
Basically just reorganize code. Try to make it a little neater, while we're at it.
2021-08-18Fix incorrect .name attribute for python programEli Schwartz1-3/+4
It is always set to python3 even if we asked for python2...
2021-08-18fix some confusingly indirect codeEli Schwartz1-3/+3
rsplit(..., 1) always produces exactly one split, by design, there's no need to then join a 1-element list via a generator comprehension after extracting the end of it via pop. If this commit message sounds confusing, then so was I when trying to figure out what this actually did and if it needed extracting to PythonExternalModule.
2021-08-17Add install tagsXavier Claessens1-3/+5
Fixes: #7007.
2021-08-03Fix python module leaving PKG_CONFIG_LIBDIR set in os.environ.Xavier Claessens1-4/+7
2021-07-13modules/python: fix up a few simply typing warnings/errorsDylan Baker1-8/+24
These were spotted by mypy and pyright. One is a string where a Path is expected, another other is a possibly unbound variable, and the third is bound but unused variables.
2021-07-13modules/python: Allow trying a macos framework as well other methodsDylan Baker1-2/+18
2021-07-13modules/python: make some internal helpers protectedDylan Baker1-4/+4
2021-07-13modules/python: use factory for dependencyDylan Baker1-90/+83
This removes the odd 'pkgdep' attribute thing, and makes it behave more like a proper dependency
2021-07-13modules/python: simplify a number of interfacesDylan Baker1-33/+27
Including not calling back into `Interpreter.func_*`, which is not a good idea both from a type saftey and perforamance point of view. Instead there's now a shared _impl method
2021-07-13modules/python: use typed_pos_argsDylan Baker1-10/+15
And note that the way that find_installation works is completely broken in regards to machine files
2021-07-13modules/python: Add type annotationsDylan Baker1-80/+96
There's still a number of things that don't properly type check, that's expected though as the input is often unvalidated and assumed good.
2021-07-13modules/python: sort importsDylan Baker1-8/+9
2021-06-18holders: Fix the remaining code to respect the holder changesDaniel Mensinger1-21/+33
2021-06-17expose SystemDependency and BuiltinDependency as toplevel classesEli Schwartz1-2/+1
mesonbuild.dependencies.__init__ exposes configtool, pkgconfig, cmake and more in __init__.py, so there's no reason we should be tying SystemDependency to the internal organization implementation of the subpackage! In the 2nd previous commit it took quite some effort to figure out that the python module "does not exist" because of import errors while refactoring something completely different.
2021-06-17move base class for system dependencies into base.pyEli Schwartz1-1/+1
In accordance with review comments; it's small enough this seems fitting.
2021-06-14dependencies: Use the SystemDependencyDylan Baker1-5/+3
This fixes these dependencies, which currently return the name of the dependency as the type. Fixes #8877
2021-06-03deps: Split dependencies.baseDaniel Mensinger1-1/+1
Split the Factory and dependency classes out of the base.py script to improve maintainability.
2021-05-28modules: Add methods dict everywhereXavier Claessens1-0/+3
This fix calling random internal methods from meson.build as long as they were not prefixed by underscore.
2021-05-28modules: Remove snippet methodsXavier Claessens1-3/+2
The only advantage they have is they have the interpreter in arguments, but it's already available as self.interpreter. We should discourage usage of the interpreter API and rely on ModuleState object instead in the future. This also lift the restriction that a module method cannot add build targets, but that was not enforced for snippet methods anyway (and some modules were doing it) and it's really loose restriction as it should check for many other things if we wanted to make it consistent.
2021-05-08interpreter: 'embed' kwarg is only valid in python moduleXavier Claessens1-1/+1
2021-04-12interpreter: Split permitted_kwargs dictXavier Claessens1-2/+2
2021-03-19split program related classes and functions out of dependenciesDylan Baker1-2/+2
Dependencies is already a large and complicated package without adding programs to the list. This also allows us to untangle a bit of spaghetti that we have.
2021-03-04mass rewrite of string formatting to use f-strings everywhereEli Schwartz1-19/+19
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04various python neatness cleanupsEli Schwartz1-3/+3
All changes were created by running "pyupgrade --py3-only --keep-percent-format" and committing the results. I have not touched string formatting for now. - use set literals - simplify .format() parameter naming - remove __future__ - remove default "r" mode for open() - use OSError rather than compatibility aliases - remove stray parentheses in function(generator) scopes
2021-03-04Simplify module APIXavier Claessens1-7/+6
- ModuleState is now a real class that will have methods in the future for actions modules needs, instead of using interpreter internal API. - New ModuleObject base class, similar to InterpreterObject, that should be used by all objects returned by modules. Its methods gets the ModuleState passed as first argument. It has a `methods` dictionary to define what is public API that can be called from build definition. - Method return value is not required to be a ModuleReturnValue any more, it can be any type that interpreter can holderify, including ModuleObject. - Legacy module API is maintained until we port all modules. In the future modules should be updated: - Use methods dict. - Remove snippets. - Custom objects returned by modules should all be subclass of ModuleObject to get the state iface in their methods. - Modules should never call into interpreter directly and instead state object should have wrapper API. - Stop using ModuleReturnValue in methods that just return simple objects like strings. Possibly remove ModuleReturnValue completely since all objects that needs to be processed by interpreter (e.g. CustomTarget) should be created through ModuleState API.
2021-01-04Use a single coredata dictionary for optionsDylan Baker1-1/+1
This patches takes the options work to it's logical conclusion: A single flat dictionary of OptionKey: UserOptions. This allows us to simplify a large number of cases, as we don't need to check if an option is in this dict or that one (or any of 5 or 6, actually).
2020-11-20use real pathlib moduleDylan Baker1-1/+1
We added the _pathlib module to work around defeciencies in python 3.5's implementation, since we now rely on 3.6 lets drop this
2020-10-06python.dependency() is not respecting 'required' kwargXavier Claessens1-2/+9
2020-10-04pathlib: Fix resolve() by overriding it in Python 3.5Daniel Mensinger1-1/+1
2020-05-10python: install_sources() should default to pure, following the docMarc-André Lureau1-1/+1
As stated by the doc, default to install python sources to purelib location, as they should not depend on platform. This also fixes discrepancy between get_install_dir() and install_sources() locations. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-04-28find_program: Fixes when the program has been overridden by executableXavier Claessens1-5/+5
- ExternalProgramHolder has path() method while CustomTargetHolder and BuildTargetHolder have full_path(). - The returned ExternalProgramHolder's path() method was broken, because build.Executable object has no get_path() method, it needs the backend. - find_program('overridden_prog', version : '>=1.0') was broken because it needs to execute the exe that is not yet built. Now assume the program has the (sub)project version. - If the version check fails, interpreter uses ExternalProgramHolder.get_name() for the error message but build.Executable does not implement get_name() method.
2020-03-23Fix legacy env var support with crossJohn Ericson1-2/+2
Fix #3969
2020-02-17modules/python: Do not error out if positional args are passedNirbheek Chauhan1-1/+5
Also update the documentation. Fixes https://github.com/mesonbuild/meson/issues/6470
2020-01-29dependencies: Make Dependency initializer signatures matchDylan Baker1-1/+1
Currently PkgConfig takes language as a keyword parameter in position 3, while the others take it as positional in position 2. Because most dependencies don't actually set a language (they use C style linking), using a positional argument makes more sense. ExtraFrameworkDependencies is even more different, and duplicates some arguments from the base ExternalDependency class. For later changes I'm planning to make having all of the dependencies use the same signature is really, really helpful.
2020-01-08types: import typing as T (fixes #6333)Daniel Mensinger1-4/+4
2019-12-18python: add embed to the python dependency functionDaniel Mensinger1-9/+15