aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/wrap
AgeCommit message (Collapse)AuthorFilesLines
2023-09-22Allow to fallback to cmake subprojectXavier Claessens1-14/+26
The method can be overridden by setting the `method` key in the wrap file and always defaults to 'meson'. cmake.subproject() is still needed in case specific cmake options need to be passed. This also makes it easier to extend to other methods in the future e.g. cargo.
2023-09-14Wrap: Use git instead of patch by defaultXavier Claessens1-6/+8
This solves problems with Strawberry Perl providing patch.exe on Windows with an unconsistent line ending support. Fixes: #12092
2023-09-05wrap: Use MESON_PACKAGE_CACHE_DIR as default packagecache pathXavier Claessens1-2/+12
Allow packagecache to contain already extracted directory to match what some distro does with Cargo source packages in /usr/share/cargo/registry. Note that there is no need to lock the cache directory because we download into a temporary name and atomically rename afterward. It means we could be downloading the same file twice, but at least integrity is guaranteed. Fixes: #12211
2023-09-05wrap: Remove duplicated codeXavier Claessens1-12/+6
2023-08-11treewide: automatic rewriting of all comment-style type annotationsEli Schwartz1-9/+9
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/ ```
2023-07-10wrap: detect network timeouts 20x fasterEli Schwartz1-1/+1
When downloading wrap content, we need to know at some point if the server is going to respond with "hello, yes, I'm here and I have data for you". The alternative is to sometimes infinitely hang. In commit 8f7781f1d6bf36c064b39e7d0794c686f1b78665 we added such a timeout, but using an extremely generously high number -- ten minutes. We don't need to wait this long just to find out if the other end exists, so decrease that time to 30 seconds, whch is still ludicrously generous but not quite as much so.
2023-05-25ProgressBar: Fix some rendering issuesXavier Claessens1-1/+3
- Do not hardcode terminal width of 100 chars, that breaks rendering on smaller terminal. It already uses current console width by default. - Disable progress bar when downloading from msubprojects because it fetches multiple wraps in parallel. - Scale unit when downloading e.g. MB/s. - Do not display rate when it's not a download. - Do not display time elapsed to simplify the rendering.
2023-05-20wrap: Check for common "provides" typoXavier Claessens1-0/+2
It is a common mistake that is hard to find because Meson silently ignore unknown sections. Better have an explicit error message.
2023-04-29wrap: Always pass posix paths to patchNirbheek Chauhan1-1/+2
patch on Windows is provided by MSYS, which only understands POSIX paths, with `/`. Using Windows paths with `\` results in a "file not found" error. We got a little lucky here because the path is relative, so the drive letter difference doesn't affect us.
2023-03-27Write wrap-redirect filename as posix pathDenis Fortin1-4/+4
2023-02-13wrap: ensure the tempfile used for downloading is closedEli Schwartz1-1/+1
This is generally a good idea, and the tempfile is already instructed to not auto-delete on close. It also fixes a bug on PyPy, where the file isn't valid because it's not explicitly closed. This is probably due to the garbage collection modes -- in CPython, the object goes out of scope and gets automatically closed before we actually attempt to unpack it. Fixes #11246
2023-02-01treewide: add future annotations importEli Schwartz2-0/+2
2023-01-03wrap: use log once instead of hand rollingDylan Baker1-5/+1
2022-12-07wrap: Don't use --branch with shallow clones against HEADL. E. Segovia1-2/+5
Fixes #10931
2022-11-30pylint: enable the set_membership pluginDylan Baker1-1/+1
Which adds the `use-set-for-membership` check. It's generally faster in python to use a set with the `in` keyword, because it's a hash check instead of a linear walk, this is especially true with strings, where it's actually O(n^2), one loop over the container, and an inner loop of the strings (as string comparison works by checking that `a[n] == b[n]`, in a loop). Also, I'm tired of complaining about this in reviews, let the tools do it for me :)
2022-10-11Make `meson wrap update` command update all wraps in parallelXavier Claessens1-6/+3
This moves the implementation into msubprojects because it has all the infrastructure to update wraps in parallel while keeping "meson wrap" UX.
2022-10-10Move some code from wraptool.py to wrap.pyXavier Claessens2-34/+32
2022-10-10wrap: Ignore directories that have a .wrap with the same nameXavier Claessens1-3/+3
If we update e.g. glib.wrap from wrap-git with directory=glib to wrap-file with directory=glib-2.70 we could still have the glib directory that is not referenced by any .wrap file any more. We should still ignore that directory otherwise it overrides the glib.wrap we parsed.
2022-10-09Get wrap from wrapdb when not found locallyXavier Claessens1-13/+55
Download wrap file from wrapdb automatically when it is not found locally but we have it in wrapdb.json. This makes for example `dependency('glib-2.0')` work out of the box simply by running `meson wrap update-db`, even if the project does not provide any wraps.
2022-10-09Add "meson wrap update-db" commandXavier Claessens1-2/+18
It downloads releases.json from wrapdb and store it in subprojects/wrapdb.json. That file will be used by Meson to find dependency fallbacks offline.
2022-09-28wrap: If the directory exists in a sub-subproject, uses it inplaceXavier Claessens1-4/+7
A subproject could have a sub-subproject as a git submodule, or part of the subproject's release tarball, and still have a wrap file for it (e.g. needed for [provide] section). In that case we need to use the source tree for the sub-subproject inplace instead of downloading a new copy into the main project. This is the case with GLib 2.74, it has a subproject "gvdb" as git submodule, and part of release tarball, it ships gvdb.wrap file as well.
2022-09-28wrap: Small simplificationXavier Claessens1-11/+8
2022-09-28wrap: Set self.directory only onceXavier Claessens1-2/+1
It can wait until after parsing the wrap file to set it.
2022-09-22pylint: enable global-statementDylan Baker1-1/+1
This does force a number of uses of `# pylint: disable` comments, but it also finds a couple of useless global uses and one place (in the previous commit) that an easy refactor removes the use of global. Global is a code smell, so forcing adding a comment to disable helps force developers to really consider if what they're doing is a good idea.
2022-09-18Warn if wrap file changesDaniel Carson1-1/+37
Save off the hash of the wrap file when first configuring a subproject. When reconfiguring a subproject, check the hash of the wrap file against the stored hash. If they don't match then warn the user.
2022-09-18Move up dangling commentDaniel Carson1-1/+1
The comment and some settings that appear to be related to the comment were introduced in f21685a83330a4bbe1e59c3641a0d24f1efe8825 and appears to be documenting some of the fields added in that commit. This commit moves the comment back to the field it appears to be documenting.
2022-09-07wrap: correctly override dependency names with capital lettersEli Schwartz1-3/+5
When we do wrap resolution, we do a case-insensitive lookup because keys, i.e. `dep_name = variable_name`, are case insensitive. In order to check whether we should process a subproject, we need to know if the lowercased dependency name matches. We do this by looking up the lowercase name, and assuming that the stored name is also lowercase. But for dependency_names, this isn't "case insensitive and stored in lowercase" so we need to manually force it to be consistent. Likewise, when looking up the wrap name (which works like dependency_names and doesn't need a provide section at all) the disk filename of the wrap file is case sensitive, but needs to be manually forced for consistency.
2022-08-29flake8: fix unnecessary f-strings without any format placeholdersEli Schwartz1-2/+2
These can just be ordinary strings.
2022-08-25wrap: Support netrc filesFabian Orccon1-1/+37
2022-07-16wrap: Fix diff_files not finding the patch to applyNirbheek Chauhan1-2/+3
When `self.wrap.filesdir` is a relative path, which happens when `meson subprojects update` is run, the path to the patch must be provided relative to the working directory in which `patch` or `git` is run. `self.wrap.filesdir` is absolute when `Resolve()` is invoked by the Meson interpreter, which is why this wasn't detected by the tests.
2022-06-13flake8: don't use f-strings for strings without formattingEli Schwartz1-1/+1
2022-06-07wrap: Add support for applying a list of patch filesPaweł Marczewski1-1/+36
Co-authored-by: Xavier Claessens <xavier.claessens@collabora.com>
2022-04-30Ignore detached head warning while cloning subprojects with tagszxey1-1/+1
2022-03-27wrap: implement allow-insecure for 'meson wrap'Eli Schwartz1-14/+27
2022-03-27wrap: use shared function to connect to wrapdb with better errorsEli Schwartz1-5/+4
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-27wrap: add functionality to specify whether insecure downloads should be usedEli Schwartz1-9/+26
We have a fallback route in `meson subprojects download` and friends, which tries to retrieve wrapdb urls via http, if Python was not built with SSL support. Stop doing this. Replace it with a command line option to specify that insecure downloads are wanted, and reference it in the error message if downloading fails due to SSL issues.
2022-03-07treewide: string-quote the first argument to T.castEli Schwartz1-1/+1
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-01fix missing encodingsEli Schwartz1-1/+1
These were caught by the testsuite erroring out with a fatal EncodingWarning due to the previous commit. Fixes #9996
2022-02-27wraptool: report name of wrap in status message for "not in wrapdb"Eli Schwartz1-1/+1
2022-02-27wraptool: be forgiving of local wrap filesEli Schwartz1-9/+22
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-16flake8: do not use bare exceptionsEli Schwartz1-1/+1
In one case, we actually specifically want to catch IndexError only. In the other case, excepting Exception rather than BaseException is quite fine.
2022-02-14FeatureNew: add mypy type annotations for subproject argEli Schwartz1-1/+2
Use a derived type when passing `subproject` around, so that mypy knows it's actually a SubProject, not a str. This means that passing anything other than a handle to the interpreter state's subproject attribute becomes a type violation, specifically when the order of the *four* different str arguments is typoed.
2022-01-27Checkout subproject submodules even when nestedWill Toohey1-3/+8
2022-01-18wraps: implement exponential backoff for downloading filesEli Schwartz1-1/+12
Implementation modeled after mesonlib.windows_proof_rmtree(). Implements the other half of #9688
2022-01-18wraps: on failure to apply a patch, delete the subproject directoryEli Schwartz1-2/+6
This code path is only called on initial download of a subproject, but if we raise an error and abort while downloading/applying a patch overlay we still have the upstream sources extracted... which appears to be a subproject, then turns out to be broken due to missing meson.build Partially implements #9688
2022-01-10first pass at migrating to dataclassesEli Schwartz1-6/+9
In some cases, init variables that accept None as a sentinel and immediately overwrite with [], are migrated to dataclass field factories. \o/ Note: dataclasses by default cannot provide eq methods, as they then become unhashable. In the future we may wish to opt into declaring them frozen, instead/additionally.
2021-11-30Fix typo in wrap.pyRandy1-1/+1
2021-11-28Add typing to msubprojects.pyTristan Partin1-2/+2
2021-11-02wrap: Fix concurrent os.mkdir()Xavier Claessens1-2/+1
Since 0.59.0 Meson downloads multiple wraps in parallel, so the packagecache directory could be created by one then the 2nd would hit error when calling os.mkdir() because it already exists.
2021-10-27wrap: fix support for git < 2.28Eli Schwartz1-1/+1
both of these do the same thing: init -b <branchname> -c init.defaultBranch=<branchname> init The latter contributes to unreadably long lines of code, but has the advantage of working on older versions of git. Fixes #9449