File: all-workspace-members

package info (click to toggle)
rust-rustls 0.23.35%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,460 kB
  • sloc: sh: 199; python: 181; makefile: 11
file content (38 lines) | stat: -rwxr-xr-x 982 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3

"""
Usage: admin/all-workspace-members

Prints the set of all workspace members by package name, suitable
for passing to cargo with the `-p`/`--package` option.

"Workspace members" are computed by cargo, and included as
the `workspace_members` item returned from `cargo metadata`.
See
<https://doc.rust-lang.org/cargo/reference/workspaces.html#the-members-and-exclude-fields>
for documentation on what makes a package a workspace member
or not.
"""

import subprocess
import argparse
import json


def workspace_packages():
    js = json.loads(
        subprocess.check_output(
            ["cargo", "metadata", "--no-deps", "--format-version=1"]
        )
    )
    members = js["workspace_members"]
    packages = [p for p in js["packages"] if p["id"] in members]
    return packages


if __name__ == "__main__":
    ap = argparse.ArgumentParser(description=__doc__)
    opts = ap.parse_args()

    for p in workspace_packages():
        print(p["name"])