msys/python in MSYS2 pretends to be cygwin in all cases for some time
now, so this check was impossible to hit.
The underlying confusion it tried to prevent is still there, namely trying
to build with mingw but wrongly using a msys/cygwin python/meson.
We can use the MSYSTEM env var to detect if we are in a mingw shell, and
in case the Python doesn't match we suggest installing mingw variants of both
python and meson.
Using msys/python + meson in a MSYS environment works fine on the other hand,
so no need to error out in that case.
Fixes#8726
Also addresses the concern raised in
https://github.com/mesonbuild/meson/issues/3653#issuecomment-474122564
argparse is the gift that keeps on giving, hahaha. Suppress the script
argument when --version is specified to avoid "required argument not
provided" errors, and print the python version.
The version argument is required in order to make this baseline
functional as a resolved python for find_program, which may specify a
version and expect this to work with python itself. Our incomplete CLI
wrapper over the python CLI interface was missing this.
Fixes#10162
This reverts commit e257a870fe.
The PR adding this command had infinitely hanging CI, and now that it is
merged to master we cannot get any CI on any PR to succeed.
Unfortunately, checking for strings without context is exceedingly prone
to false positives, while missing anything that indirectly opens a file.
Python 3.10 has a feature to warn about this though -- and it uses a
runtime check which runs at the same time that the code fails to open
files in the broken Windows locale. Set this up automatically when
running the testsuite.
Sadly, Python's builtin feature to change the warning level, e.g. by
setting EncodingWarning to error at startup, is utterly broken if you
want to limit it to only certain modules. This is tracked in order to be
more efficiently ignored at https://bugs.python.org/issue34624 and
https://github.com/python/cpython/pull/9358
It is also very trigger happy and passing stuff around via environment
variable either messes with the testsuite, or with thirdparty programs
which are implemented in python *such as lots of gnome*, or perhaps
both.
Instead, add runtime code to meson itself, to add a hidden "feature".
In the application source code, running the 'warnings' module, you can
actually get the expected behavior that $PYTHONWARNINGS doesn't have. So
check for a magic testsuite variable every time meson starts up, and if
it does, then go ahead and initialize a warnings filter that makes
EncodingWarning fatal, but *only* when triggered via Meson and not
arbitrary subprocess scripts.
Do not report a MesonBugException if the command is `runpython`, because
that is 100% other people's code, not ours. It's only used as an
alternative to sys.executable for reporting a path to python, in the
event of a Windows MSI install.
While we are at it, refactor the logic for PermissionError to be a bit
more unified (and sadly use isinstance instead of except, but it is what
it is).
It's not a MesonBug which needs to be reported, and the existing error
already adequately points out the problematic file.
It is impossible to get a PermissionError for files created by meson
itself, once the build directory has been created, anyway.
The interpreter tries to catch any exception and add the latest node
information to it, but currently we only used that to print better
formatted error messages on MesonException.
Since we should theoretically have that property for most/all
exceptions, let's percolate that upward, and message the user that an
unexpected traceback was encountered, that it should be reported as a
bug, and the helpful information of "how far into parsing this
meson.build did we get before erroring out, anyway?"
We have a lot of these. Some of them are harmless, if unidiomatic, such
as `if (condition)`, others are potentially dangerous `assert(...)`, as
`assert(condtion)` works as expected, but `assert(condition, message)`
will result in an assertion that never triggers, as what you're actually
asserting is `bool(tuple[2])`, which will always be true.
" bat_info = json.loads(bat_json) " may produce error
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 ...
Because the vswhere.exe's output is not utf-8 by default
Use UTF-8 encoding for vswhere.exe can fixing it .
This will be printed in bold at the end of interactive meson
sub-commands that won't be parsed by a program. Specifically: setup,
compile, test, and install.
NOTICE: You are using [...]
D lang compilers have an option -release (or similar) which turns off
asserts, contracts, and other runtime type checking. This patch wires
that up to the b_ndebug flag.
Fixes#7082
This isn't safe given the way python implements default arguments.
Basically python store a reference to the instance it was passed, and
then if that argument is not provided it uses the default. That means
that two calls to the same function get the same instance, if one of
them mutates that instance every subsequent call that gets the default
will receive the mutated instance. The idiom to this in python is to use
None and replace the None,
def in(value: str, container: Optional[List[str]]) -> boolean:
return src in (container or [])
if there is no chance of mutation it's less code to use or and take
advantage of None being falsy. If you may want to mutate the value
passed in you need a ternary (this example is stupid):
def add(value: str, container: Optional[List[str]]) -> None:
container = container if container is not None else []
container.append(value)
I've used or everywhere I'm sure that the value will not be mutated by
the function and erred toward caution by using ternaries for the rest.
Otherwise Python gets all confused and it makes testing difficult.
Also minimally emulate the behaviour of the normal object to make the rest
of the code happy.
This adds a hidden option to dump the current otherwise hidden peristant
state in coredata.dat.
This interface is unstable as meson has no compatibility promises about
coredata.dat.
This has the adventage that "meson --help" shows a list of all commands,
making them discoverable. This also reduce the manual parsing of
arguments to the strict minimum needed for backward compatibility.