Ultimaker / cura-build-environment

CMake project to build dependencies for Cura
GNU Affero General Public License v3.0
24 stars 55 forks source link

Compile Fails on macOS due to PyInstaller #130

Closed lbibass closed 2 years ago

lbibass commented 2 years ago

When attempting to compile Cura, pyinstaller throws this error:

  File "/Users/lbibass/git/cura-build-environment/install/bin/pyinstaller", line 8, in <module>
    sys.exit(run())
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/PyInstaller/__main__.py", line 124, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/PyInstaller/__main__.py", line 58, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/PyInstaller/building/build_main.py", line 803, in main
    build(specfile, distpath, workpath, clean_build)
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/PyInstaller/building/build_main.py", line 725, in build
    exec(code, spec_namespace)
  File "/Users/lbibass/git/cura-build-environment/install/installer/Ultimaker-Cura.spec", line 24, in <module>
    a = Analysis(['/Users/lbibass/git/cura-build-environment/install/bin/cura_app.py'],
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/PyInstaller/building/build_main.py", line 277, in __init__
    self.__postinit__()
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/PyInstaller/building/datastruct.py", line 155, in __postinit__
    self.assemble()
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/PyInstaller/building/build_main.py", line 504, in assemble
    bindepend.Dependencies(self.binaries, redirects=self.binding_redirects, xtrapath=extra_libdirs)
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/PyInstaller/depend/bindepend.py", line 207, in Dependencies
    for lib, npth in selectImports(pth, xtrapath):
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/PyInstaller/depend/bindepend.py", line 459, in selectImports
    dlls = getImports(pth)
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/PyInstaller/depend/bindepend.py", line 700, in getImports
    return _getImports_macholib(pth)
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/PyInstaller/depend/bindepend.py", line 600, in _getImports_macholib
    m = MachO(pth)
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/macholib/MachO.py", line 118, in __init__
    self.load(fp)
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/macholib/MachO.py", line 133, in load
    self.load_header(fh, 0, size)
  File "/Users/lbibass/git/cura-build-environment/install/lib/python3.10/site-packages/macholib/MachO.py", line 167, in load_header
    raise ValueError("Unknown Mach-O header: 0x%08x in %r" % (header, fh))
ValueError: Unknown Mach-O header: 0x213c6172 in <_io.BufferedReader name='/Users/lbibass/git/cura-build-environment/install/lib/python./site-packages/pySavitar.so'>
ninja: build stopped: subcommand failed.

It seems it's trying to load non-executable files as executables. I'm not sure how to fix this.

jellespijker commented 2 years ago

Which minor version of Python are you using. There was a bug in pyinstaller which requires at least 3.10.4

jellespijker commented 2 years ago

Are you compiling on a M1?

lbibass commented 2 years ago

Are you compiling on a M1?

Yes, I am.

jellespijker commented 2 years ago

Then you have to use the Rosetta terminal. We don't support native ARM yet.

lbibass commented 2 years ago

That's too bad. QT6 supports it, and all the other aspects of the compilation process should work.

lbibass commented 2 years ago
image

So this is bizarre. It just... compiled for me? Not sure what happened, but it worked. Apple Silicon native Cura!

jellespijker commented 2 years ago

That is very interesting and unexpected. Can you share the binaries.

lbibass commented 2 years ago

Sure. How would you like me to share them?

lbibass commented 2 years ago

I have figured out what I did in order to get it to compile: I had to completely delete the build folder and build from scratch. Attempting to rebuild in a directory that has already been used to compile Cura causes the error.

What a bizarre glitch.

jellespijker commented 2 years ago

Consistency is key in these kind of scenarios. Start with a fresh build folder. Make sure the cmake project is configured and build In the correct terminal. Also check if the python you're using isn't the pure Intel variant.

jellespijker commented 2 years ago

I hope you will get there, and I can help you a long a bit, if time allows it, but I will close this issue since we don't officially support ARM. But feel free ask and this thread.

If the arm approach fails use the Rosetta terminal. Just make sure you're consistent in that approach, so no messing up binaries from different architectures