summaryrefslogtreecommitdiff
path: root/mesonbuild/modules/python.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix to find Python files for Windows virtualenvsMatthew Brett2021-11-151-2/+6
| | | | | | | | | Virtualenvs do not have their Python DLLs etc in the `sys.prefix` directory, but in the `sys.base_prefix` directory. This directory is the same as `sys.prefix` if not in a virtualenv, so is safe for either case: https://docs.python.org/3/library/sys.html#sys.base_prefix
* python: Better detect when install path is not in sys.pathXavier Claessens2021-11-091-9/+12
| | | | | Using pathlib ensure propre platform specific path handling, such as case sensitivity.
* python.dependency(): Do not stop when first candidate is not foundXavier Claessens2021-11-021-3/+4
| | | | | It has to lookup the dependency with required=False otherwise it raises an exception when the first candidate (pkg-config) failed.
* fix various flake8 whitespace errorsEli Schwartz2021-10-271-5/+5
|
* dep.name(): return dependency name even if dependency is not foundThomas Heijligen2021-10-261-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
* Fix typos discovered by codespellChristian Clauss2021-10-101-3/+3
|
* python: Add platlibdir and purelibdir optionsXavier Claessens2021-10-081-6/+11
|
* f-stringsEli Schwartz2021-10-041-4/+2
|
* modules: python: better handling of the Python paths for DebianFilipe Laíns2021-09-291-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>
* mintro: add installed_planFilipe Laíns2021-09-061-1/+5
| | | | Signed-off-by: Filipe Laíns <lains@riseup.net>
* python module: fix error message mentioning setuptoolsEli Schwartz2021-08-311-1/+1
| | | | We use distutils, not setuptools, for probing information.
* Add missing "disabler" kwarg to python.dependency()Xavier Claessens2021-08-301-0/+1
| | | | | There is a unit test using it and now fails because the warning about unknown kwarg became fatal.
* interpreter: fix cases of `KwargInfo(..., T, default=None)`Dylan Baker2021-08-271-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
* python module: produce the correct install path on every OSEli Schwartz2021-08-271-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.
* python: Workaround broken install pathXavier Claessens2021-08-221-3/+20
|
* python module: fix extensions without explicit subdir being installed to libdirEli Schwartz2021-08-181-4/+4
| | | | | | | | They are documented to go in site-packages, and indeed belong there. Regression from the initial implementation via commit ad296976f079cd185ab7361e3e4b18c6bf684090 Fixes #6331
* python module: make external program wrapper have access to useful metadataEli Schwartz2021-08-181-26/+35
| | | | | Basically just reorganize code. Try to make it a little neater, while we're at it.
* Fix incorrect .name attribute for python programEli Schwartz2021-08-181-3/+4
| | | | It is always set to python3 even if we asked for python2...
* fix some confusingly indirect codeEli Schwartz2021-08-181-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.
* Add install tagsXavier Claessens2021-08-171-3/+5
| | | | Fixes: #7007.
* Fix python module leaving PKG_CONFIG_LIBDIR set in os.environ.Xavier Claessens2021-08-031-4/+7
|
* modules/python: fix up a few simply typing warnings/errorsDylan Baker2021-07-131-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.
* modules/python: Allow trying a macos framework as well other methodsDylan Baker2021-07-131-2/+18
|
* modules/python: make some internal helpers protectedDylan Baker2021-07-131-4/+4
|
* modules/python: use factory for dependencyDylan Baker2021-07-131-90/+83
| | | | | This removes the odd 'pkgdep' attribute thing, and makes it behave more like a proper dependency
* modules/python: simplify a number of interfacesDylan Baker2021-07-131-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
* modules/python: use typed_pos_argsDylan Baker2021-07-131-10/+15
| | | | | And note that the way that find_installation works is completely broken in regards to machine files
* modules/python: Add type annotationsDylan Baker2021-07-131-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.
* modules/python: sort importsDylan Baker2021-07-131-8/+9
|
* holders: Fix the remaining code to respect the holder changesDaniel Mensinger2021-06-181-21/+33
|
* expose SystemDependency and BuiltinDependency as toplevel classesEli Schwartz2021-06-171-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.
* move base class for system dependencies into base.pyEli Schwartz2021-06-171-1/+1
| | | | In accordance with review comments; it's small enough this seems fitting.
* dependencies: Use the SystemDependencyDylan Baker2021-06-141-5/+3
| | | | | | | This fixes these dependencies, which currently return the name of the dependency as the type. Fixes #8877
* deps: Split dependencies.baseDaniel Mensinger2021-06-031-1/+1
| | | | | Split the Factory and dependency classes out of the base.py script to improve maintainability.
* modules: Add methods dict everywhereXavier Claessens2021-05-281-0/+3
| | | | | This fix calling random internal methods from meson.build as long as they were not prefixed by underscore.
* modules: Remove snippet methodsXavier Claessens2021-05-281-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.
* interpreter: 'embed' kwarg is only valid in python moduleXavier Claessens2021-05-081-1/+1
|
* interpreter: Split permitted_kwargs dictXavier Claessens2021-04-121-2/+2
|
* split program related classes and functions out of dependenciesDylan Baker2021-03-191-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.
* mass rewrite of string formatting to use f-strings everywhereEli Schwartz2021-03-041-19/+19
| | | | performed by running "pyupgrade --py36-plus" and committing the results
* various python neatness cleanupsEli Schwartz2021-03-041-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
* Simplify module APIXavier Claessens2021-03-041-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.
* Use a single coredata dictionary for optionsDylan Baker2021-01-041-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).
* use real pathlib moduleDylan Baker2020-11-201-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
* python.dependency() is not respecting 'required' kwargXavier Claessens2020-10-061-2/+9
|
* pathlib: Fix resolve() by overriding it in Python 3.5Daniel Mensinger2020-10-041-1/+1
|
* python: install_sources() should default to pure, following the docMarc-André Lureau2020-05-101-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>
* find_program: Fixes when the program has been overridden by executableXavier Claessens2020-04-281-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.
* Fix legacy env var support with crossJohn Ericson2020-03-231-2/+2
| | | | Fix #3969
* modules/python: Do not error out if positional args are passedNirbheek Chauhan2020-02-171-1/+5
| | | | | | Also update the documentation. Fixes https://github.com/mesonbuild/meson/issues/6470