Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#38163 closed defect (invalid)

py2app and macholib error

Reported by: drsmith48@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 2.1.3
Keywords: Cc: jmroot (Joshua Root)


Py2app and macholib raise the error "ValueError: New Mach-O header is too large to relocate". The patches for configure.ldflags in portconfigure.tcl described here

do not fix the error. I suspect some ports override default configure.ldflags. Also, I think OpenCV triggers the same error:

Error stack:

WARNING: Mach-O header may be too large to relocate
WARNING: Mach-O header may be too large to relocate
Traceback (most recent call last):
  File "", line 26, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/", line 152, in setup
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/", line 953, in run_commands
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/", line 972, in run_command
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py2app/", line 553, in run
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py2app/", line 741, in _run
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py2app/", line 831, in run_normal
    self.create_binaries(py_files, pkgdirs, extensions, loader_files)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py2app/", line 978, in create_binaries
    platfiles =
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/macholib/", line 140, in run
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/macholib/", line 119, in write
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/macholib/", line 314, in write
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/macholib/", line 304, in synchronize_size
    raise ValueError("New Mach-O header is too large to relocate")
ValueError: New Mach-O header is too large to relocate

py2app's full output is attached.

Env: python27, py27-py2app, py27-macholib on OSX 10.8.

Any guidance would be helpful. There seems to be lots of confusion about this in trac and stack overflow.


Attachments (1)

build.txt (1.1 MB) - added by drsmith48@… 5 years ago.
py2app output

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by drsmith48@…

Attachment: build.txt added

py2app output

comment:1 Changed 5 years ago by jmroot (Joshua Root)

Resolution: invalid
Status: newclosed

As explained in your links, there is nothing py2app can do about this. The relocated header cannot be larger than the original.

comment:2 Changed 5 years ago by drsmith48@…

How about macholib? I'm not sure where the bug lies.

comment:3 Changed 5 years ago by jmroot (Joshua Root)

AIUI it's more like a limitation of the Mach-O format, in that to increase the size of the header you effectively have to re-link the file. So it could be viewed as a deficiency of macholib that it doesn't do that, but it's not like it's a simple fix, which is why install_name_tool can't do it either.

comment:4 Changed 5 years ago by spam4scott@…

For future reference. I had begun posting "Same problem as above. Earlier, editing portconfigure.tcl did the trick, but with the newer MacPorts I confirm that this does not fix it; i.e., error persists despite fresh clean/reinstall of MacPorts, rebuilding with -headerpad... in portconfigure.tcl "

...However, this is now...

RESOLVED: Posting solution for future users: The issue resulted from my default python installation somehow getting switched from the MacPorts version in /opt/local/bin to the Apple version in /usr/bin. (No idea how. Lion->Mountain Lion upgrade, perhaps?)

MacPorts now comes with the required -headerpad,etc. modifications, so if you are still encountering the error that started this thread, run "which python" and if you see "/usr/bin/python", then set your path so that it checks /opt/local/bin first.

With this change -- i.e., using the actual MacPorts python instead of the 'default' (duhhh) -- the build finishes successfully and the executable application runs without problem.

Last edited 5 years ago by spam4scott@… (previous) (diff)
Note: See TracTickets for help on using tickets.