Commit Graph

33 Commits

Author SHA1 Message Date
Eli Schwartz 479a84455f wrap: implement allow-insecure for 'meson wrap' 2022-03-27 18:57:07 -04:00
Eli Schwartz faafcc15e2 wrap: use shared function to connect to wrapdb with better errors
We currently inconsistently handle connection, `has_ssl`, and printing
errors on urlopen failure between `meson subprojects` and `meson wrap`.

Make the latter work more like the former.
2022-03-27 18:57:07 -04:00
Eli Schwartz a009eacc65
treewide: string-quote the first argument to T.cast
Using future annotations, type annotations become strings at runtime and
don't impact performance. This is not possible to do with T.cast though,
because it is a function argument instead of an annotation.

Quote the type argument everywhere in order to have the same effect as
future annotations. This also allows linters to better detect in some
cases that a given import is typing-only.
2022-03-07 19:01:04 -05:00
Eli Schwartz fc5dfb852b
wraptool: report name of wrap in status message for "not in wrapdb" 2022-02-27 18:37:15 -05:00
Eli Schwartz 769680f848
wraptool: be forgiving of local wrap files
Do not traceback when trying to update a wrap that isn't a [wrap-file],
just report the problem.

Do not traceback on perfectly valid WrapDB wraps that don't have a
patch_url because they have upstream meson.build, instead try to parse
the version from the source tarball filename.
2022-02-27 18:37:15 -05:00
Tristan Partin b361fc52dd Add typing to msubprojects.py 2021-11-28 07:10:12 -05:00
Daniel Jacobs 31bea202c9 improve wraptool search 2021-10-10 16:12:57 -04:00
Dylan Baker 4d7031437c pylint: turn on superflous-parens
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.
2021-08-31 16:28:54 -04:00
Xavier Claessens 38db4602d8 wraptool: Fix version comparison 2021-08-30 14:02:42 -04:00
Xavier Claessens 62c53b834d wrap: Port to v2 protocol
Fixes: #8754.
2021-06-04 15:35:29 -04:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Daniel Mensinger 449dd8e72a
typing: fully annotate wrap 2020-09-08 20:15:56 +02:00
Jussi Pakkanen 7375eaa263 Always disable interpolation for ini parsers. 2020-01-27 22:22:12 +02:00
Michael Brockus 4b69aea85d Update Python2 syntax to Python3 syntax in Wrap 2019-12-06 15:23:26 +02:00
Michael Hirsch, Ph.D d080917561 wrap.py: catch connection error with WrapException
fixes #6130

wrap: more error verbosity
2019-11-07 22:14:59 +02:00
Michael Hirsch, Ph.D a47c1374b9 wrap.py: apply type annotation, modernize syntax
correct syntax issues, missing imports revealed by type annotation checking
2019-11-07 22:14:59 +02:00
Daniel Mensinger 236221061a
Fixed unnecessary .items() 2019-04-29 12:23:13 +02:00
Xavier Claessens 60b58e056f Add 'meson subprojects update' command
This is inspired by gst-build's git-update script.
2018-12-02 08:37:32 -05:00
Xavier Claessens 37067a53c4 Use a single ArgumentParser for all subcommands
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.
2018-10-04 09:40:21 -04:00
Xavier Claessens 1e6d72eb5a Remove useless __main__ in files that cannot be executed 2018-08-22 15:15:54 -04:00
Daniel Pirch 6ecd31af19 wraptool: fix manual selection of wrap file to promote
Fixed manually promoting wrap files with a full path, e.g.
`meson wrap promote subprojects/s1/subprojects/projname.wrap`,
which resulted in an error before (new test added:
`./run_unittests.py AllPlatformTests.test_subproject_promotion_wrap`).

Additionally, running promote with an invalid subproject path now fails
properly. Before, it just silently did nothing (added to test:
`./run_unittests.py AllPlatformTests.test_subproject_promotion`).
2018-08-17 00:33:38 +03:00
Xavier Claessens a2ebbc7ec4 wraptool: Convert to argparse 2018-06-06 20:02:37 +00:00
Aleksey Filippov 2cf85ae16f Use os.path: basename() and dirname() instead of split()
According to Python documentation[1] dirname and basename
are defined as follows:
    os.path.dirname() = os.path.split()[0]
    os.path.basename() = os.path.split()[1]
For the purpose of better readability split() is replaced
by appropriate function if only one part of returned tuple
is used.

[1]: https://docs.python.org/3/library/os.path.html#os.path.split
2018-01-30 07:08:22 +11:00
Jussi Pakkanen 86feb843f4 Add promote to list of wrap commands. 2018-01-06 15:48:43 +02:00
Jussi Pakkanen 164fb9a150 Also promote wrap files. 2017-12-17 21:19:22 +02:00
Jussi Pakkanen 5b9d79b902 Print instructions on how to promote subsubprojects. 2017-12-17 21:19:22 +02:00
Jussi Pakkanen 46c071ea5c Add functionality to promote nested dependencies to top level. 2017-12-17 21:17:13 +02:00
Dylan Baker a8173630ea Don't use len() to test emptiness vs not emptiness
Meson has a common pattern of using 'if len(foo) == 0:' or
'if len(foo) != 0:', however, this is a common anti-pattern in python.
Instead tests for emptiness/non-emptiness should be done with a simple
'if foo:' or 'if not foo:'

Consider the following:
>>> import timeit
>>> timeit.timeit('if len([]) == 0: pass')
0.10730923599840025
>>> timeit.timeit('if not []: pass')
0.030033907998586074
>>> timeit.timeit('if len(['a', 'b', 'c', 'd']) == 0: pass')
0.1154778649979562
>>> timeit.timeit("if not ['a', 'b', 'c', 'd']: pass")
0.08259823200205574
>>> timeit.timeit('if len("") == 0: pass')
0.089759664999292
>>> timeit.timeit('if not "": pass')
0.02340641999762738
>>> timeit.timeit('if len("foo") == 0: pass')
0.08848102600313723
>>> timeit.timeit('if not "foo": pass')
0.04032287199879647

And for the one additional case of 'if len(foo.strip()) == 0', which can
be replaced with 'if not foo.isspace()'
>>> timeit.timeit('if len("   ".strip()) == 0: pass')
0.15294511600222904
>>> timeit.timeit('if "   ".isspace(): pass')
0.09413968399894657
>>> timeit.timeit('if len("   abc".strip()) == 0: pass')
0.2023209120015963
>>> timeit.timeit('if "   abc".isspace(): pass')
0.09571301700270851

In other words, it's always a win to not use len(), when you don't
actually want to check the length.
2017-05-02 21:57:26 +03:00
Mike Sinkovsky 969be1f679 cleanup: Remove redundant parentheses 2017-01-18 21:22:47 +02:00
Igor Gnatenko 9cfdd30789 remove shebang from wraptool
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/wrap/wraptool.py 644 /usr/bin/python3

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-18 16:58:02 +01:00
Elliott Sales de Andrade 4c71695e41 Use context manager for file I/O.
There are a few cases where a context manager cannot be used, such as
the logger.
2016-08-27 18:29:55 -04:00
Jussi Pakkanen 9644a928d2 Some more command line guarding. 2016-01-17 00:14:36 +02:00
Jussi Pakkanen 23b98cd6e6 Renamed meson package to mesonbuild so that we can have a script named meson in the same toplevel dir. 2016-01-16 17:35:29 +02:00