@@ -40,6 +40,7 @@ def initialize_options(self):
40
40
self .vendor_crates = 0
41
41
42
42
def get_file_list (self ):
43
+ super ().get_file_list ()
43
44
if self .vendor_crates :
44
45
manifest_paths = []
45
46
for ext in self .distribution .rust_extensions :
@@ -68,11 +69,23 @@ def get_file_list(self):
68
69
cargo_config = cargo_config .replace (base_dir_bytes + os .sep .encode (), b'' )
69
70
if os .altsep :
70
71
cargo_config = cargo_config .replace (base_dir_bytes + os .altsep .encode (), b'' )
72
+
73
+ # Check whether `.cargo/config`/`.cargo/config.toml` already exists
74
+ existing_cargo_config = None
75
+ for filename in (".cargo/config" , ".cargo/config.toml" ):
76
+ if filename in self .filelist .allfiles :
77
+ existing_cargo_config = filename
78
+ break
79
+ if existing_cargo_config :
80
+ cargo_config_path = os .path .join (base_dir , existing_cargo_config )
81
+ # Append vendor config to original cargo config
82
+ with open (existing_cargo_config , "rb" ) as f :
83
+ cargo_config = f .read () + b'\n ' + cargo_config
84
+
71
85
with open (cargo_config_path , "wb" ) as f :
72
86
f .write (cargo_config )
73
87
self .filelist .append (vendor_path )
74
88
self .filelist .append (cargo_config_path )
75
- super ().get_file_list ()
76
89
dist .cmdclass ["sdist" ] = sdist_rust_extension
77
90
78
91
build_ext_base_class = dist .cmdclass .get ('build_ext' , build_ext )
0 commit comments