File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -517,10 +517,10 @@ def _cargo_args(
517517 if target_triple is not None :
518518 args .extend (["--target" , target_triple ])
519519
520- if release :
521- profile = ext . get_cargo_profile ( )
522- if not profile :
523- args .append ("--release" )
520+ ext_profile = ext . get_cargo_profile ()
521+ env_profile = os . getenv ( "SETUPTOOLS_RUST_CARGO_PROFILE" )
522+ if release and not ext_profile and not env_profile :
523+ args .append ("--release" )
524524
525525 if quiet :
526526 args .append ("-q" )
@@ -541,6 +541,18 @@ def _cargo_args(
541541 if ext .args is not None :
542542 args .extend (ext .args )
543543
544+ if env_profile :
545+ if ext_profile :
546+ args = [p for p in args if not p .startswith ("--profile=" )]
547+ while True :
548+ try :
549+ index = args .index ("--profile" )
550+ del args [index :index + 2 ]
551+ except ValueError :
552+ break
553+
554+ args .extend (["--profile" , env_profile ])
555+
544556 if ext .cargo_manifest_args is not None :
545557 args .extend (ext .cargo_manifest_args )
546558
You can’t perform that action at this time.
0 commit comments