Commit Graph

44 Commits

Author SHA1 Message Date
Jussi Pakkanen 5b422fce87 Make Python 2 tests optional(er) to prepare for py2 purge in Debian. 2019-10-01 21:12:04 +03:00
Ross Burton ad368cfc07 modules/python: improve log when probing Python binary
If the Python binary that we find doesn't return valid JSON when asked to run a
small script, show the command being ran and stdout/stderr in meson-log.txt.

Fixes: #5914
2019-09-12 15:09:40 +03:00
Jussi Pakkanen af1a81fffc Improve error message when Python is not usable. [skip ci] 2019-06-27 20:45:58 +03:00
Dylan Baker 15ab1f64f9 modules/python: add a modules keyword argument
This mirrors the modules keyword argument that some dependencies (such
as qt and llvm) take. This allows an easier method to determine if
modules are installed.
2019-06-12 14:13:20 +03:00
John Ericson 07777e15d4 Purge `is_cross` and friends without changing user interfaces
In most cases instead pass `for_machine`, the name of the relevant
machines (what compilers target, what targets run on, etc). This allows
us to use the cross code path in the native case, deduplicating the
code.

As one can see, environment got bigger as more information is kept
structured there, while ninjabackend got a smaller. Overall a few amount
of lines were added, but the hope is what's added is a lot simpler than
what's removed.
2019-06-09 13:13:25 -04:00
Daniel Mensinger e75211d321
Fix builtin variable names 2019-04-29 12:17:40 +02:00
Jussi Pakkanen 4e4f97edb3 Can run argument strings with internal Python. Closes #5217. 2019-04-21 15:14:34 +03:00
Dylan Baker a710b83a67 modules/python: normalize output for disabled by feature
Instead of printing a message about how python was skipped, print the
normal 'Program foo found:' message, with a "disabled by feature"
message added.
2019-04-03 14:48:29 -07:00
Dylan Baker de48e887b8 modules/python: Do disabler check after validating inputs
This will help developers not introduce bugs (say putting 3 instead of
"python3"), and will be useful for the next patch.
2019-04-03 14:48:29 -07:00
Dylan Baker 82346a2bd2 modules/python: Report program found in find_installation()
Currently find_installation is silent, which is pretty annoying. Let's
log it.
2019-04-03 14:48:29 -07:00
Dylan Baker 3d04e5a150 modules/python: Remove spaces around keyword arguments
just small style cleanups.
2019-04-02 15:34:55 -07:00
Nacho García 222a973918 dependencies: fix Python linking for windows+mingw
For dynamic linking, some mingw releases don't link
correctly with pythonXX.lib in all cases.
This patch forces mingw to link against
pyhthonXX.dll instead of the .lib file, which has
a better compatiblity.

Note that msys 1.0 old platform is detected
as windows instead of 'mingw'
2019-03-18 09:51:31 +00:00
Christoph Reiter 1bd14b52b2 python: don't require a Python lib in case we don't link against it. Fixes #4841
In case extensions aren't linked against libpython we can't assume one exists at
all or is available in a known directory.
2019-02-04 20:27:26 +01:00
Xavier Claessens 83766b3687 Fix flake8 errors 2019-01-16 11:16:46 -05:00
John Ericson 2b22576fb6 Remove cross_info; cross file is parsed up front and discarded 2019-01-02 16:22:47 -05:00
guruDanny67 ee555e37c9 Avoid exception looking for python on windows if the launcher (py.exe) is not installed 2019-01-02 22:18:11 +02:00
Dylan Baker f6405adc2d modules/python: Add path method
This would normally be exposed by the ExternalProgramHolder, but wasn't
due to the implementation of the PythonInstallation module. Because of
that I've duplicated the method so that we can add the FeatureNew
decorator.

Fixes #4070
2018-12-12 12:23:37 -08:00
Dylan Baker d536a6f018 modules/python: Refactor the PythonInstallation object
Into a generic interpreter object. This isn't a module, it's an object
returned by a module, it also happens to be a special case of an
ExternalProgram, which is a normal interpreter object. Let's treat it
like one.
2018-12-12 12:23:37 -08:00
Dylan Baker 3d322b3381 modules/python: don't inherit from InterpreterObject
Because ExternalProjectHolder already does
2018-12-12 12:23:37 -08:00
Dylan Baker 03805287e5 modules/python: Don't pass instance variable to instance method 2018-12-12 12:23:37 -08:00
Christoph Reiter 8e85a7b7b8 python: only link extension modules against libpython when distutils does too. Fixes #4117
Windows requires things to be linked, on macOS distutils doesn't link by default.
On Linux etc. things are not so clear, some distros like Debian patch distutils to not link,
some don't. In addition the manylinux wheels spec prohibits linking against libpython
and upstream is thinking about changing the default:
https://bugs.python.org/issue34814

