@@ -249,7 +249,7 @@ def build_extension(
249249 artifacts = _find_cargo_artifacts (
250250 cargo_messages .splitlines (),
251251 package_id = package_id ,
252- kind = "bin" ,
252+ kinds = { "bin" } ,
253253 )
254254 for name , dest in ext .target .items ():
255255 if not name :
@@ -277,15 +277,15 @@ def build_extension(
277277 artifacts = _find_cargo_artifacts (
278278 cargo_messages .splitlines (),
279279 package_id = package_id ,
280- kind = "cdylib" ,
280+ kinds = { "cdylib" , "dylib" } ,
281281 )
282282 if len (artifacts ) == 0 :
283283 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"
285285 )
286286 elif len (artifacts ) > 1 :
287287 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 } "
289289 )
290290
291291 artifact_path = artifacts [0 ]
@@ -657,7 +657,7 @@ def _find_cargo_artifacts(
657657 cargo_messages : List [str ],
658658 * ,
659659 package_id : str ,
660- kind : str ,
660+ kinds : Set [ str ] ,
661661) -> List [str ]:
662662 """Identifies cargo artifacts built for the given `package_id` from the
663663 provided cargo_messages.
@@ -666,11 +666,11 @@ def _find_cargo_artifacts(
666666 ... [
667667 ... '{"some_irrelevant_message": []}',
668668 ... '{"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"]}',
670670 ... '{"reason":"compiler-artifact","package_id":"some_other_id","target":{"kind":["cdylib"]},"filenames":["/not/this.so"]}',
671671 ... ],
672672 ... package_id="some_id",
673- ... kind= "cdylib",
673+ ... kinds={ "cdylib", "dylib"} ,
674674 ... )
675675 ['/some/path/baz.so', '/file/two/baz.dylib']
676676 >>> _find_cargo_artifacts(
@@ -681,14 +681,14 @@ def _find_cargo_artifacts(
681681 ... '{"reason":"compiler-artifact","package_id":"some_other_id","target":{"kind":["cdylib"]},"filenames":["/not/this.so"]}',
682682 ... ],
683683 ... package_id="some_id",
684- ... kind= "rlib",
684+ ... kinds={ "rlib"} ,
685685 ... )
686686 ['/file/two/baz.rlib']
687687 """
688688 artifacts = []
689689 for message in cargo_messages :
690690 # 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 :
692692 parsed = json .loads (message )
693693 # verify the message is correct
694694 if (
@@ -698,7 +698,7 @@ def _find_cargo_artifacts(
698698 for artifact_kind , filename in zip (
699699 parsed ["target" ]["kind" ], parsed ["filenames" ]
700700 ):
701- if artifact_kind == kind :
701+ if artifact_kind in kinds :
702702 artifacts .append (filename )
703703 return artifacts
704704
0 commit comments