소스 검색

Arm Chip for MacOS

Naibo Wang 2 년 전
부모
커밋
e09cae78d9
1개의 변경된 파일21개의 추가작업 그리고 4개의 파일을 삭제
  1. 21 4
      .temp_to_pub/compress.py

+ 21 - 4
.temp_to_pub/compress.py

@@ -11,6 +11,19 @@ import zipfile
 import urllib.request
 # import py7zr
 
+def get_processor_info():
+    if os.uname().sysname == 'Darwin':
+        processor_info = subprocess.check_output(['sysctl', '-n', 'machdep.cpu.brand_string']).strip()
+        processor_info = str(processor_info)
+        if 'Intel' in processor_info:
+            return 'Intel'
+        elif 'Apple' in processor_info:
+            return 'Apple'
+        else:
+            return 'Unknown'
+    else:
+        return 'This method is only implemented for macOS.'
+
 def compress_folder_to_7z(folder_path, output_file):
     if os.path.exists(output_file):
         os.remove(output_file)
@@ -107,10 +120,14 @@ if __name__ == "__main__":
         subprocess.call(["tar", "-Jcvf", file_name, "./EasySpider_Linux_x64"])
         print(f"Compress {file_name} successfully!")
     elif sys.platform == "darwin" and platform.architecture()[0] == "64bit":
-        file_name = f"EasySpider_{easyspider_version}_MacOS_all_arch.tar.gz"
-        if os.path.exists("./EasySpider_MacOS_all_arch/Data"):
-            shutil.rmtree("./EasySpider_MacOS_all_arch/Data")
-        os.mkdir("./EasySpider_MacOS_all_arch/Data")
+        arch = get_processor_info()
+        if arch == "Intel":
+            file_name = f"EasySpider_{easyspider_version}_MacOS_Intel_Chip.tar.gz"
+        else:
+            file_name = f"EasySpider_{easyspider_version}_MacOS_Apple_Arm_Chip.tar.gz"
+            if os.path.exists("./EasySpider_MacOS_all_arch/Data"):
+                shutil.rmtree("./EasySpider_MacOS_all_arch/Data")
+            os.mkdir("./EasySpider_MacOS_all_arch/Data")
         subprocess.call(["tar", "-zcvf", file_name, "./EasySpider_MacOS_all_arch"])
         subprocess.call(["7zz", "a", "-v95m", file_name.replace(".tar.gz", ".7z"), file_name, "请继续解压EasySpider_MacOS_all_arch.tar.gz使用.txt"])
         print(f"Compress {file_name} successfully!")