Browse Source

makewheel: Don't run codesign --remove-signature on files without signature

See #927
rdb 4 years ago
parent
commit
13a764c91e
1 changed files with 9 additions and 7 deletions
  1. 9 7
      makepanda/makewheel.py

+ 9 - 7
makepanda/makewheel.py

@@ -404,6 +404,7 @@ class WheelFile(object):
 
 
             # Now add dependencies.  On macOS, fix @loader_path references.
             # Now add dependencies.  On macOS, fix @loader_path references.
             if sys.platform == "darwin":
             if sys.platform == "darwin":
+                is_unsigned = subprocess.call(['codesign', '-d', temp.name], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
                 if source_path.endswith('deploy-stubw'):
                 if source_path.endswith('deploy-stubw'):
                     deps_path = '@executable_path/../Frameworks'
                     deps_path = '@executable_path/../Frameworks'
                 else:
                 else:
@@ -444,13 +445,14 @@ class WheelFile(object):
                     remove_signature = True
                     remove_signature = True
 
 
                 # Replace the codesign signature if we modified the library.
                 # Replace the codesign signature if we modified the library.
-                if remove_signature:
-                    if self.platform.endswith("_arm64"):
-                        subprocess.call(["codesign", "-f", "-s", "-", temp.name])
-                    else:
-                        subprocess.call(["codesign", "--remove-signature", temp.name])
-                        if self.platform.endswith("_universal2"):
-                            subprocess.call(["codesign", "-a", "arm64", "-s", "-", temp.name])
+                if self.platform.endswith("_arm64") and (is_unsigned or remove_signature):
+                    subprocess.call(["codesign", "-f", "-s", "-", temp.name])
+                elif remove_signature and not is_unsigned:
+                    if GetVerbose():
+                        print("Removing code signature from {0}".format(source_path))
+                    subprocess.call(["codesign", "--remove-signature", temp.name])
+                    if self.platform.endswith("_universal2"):
+                        subprocess.call(["codesign", "-a", "arm64", "-s", "-", temp.name])
             else:
             else:
                 # On other unixes, we just add dependencies normally.
                 # On other unixes, we just add dependencies normally.
                 for dep in deps:
                 for dep in deps: