Skip to content

Commit 56d73cc

Browse files
committed
wrap: warn on deprecated wraps
mesonbuild/wrapdb#2529 adds a mechanism for marking wraps as deprecated in releases.json. If a wrap is deprecated, hide it from `meson wrap list` and `meson wrap search` output, warn if it's passed to `meson wrap install` or `meson wrap info`, warn if it's present during `meson wrap status` or `meson wrap update`, and warn if it's automatically installed from `wrapdb.json`. Omit deprecated wraps from the wrap list on the website.
1 parent 054fd1e commit 56d73cc

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

mesonbuild/msubprojects.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
from .ast import IntrospectionInterpreter
1919
from .mesonlib import quiet_git, GitException, Popen_safe, MesonException, windows_proof_rmtree
2020
from .wrap.wrap import (Resolver, WrapException, ALL_TYPES,
21-
parse_patch_url, update_wrap_file, get_releases)
21+
parse_patch_url, update_wrap_file, get_releases,
22+
warn_if_deprecated)
2223

2324
if T.TYPE_CHECKING:
2425
from typing_extensions import Protocol
@@ -154,6 +155,7 @@ def update_wrapdb(self) -> bool:
154155
if not info:
155156
self.log(' -> Wrap not found in wrapdb')
156157
return True
158+
warn_if_deprecated(self.wrap.name, info)
157159

158160
# Determine current version
159161
try:

mesonbuild/wrap/wrap.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@ def get_releases(allow_insecure: bool) -> T.Dict[str, T.Any]:
164164
data = get_releases_data(allow_insecure)
165165
return T.cast('T.Dict[str, T.Any]', json.loads(data.decode()))
166166

167+
def warn_if_deprecated(name: str, info: T.Dict[str, T.Any]) -> None:
168+
deprecated = info.get('deprecated')
169+
if deprecated is None:
170+
return
171+
replacement = deprecated.get('replacement')
172+
reason = deprecated.get('reason')
173+
if replacement:
174+
mlog.warning(f'Wrap {name} is deprecated: use {replacement} instead')
175+
elif reason:
176+
mlog.warning(f'Wrap {name} is deprecated: {reason}')
177+
else:
178+
mlog.warning(f'Wrap {name} is deprecated')
179+
167180
def update_wrap_file(wrapfile: str, name: str, new_version: str, new_revision: str, allow_insecure: bool) -> None:
168181
url = open_wrapdburl(f'https://wrapdb.mesonbuild.com/v2/{name}_{new_version}-{new_revision}/{name}.wrap',
169182
allow_insecure, True, True)
@@ -447,6 +460,7 @@ def get_from_wrapdb(self, subp_name: str) -> T.Optional[PackageDefinition]:
447460
info = self.wrapdb.get(subp_name)
448461
if not info:
449462
return None
463+
warn_if_deprecated(subp_name, info)
450464
self.check_can_download()
451465
latest_version = info['versions'][0]
452466
version, revision = latest_version.rsplit('-', 1)

mesonbuild/wrap/wraptool.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from glob import glob
1212
from .wrap import (open_wrapdburl, read_and_decompress, WrapException, get_releases,
13-
get_releases_data, parse_patch_url)
13+
get_releases_data, parse_patch_url, warn_if_deprecated)
1414
from .. import mesonlib, msubprojects
1515

1616
if T.TYPE_CHECKING:
@@ -65,12 +65,15 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None:
6565
def list_projects(options: 'argparse.Namespace') -> None:
6666
releases = get_releases(options.allow_insecure)
6767
for p in releases.keys():
68-
print(p)
68+
if 'deprecated' not in releases[p]:
69+
print(p)
6970

7071
def search(options: 'argparse.Namespace') -> None:
7172
name = options.name
7273
releases = get_releases(options.allow_insecure)
7374
for p, info in releases.items():
75+
if 'deprecated' in releases[p]:
76+
continue
7477
if p.find(name) != -1:
7578
print(p)
7679
else:
@@ -83,6 +86,7 @@ def get_latest_version(name: str, allow_insecure: bool) -> T.Tuple[str, str]:
8386
info = releases.get(name)
8487
if not info:
8588
raise WrapException(f'Wrap {name} not found in wrapdb')
89+
warn_if_deprecated(name, info)
8690
latest_version = info['versions'][0]
8791
version, revision = latest_version.rsplit('-', 1)
8892
return version, revision
@@ -129,6 +133,7 @@ def info(options: 'argparse.Namespace') -> None:
129133
info = releases.get(name)
130134
if not info:
131135
raise WrapException(f'Wrap {name} not found in wrapdb')
136+
warn_if_deprecated(name, info)
132137
print(f'Available versions of {name}:')
133138
for v in info['versions']:
134139
print(' ', v)

tools/regenerate_docs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ def generate_wrapdb_table(output_dir: Path) -> None:
128128
f.write('| Project | Versions | Provided dependencies | Provided programs |\n')
129129
f.write('| ------- | -------- | --------------------- | ----------------- |\n')
130130
for name, info in releases.items():
131+
if 'deprecated' in info:
132+
continue
131133
versions = []
132134
added_tags = set()
133135
for v in info['versions']:

0 commit comments

Comments
 (0)