Skip to content

Commit

Permalink
Merge pull request #283 from davidhewitt/fix-multiple-artifacts
Browse files Browse the repository at this point in the history
build: fix location of multiple exec artifacts
  • Loading branch information
messense authored Aug 11, 2022
2 parents ab51558 + f245595 commit 13fa941
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased
### Fixed
- Fix regression in `get_lib_name` crashing since 1.5.0. [#280](https://github.com/PyO3/setuptools-rust/pull/280)
- Fix regression in `Binding.Exec` builds with multiple executables not finding built executables since 1.5.0. [#283](https://github.com/PyO3/setuptools-rust/pull/283)

## 1.5.0 (2022-08-09)
### Added
Expand Down
24 changes: 12 additions & 12 deletions setuptools_rust/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,10 @@ def build_extension(
dylib_paths.append(_BuiltModule(dest, artifact_path))
else:
# Find artifact from cargo messages
artifacts = tuple(
_find_cargo_artifacts(
cargo_messages.splitlines(),
package_id=package_id,
kind="cdylib",
)
artifacts = _find_cargo_artifacts(
cargo_messages.splitlines(),
package_id=package_id,
kind="cdylib",
)
if len(artifacts) == 0:
raise DistutilsExecError(
Expand Down Expand Up @@ -660,11 +658,11 @@ def _find_cargo_artifacts(
*,
package_id: str,
kind: str,
) -> Iterable[str]:
) -> List[str]:
"""Identifies cargo artifacts built for the given `package_id` from the
provided cargo_messages.
>>> list(_find_cargo_artifacts(
>>> _find_cargo_artifacts(
... [
... '{"some_irrelevant_message": []}',
... '{"reason":"compiler-artifact","package_id":"some_id","target":{"kind":["cdylib"]},"filenames":["/some/path/baz.so"]}',
Expand All @@ -673,9 +671,9 @@ def _find_cargo_artifacts(
... ],
... package_id="some_id",
... kind="cdylib",
... ))
... )
['/some/path/baz.so', '/file/two/baz.dylib']
>>> list(_find_cargo_artifacts(
>>> _find_cargo_artifacts(
... [
... '{"some_irrelevant_message": []}',
... '{"reason":"compiler-artifact","package_id":"some_id","target":{"kind":["cdylib"]},"filenames":["/some/path/baz.so"]}',
Expand All @@ -684,9 +682,10 @@ def _find_cargo_artifacts(
... ],
... package_id="some_id",
... kind="rlib",
... ))
... )
['/file/two/baz.rlib']
"""
artifacts = []
for message in cargo_messages:
# only bother parsing messages that look like a match
if "compiler-artifact" in message and package_id in message and kind in message:
Expand All @@ -700,7 +699,8 @@ def _find_cargo_artifacts(
parsed["target"]["kind"], parsed["filenames"]
):
if artifact_kind == kind:
yield filename
artifacts.append(filename)
return artifacts


def _replace_cross_target_dir(path: str, ext: RustExtension, *, quiet: bool) -> str:
Expand Down

0 comments on commit 13fa941

Please sign in to comment.