R7.7: crates.py lists what cargo links on this target
The walk over cargo metadata ignored an edge's target, so lopdf (Linux only, a test dependency elsewhere) counted on Windows. Linux needs the BSD-3-Clause text for alloc-stdlib, which ships no licence file. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
3846041f17
commit
a1b8c18ffd
2 files changed
+33
-14
No files matched your search
+9
-14
@@ -10,26 +10,21 @@ root = pathlib.Path(__file__).resolve().parent.parent
|
|||||||
standard = root / "packaging" / "licenses"
|
standard = root / "packaging" / "licenses"
|
||||||
host = next(line.split()[1] for line in subprocess.run(
|
host = next(line.split()[1] for line in subprocess.run(
|
||||||
["rustc", "-vV"], check=True, capture_output=True, text=True).stdout.splitlines() if line.startswith("host:"))
|
["rustc", "-vV"], check=True, capture_output=True, text=True).stdout.splitlines() if line.startswith("host:"))
|
||||||
# Only what this machine's build links.
|
|
||||||
meta = json.loads(subprocess.run(
|
meta = json.loads(subprocess.run(
|
||||||
["cargo", "metadata", "--format-version", "1", "--locked", "--filter-platform", host,
|
["cargo", "metadata", "--format-version", "1", "--locked",
|
||||||
"--manifest-path", str(root / "Cargo.toml")],
|
"--manifest-path", str(root / "Cargo.toml")],
|
||||||
check=True, capture_output=True, text=True).stdout)
|
check=True, capture_output=True, text=True).stdout)
|
||||||
by_id = {package["id"]: package for package in meta["packages"]}
|
by_id = {package["id"]: package for package in meta["packages"]}
|
||||||
own = set(meta["workspace_members"])
|
own = set(meta["workspace_members"])
|
||||||
nodes = {node["id"]: node for node in meta["resolve"]["nodes"]}
|
if len([pid for pid in own if by_id[pid]["name"] in sys.argv[1:]]) != len(sys.argv) - 1:
|
||||||
# What links in: normal edges, for this machine's target.
|
|
||||||
wanted, stack = set(), [pid for pid in own if by_id[pid]["name"] in sys.argv[1:]]
|
|
||||||
if len(stack) != len(sys.argv) - 1:
|
|
||||||
sys.exit(f"crates.py: unknown package among {sys.argv[1:]}")
|
sys.exit(f"crates.py: unknown package among {sys.argv[1:]}")
|
||||||
while stack:
|
# Cargo decides which normal edges link on this target.
|
||||||
pid = stack.pop()
|
tree = subprocess.run(
|
||||||
if pid in wanted:
|
["cargo", "tree", "--locked", "-e", "normal", "--target", host, "--prefix", "none", "-f", "{p}",
|
||||||
continue
|
"--manifest-path", str(root / "Cargo.toml"), *[arg for name in sys.argv[1:] for arg in ("-p", name)]],
|
||||||
wanted.add(pid)
|
check=True, capture_output=True, text=True).stdout
|
||||||
for dep in nodes[pid]["deps"]:
|
linked = {tuple(line.split()[:2]) for line in tree.splitlines() if line.strip()}
|
||||||
if any(kind["kind"] is None for kind in dep["dep_kinds"]):
|
wanted = {pid for pid, package in by_id.items() if (package["name"], "v" + package["version"]) in linked}
|
||||||
stack.append(dep["pkg"])
|
|
||||||
|
|
||||||
out, missing = [], []
|
out, missing = [], []
|
||||||
for pid in sorted(wanted - own, key=lambda pid: (by_id[pid]["name"], by_id[pid]["version"])):
|
for pid in sorted(wanted - own, key=lambda pid: (by_id[pid]["name"], by_id[pid]["version"])):
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of the copyright holder nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
Reference in new issue
Block a user