Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix finding cargo artifacts when filenames are empty #521

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions setuptools_rust/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,15 @@ def _find_cargo_artifacts(
... kinds={"rlib"},
... )
['/file/two/baz.rlib']
>>> _find_cargo_artifacts(
... [
... '{"some_irrelevant_message": []}',
... '{"reason": "compiler-artifact", "package_id": "some_id", "target": {"kind": ["bin"]}, "filenames":[], "executable": "/target/debug/some_exe"}'
... ],
... package_id="some_id",
... kinds={"bin"},
... )
['/target/debug/some_exe']
"""
artifacts = []
for message in cargo_messages:
Expand All @@ -769,9 +778,12 @@ def _find_cargo_artifacts(
parsed.get("reason") == "compiler-artifact"
and parsed.get("package_id") == package_id
):
for artifact_kind, filename in zip(
parsed["target"]["kind"], parsed["filenames"]
):
filenames = parsed["filenames"]
if not filenames and parsed.get("executable"):
# Use parsed["executable"] as the filename when filenames are empty
# See https://github.com/PyO3/maturin/issues/2370
filenames = [parsed["executable"]]
for artifact_kind, filename in zip(parsed["target"]["kind"], filenames):
if artifact_kind in kinds:
artifacts.append(filename)
return artifacts
Expand Down
Loading