@@ -249,7 +249,7 @@ def build_extension(
249
249
artifacts = _find_cargo_artifacts (
250
250
cargo_messages .splitlines (),
251
251
package_id = package_id ,
252
- kind = "bin" ,
252
+ kinds = { "bin" } ,
253
253
)
254
254
for name , dest in ext .target .items ():
255
255
if not name :
@@ -277,15 +277,15 @@ def build_extension(
277
277
artifacts = _find_cargo_artifacts (
278
278
cargo_messages .splitlines (),
279
279
package_id = package_id ,
280
- kind = "cdylib" ,
280
+ kinds = { "cdylib" , "dylib" } ,
281
281
)
282
282
if len (artifacts ) == 0 :
283
283
raise DistutilsExecError (
284
- "Rust build failed; unable to find any build artifacts"
284
+ "Rust build failed; unable to find any cdylib or dylib build artifacts"
285
285
)
286
286
elif len (artifacts ) > 1 :
287
287
raise DistutilsExecError (
288
- f"Rust build failed; expected only one build artifact but found { artifacts } "
288
+ f"Rust build failed; expected only one cdylib or dylib build artifact but found { artifacts } "
289
289
)
290
290
291
291
artifact_path = artifacts [0 ]
@@ -657,7 +657,7 @@ def _find_cargo_artifacts(
657
657
cargo_messages : List [str ],
658
658
* ,
659
659
package_id : str ,
660
- kind : str ,
660
+ kinds : Set [ str ] ,
661
661
) -> List [str ]:
662
662
"""Identifies cargo artifacts built for the given `package_id` from the
663
663
provided cargo_messages.
@@ -666,11 +666,11 @@ def _find_cargo_artifacts(
666
666
... [
667
667
... '{"some_irrelevant_message": []}',
668
668
... '{"reason":"compiler-artifact","package_id":"some_id","target":{"kind":["cdylib"]},"filenames":["/some/path/baz.so"]}',
669
- ... '{"reason":"compiler-artifact","package_id":"some_id","target":{"kind":["cdylib ", "rlib"]},"filenames":["/file/two/baz.dylib", "/file/two/baz.rlib"]}',
669
+ ... '{"reason":"compiler-artifact","package_id":"some_id","target":{"kind":["dylib ", "rlib"]},"filenames":["/file/two/baz.dylib", "/file/two/baz.rlib"]}',
670
670
... '{"reason":"compiler-artifact","package_id":"some_other_id","target":{"kind":["cdylib"]},"filenames":["/not/this.so"]}',
671
671
... ],
672
672
... package_id="some_id",
673
- ... kind= "cdylib",
673
+ ... kinds={ "cdylib", "dylib"} ,
674
674
... )
675
675
['/some/path/baz.so', '/file/two/baz.dylib']
676
676
>>> _find_cargo_artifacts(
@@ -681,14 +681,14 @@ def _find_cargo_artifacts(
681
681
... '{"reason":"compiler-artifact","package_id":"some_other_id","target":{"kind":["cdylib"]},"filenames":["/not/this.so"]}',
682
682
... ],
683
683
... package_id="some_id",
684
- ... kind= "rlib",
684
+ ... kinds={ "rlib"} ,
685
685
... )
686
686
['/file/two/baz.rlib']
687
687
"""
688
688
artifacts = []
689
689
for message in cargo_messages :
690
690
# only bother parsing messages that look like a match
691
- if "compiler-artifact" in message and package_id in message and kind in message :
691
+ if "compiler-artifact" in message and package_id in message :
692
692
parsed = json .loads (message )
693
693
# verify the message is correct
694
694
if (
@@ -698,7 +698,7 @@ def _find_cargo_artifacts(
698
698
for artifact_kind , filename in zip (
699
699
parsed ["target" ]["kind" ], parsed ["filenames" ]
700
700
):
701
- if artifact_kind == kind :
701
+ if artifact_kind in kinds :
702
702
artifacts .append (filename )
703
703
return artifacts
704
704
0 commit comments