--- a/backends/pep517.py	2023-02-16 02:15:30.000000000 +0800
+++ b/backends/pep517.py	2023-02-18 01:31:54.245328767 +0800
@@ -30,6 +30,7 @@
 import os
 import glob
 import tarfile
+import tempfile
 import shutil
 import sys
 import zipfile
@@ -214,14 +215,16 @@
 
 
 def _build_and_inject_ac_index(build_dir, extracted_wheel_dir):
-    ac_index_build_name = _build_ac_index(build_dir)
+    ac_index_dir = tempfile.mkdtemp()
+    ac_index_build_name = _build_ac_index(ac_index_dir)
     extracted_ac_index = os.path.join(extracted_wheel_dir, AC_INDEX_REL_PATH)
     _remove_file_if_exists(extracted_ac_index)
     print("Adding auto-complete index into wheel")
-    os.rename(
+    shutil.copy2(
         ac_index_build_name,
         extracted_ac_index,
     )
+    shutil.rmtree(ac_index_dir)
 
 
 def _build_ac_index(build_dir, rebuild=True):
