Move this message up before we attempt to change anything in the file
system (in this case creating the directory structure).
If an error occurs it will thus occur immediately after the message,
allowing us to debug what failed to install.
Github Actions supports this fine, but is misdetected by flake8/mypy.
Even though pylint defaults to text instead of colorized, we might as
well do the right thing here though.
This allows verifying that meson is type-safe under older versions of
Python, which it currently is. Different versions of Python sometimes
have different supported types for an API.
Verify this in CI.
(We flush output to ensure CI prints lines in the right order.)
And in fact *use* typing_extensions, which is sometimes the only way to
get access to TypedDict.
Mostly, reindent almost but not quite an entire file to only define
annotation classes under TYPE_CHECKING.
On average, saves 20 seconds for a job that may take 1.5 or 2 minutes.
Mostly due to recompiling the same 3 wheels again and again, so that
avoids pointless CPU waste.
The most notable problem this causes is that when running `meson setup
--reconfigure` the build.ninja file is erroneously seen as out of date,
so ninja immediately tries to regenerate it again as it didn't see the
file get updated.
There are two problems.
The first problem is that we looked for the wrong file. Ninja creates a
few internal files, and one of them is the one we care about:
`.ninja_log`, which contains stat'ed timestamps for build outputs to aid
in checking when things are out of date. But the thing we actually
checked for is `.ninja_deps`, a file that contains a compressed database
of depfile outputs. If the latter exists, then the former surely exists
too.
Checking for the wrong file meant that we would restat outputs, but only
when some build edges were previously built that had depfile outputs.
The second problem is that we checked for this in os.getcwd() instead of
the configured build directory. This very easily fails to be correct,
except when reconfigure is triggered directly by ninja itself, in which
case we didn't need the restat to begin with.
Every time I update meson, I spend about 20 minutes on frustrated googling
to figure out how to update my build directory to work with the new version.
I'm forgetful, okay? Ease this pain point by suggesting a potential fix in
the error message.
This reverts commit f52bcaa27f.
It did not pass CI, and was merged anyway because there were two CI
errors in the same cygwin job. The other error was not the fault of this
commit, and since cygwin errors were glossed over because they were
"expected", the presence of a new error *added* by this commit was
overlooked.
Per the meson development policy, PRs which result in CI errors
can/should be reverted at will, no questions asked.
In commit f52bcaa27f a few issues were
added:
- doc typo
- imports for utils.universal are not intended to be directly used, it's
an internal wrapper that exists solely to make mesonlib work well as
it always did while simultaneously allowing `meson --internal`
codepaths to avoid importing anything other than an extremely stripped
down core
- type annotation specific import was imported at runtime scope
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.
Performed using https://github.com/ilevkivskyi/com2ann
This has no actual effect on the codebase as type checkers (still)
support both and negligible effect on runtime performance since
__future__ annotations ameliorates that. Technically, the bytecode would
be bigger for non function-local annotations, of which we have many
either way.
So if it doesn't really matter, why do a large-scale refactor? Simple:
because people keep wanting to, but it's getting nickle-and-dimed. If
we're going to do this we might as well do it consistently in one shot,
using tooling that guarantees repeatability and correctness.
Repeat with:
```
com2ann mesonbuild/
```
Make them into real type annotations. These are the only ones that if
automatically rewritten, would cause flake8 to error out with the
message: "E128 continuation line under-indented for visual indent".
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.
- allow defines with leading whitespace
- always do replacement for cmakedefine
- output boolean value for cmakedefine01
- correct unittests for cmakedefine
- add cmakedefine specific unittests
clang has supported gcc syntax since version 3.3.0 from 10 years ago.
It's better than its own version because it takes a "when" verb which
allows us to explicitely ask for "auto". This is useful when overriding
flags that came from elsewhere.
Before this patch, meson was just treating b_colorout="auto" as "always".
Since CPython 3.8 .pyd files no longer look in PATH for loading libraries,
but require the DLL directory to be explicitely added via os.add_dll_directory().
This resulted in those tests failing with 3.8+ on Windows.
Add the DLL build directory with os.add_dll_directory() to fix them.
This was never noticed in CI because it only uses Python 3.7 and the
MSYS2 CPython still used the old behaviour until now.
meson tests enable PYTHONWARNDEFAULTENCODING by default and
make EncodingWarning fatal too.
Starting with Python 3.11 CPython not only warns if no encoding is passed
to open() but also to things like subprocess.check_output(). This made
the call in vsenv.py fail and in turn made test_vsenv_option fail.
check_output() here calls a .bat file which in turn calls vcvars. I don't
know what the encoding is supposed to be used there, so just be explicit
with the locale encoding to silence the warning.