Call into distutils to figure out what distutils does and in case it doesn't link
against libpython replace the passed in Python dependency with a partial one.
2018-12-10 20:25:33 +02:00
Philippe Normand 4db1b3a09f modules/python: Do not override link_args with None largs
None is not iterable so it would trigger a TypeError later when link_args are
passed on to CompilerArgs.extend_direct().
2018-12-05 22:18:53 +02:00
Dylan Baker 71a5f990d0 modules/python: Allow use of the native file
Currently this just allows setting a "python" variable that always
overrides, probably we want to have the option for "python2" and
"python3" as well.
2018-11-14 15:57:37 -08:00
Xavier Claessens 61348da069 Add 'disabler' argument to functions returning not-found objects
When dependency(), find_library(), find_program(), or
python.find_installation() return a not-found object and disabler is
true, they return a Disabler object instead.
2018-10-23 22:09:55 +03:00
Xavier Claessens 4ff7b65f9b python module: Only run command once to get all info 2018-09-18 08:50:49 -04:00
Xavier Claessens 6112e6a815 Fix version check when passing feature option to find_installation() 2018-09-17 11:37:14 -04:00
Xavier Claessens 3cf03ec6d6 find_installation: Add support for feature option in required kwarg
Closes: #4165.
2018-09-16 15:07:43 +03:00
David Seifert ab01db177b Make python module more robust
* Lookup is now performed according to the following order:
  1. use `pkg-config` with `PKG_CONFIG_LIBDIR=LIBPC` from python
  2. use plain `PKG_CONFIG_{LIBDIR,PATH}` from the environment
  3. try to extract the information from SYSCONFIG

The second step is necessary for relocated python installations
and cross compilation scenarios, where the value of `LIBPC` might
be wrong.
2018-08-09 06:27:53 -07:00
Christoph Reiter 6b9fdfe67b python.find_installation: only try to find python with the py launcher if it isn't in PATH
Meson tries to find the interpreter path through the "py" launcher on Windows in all
cases which breaks if meson is run under MSYS2 and an official CPython is installed as well.
MSYS2 Python doesn't install a py launcher which results in meson finding the system one instead
even though python2/python3 is in PATH.

Always check if the interpreter name is in PATH before falling back to checking the py launcher.
2018-07-27 18:10:13 +03:00
Nirbheek Chauhan 907a68bcf1 FeatureNew: Fix method names for some feature checks 2018-07-02 07:05:08 +00:00
Nirbheek Chauhan 817dcaa23b Remove permittedSnippetKwargs, snippets are not special
All we needed to do was change _get_callee_args() to also support
snippets.
2018-07-02 07:05:08 +00:00
Nirbheek Chauhan d737488150 dependencies: Don't assume self.compiler is a C compiler
All dependencies were using find_library, has_header, get_define, etc on
self.compiler assuming that it's a compiler that outputs and consumes
C-like libraries. This is not true for D (and in the future, for Rust)
since although they can consume C libraries, they do not use the
C ecosystem.

For such purposes, we now have self.clib_compiler. Nothing uses
self.compiler anymore as a result, and it has been removed.
2018-06-20 11:27:08 +00:00
Salamandar 2fb6018763 Add 0.46.0 features 2018-06-01 14:23:24 +02:00
Mathieu Duponchelle f1c92d7c9c Interpreter: don't flatten the arguments of various methods
this fixes eg set_variable('foo', ['bar', 'baz']), which
was previously erroring out complaining about the number
of arguments.

Closes #1481
2018-05-04 15:24:21 +00:00
Mathieu Duponchelle 8bda86faab python module: make it work with pypy
pypy installations don't usuallyy ship with pkg-config files,
we thus need to replicate what their version of distutils does.

In addition, we also try our best to build against other
pythons that do not have pkg-config files.
2018-05-03 18:50:40 +05:30
Havard Graff 14db3861d8 modules/python: add some more options around path and config_vars
What is actually defined here varies wildly on different python-versions
for different platforms.
On my python2.7 on Windows len(sysconfig.get_config_vars()) returns 17,
whereas in my Ubuntu that number is 517!

Hence it is useful to be able to check which keys are available, as
well as allowing specifying a default option.
2018-04-21 19:50:53 +02:00
Jussi Pakkanen 9790f2d500 Made Python module match the new init interface. 2018-04-18 00:20:52 +03:00
Mathieu Duponchelle c3bc7873e9 [fixup]: various minor tweaks found while documenting 2018-04-09 15:46:06 +02:00
Mathieu Duponchelle 33abe0cf55 [fixup]: Rename find to find_installation 2018-04-09 15:43:25 +02:00
Mathieu Duponchelle dce770c0a7 [fixup]: Fix python2 detection and unit test 2018-04-09 02:06:22 +02:00
Mathieu Duponchelle 5b13742ff4 [fixup]: trivial fix after rebase 2018-04-07 00:37:28 +02:00
Mathieu Duponchelle ad296976f0 [fixup]: extension_module: allow specifying install_dir OR subdir 2018-04-07 00:37:28 +02:00
Mathieu Duponchelle 423f2f5c92 [fixup]: Address PKG_CONFIG env vars comments 2018-04-07 00:37:28 +02:00
Mathieu Duponchelle e1b138a21b Implement a generic python module
With contributions from Håvard Graff
2018-04-06 22:43:35 +02:00