Skip to content

pyinstaller on Mac OSX 14.5 fails on a very simple code with a codesign issue #8581

Description

@oliviermarti

Description of the issue

I'm trying to test pyinstaller on a very simple python script which is only print ("Hello world"), and it fails with SystemError: codesign command (['codesign', '--remove', '--all-architectures', '/Users/marti/build/hello/hello']) failed with error code 106!

I've seen lot of issues about MacOS X signing, but I couldn't find a solution. Is it supposed to work on Mac OSX 14.5 ?

I've test a few options with no success.

Context information (for bug reports)

  • Output of pyinstaller --version : 6.7.0
  • Version of Python: 3.11.9
  • Platform: Mac OS Sonoma 14.5 macOS-14.5-arm64-arm-64bit
  • How you installed Python: conda

A minimal example program which shows the error

print ("Hello world")

Stacktrace / full error message

> pyinstaller  hello.py
234 INFO: PyInstaller: 6.7.0, contrib hooks: 2024.6
234 INFO: Python: 3.11.9 (conda)
295 INFO: Platform: macOS-14.5-arm64-arm-64bit
296 INFO: wrote /Users/marti/hello.spec
300 INFO: Extending PYTHONPATH with paths
['/Users/xxxx']
466 INFO: checking Analysis
469 INFO: checking PYZ
470 INFO: EXE target arch: arm64
470 INFO: Code signing identity: None
473 INFO: checking PKG
473 INFO: Bootloader /Users/marti/miniforge3/envs/FULL/lib/python3.11/site-packages/PyInstaller/bootloader/Darwin-64bit/run
473 INFO: checking EXE
473 INFO: Building EXE because EXE-00.toc is non existent
473 INFO: Building EXE from EXE-00.toc
473 INFO: Copying bootloader EXE to /Users/marti/build/hello/hello
474 INFO: Converting EXE to target arch (arm64)
474 INFO: Removing signature(s) from EXE
Traceback (most recent call last):
 File "/Users/xxxx/miniforge3/envs/FULL/bin/pyinstaller", line 11, in <module>
   sys.exit(run())
            ^^^^^
 File "/Users/xxxx/miniforge3/envs/FULL/lib/python3.11/site-packages/PyInstaller/__main__.py", line 212, in run
   run_build(pyi_config, spec_file, **vars(args))
 File "/Users/xxxx/miniforge3/envs/FULL/lib/python3.11/site-packages/PyInstaller/__main__.py", line 69, in run_build
   PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
 File "/Users/xxxx/miniforge3/envs/FULL/lib/python3.11/site-packages/PyInstaller/building/build_main.py", line 1189, in main
   build(specfile, distpath, workpath, clean_build)
 File "/Users/xxxx/miniforge3/envs/FULL/lib/python3.11/site-packages/PyInstaller/building/build_main.py", line 1129, in build
   exec(code, spec_namespace)
 File "/Users/xxxx/hello.spec", line 19, in <module>
   exe = EXE(
         ^^^^
 File "/Users/xxxx/miniforge3/envs/FULL/lib/python3.11/site-packages/PyInstaller/building/api.py", line 643, in __init__
   self.__postinit__()
 File "/Users/xxxx/miniforge3/envs/FULL/lib/python3.11/site-packages/PyInstaller/building/datastruct.py", line 184, in __postinit__
   self.assemble()
 File "/Users/xxxx/miniforge3/envs/FULL/lib/python3.11/site-packages/PyInstaller/building/api.py", line 820, in assemble
   osxutils.remove_signature_from_binary(build_name)
 File "/Users/xxxx/miniforge3/envs/FULL/lib/python3.11/site-packages/PyInstaller/utils/osx.py", line 365, in remove_signature_from_binary
   raise SystemError(f"codesign command ({cmd_args}) failed with error code {p.returncode}!\noutput: {p.stdout}")
SystemError: codesign command (['codesign', '--remove', '--all-architectures', '/Users/marti/build/hello/hello']) failed with error code 106!
output: --sign is required
Run with --help for more information.

Activity

  1. rokm commented on Jun 4, 2024

    @rokm
    Member

    I've seen lot of issues about MacOS X signing, but I couldn't find a solution. Is it supposed to work on Mac OSX 14.5 ?

    It works just fine on my test macOS 14.5 system.


    output: --sign is required
    

    This sounds like you have some sort of codesign wrapper in PATH, which masks the actual codesign utility.

    What is the output of

    which codesign
    

    and

    codesign --help
    
  2. oliviermarti commented on Jun 4, 2024

    @oliviermarti
    Author
    > which codesign
    /Users/marti/miniforge3/bin/codesign
    > codesign --help
    codesign
    Usage: codesign [OPTIONS] [files...]
    
    Positionals:
      files TEXT ...              Files to sign
    
    Options:
      -h,--help                   Print this help message and exit
      -s,--sign TEXT REQUIRED     Code signing identity
      -i,--identifier TEXT        File identifier
      -f,--force                  Replace any existing signatures
      --entitlements TEXT         Entitlements plist
    

    This is indeed not /usr/bin/codesign !

    Running :

    > PATH="/usr/bin:$PATH"
    > pyinstaller -c --onedir hello.py
    

    works smoothly.

    I have to rethink my PATH

    Thanks !! :-) (for your response, for the rapidity of the response, and for pyinstaller in general !)

    Olivier

  3. removed
    triagePlease triage and relabel this issue
    on Jun 4, 2024
  4. locked as resolved and limited conversation to collaborators on Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions