ronaldoussoren / py2app

py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts.
Other
341 stars 36 forks source link

Symlinks are stripped from frameworks #234

Open ronaldoussoren opened 7 years ago

ronaldoussoren commented 7 years ago

Original report by Daniel Miller (Bitbucket: millerdev, GitHub: millerdev).


After upgrading py2app from 0.9 to 0.14 in EditXT I'm getting an error related to the Sparkle framework:

During the stripping phase I get this (previous lines included for context):

$ python setup.py py2app
...
stripping fileop
stripping binascii.so
error: [Errno 2] No such file or directory: '/Users/dmiller/code/EditXT/dist/EditXT.app/Contents/Frameworks/Sparkle.framework/Sparkle'

The Sparkle framework in the app bundle has none of the symlinks (for example Sparkle -> Versions/Current/Sparkle) that are in the source bundle from which the framework was copied.

It succeeds if I build with python setup.py py2app --no-strip, but the symlinks are still not present in the Sparkle.framework in the built app bundle.

Build environment:
Python 3.6.1
Mac OS 10.11.6

ronaldoussoren commented 7 years ago

Original comment by Daniel Miller (Bitbucket: millerdev, GitHub: millerdev).


Updated previous py2app version (0.12 was wrong). The older version of py2app (0.9), which was used before upgrading Python to 3.6.1, does not work with Python 3.6.1.

ronaldoussoren commented 7 years ago

Original comment by Daniel Miller (Bitbucket: millerdev, GitHub: millerdev).


Maybe related to 54c9003ac836a968d8400019937bc6451f456f64 or 7ed277da3184a7b5070ce4d220accf0b64038f96

ronaldoussoren commented 6 years ago

Original comment by JonathanH (Bitbucket: Marginal42, ).


The problem occurs because relative symlinks within the framework bundle are not copied into dist_dir.

The error was introduced in https://bitbucket.org/ronaldoussoren/py2app/commits/54c9003ac836a968d8400019937bc6451f456f64#Lpy2app/util.pyT558

Suggested fix:

--- py2app/util.py.orig 2018-03-01 02:31:07.000000000 +0000
+++ py2app/util.py  2018-03-01 02:32:53.000000000 +0000
@@ -614,9 +614,13 @@

         # Note: using zipio's internal _locate function throws an IOError on
         # dead symlinks, so handle it here.
-        if os.path.islink(src_name) \
-                and not os.path.exists(os.readlink(src_name)):
-            continue
+        if os.path.islink(src_name):
+            link_dest = os.readlink(src_name)
+            if not os.path.exists(link_dest.startswith(os.sep) and
+                                  os.readlink(src_name) or
+                                  os.path.join(os.path.dirname(src_name),
+                                               link_dest)):
+                continue

         if preserve_symlinks and zipio.islink(src_name):
             link_dest = zipio.readlink(src_name)