Re: py2app questions

Ronald Oussoren via Pythonmac-SIG <[email protected]> Mon, 14 Dec 2020 09:21:50 +0100
Newsgroups gmane.comp.python.apple
Message-ID <[email protected]>
--===============4207006264799427068==
Content-Type: multipart/alternative;
	boundary="Apple-Mail=_C282F7E1-16F5-4357-95D2-73F61A011CE1"


--Apple-Mail=_C282F7E1-16F5-4357-95D2-73F61A011CE1
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8



> On 13 Dec 2020, at 04:53, Timothy M. Shead =
<[email protected]> wrote:
>=20
> Many thanks for py2app, of all the packaging apps I=E2=80=99ve tried, =
it=E2=80=99s been the most usable by far; that said, I have questions.  =
Using conda, python 3.8.5, and py2app 0.22 on MacOS 10.15.7 with the =
following test app:
>=20
>    # hello.py
>    print(=E2=80=9CHello, World!=E2=80=9D)
>=20
> And the following default setup.py:
>=20
>    from setuptools import setup
>=20
>    APP =3D ["hello.py=E2=80=9D]
>    DATA_FILES =3D []
>    OPTIONS =3D {}
>=20
>    setup(
>        app=3DAPP,
>        data_files=3DDATA_FILES,
>        options=3D{"py2app": OPTIONS},
>        setup_requires=3D["py2app=E2=80=9D],
>    )
>=20
> Everything builds and runs fine:
>=20
>    $ python setup.py py2app
>    $ dist/hello.app/Contents/MacOS/hello
>    Hello, World!
>=20
> However, upon closer inspection, I see that there are a couple of libs =
that are being loaded from outside the bundle:
>=20
>    $ DYLD_PRINT_LIBRARIES=3D1 dist/hello.app/Contents/MacOS/hello
>    ...
>    /Users/tshead/miniconda3/envs/flow/lib/libz.1.dylib
>    /Users/tshead/miniconda3/envs/flow/lib/libffi.7.dylib
>=20
> Focusing on libz, I see that it=E2=80=99s being loaded from a library =
that is part of the bundle:
>=20
>    $ otool -L =
dist/hello.app/Contents/Resources/lib/python3.8/lib-dynload/zlib.so
>    =
dist/hello.app/Contents/Resources/lib/python3.8/lib-dynload/zlib.so:
> 	    @rpath/libz.1.dylib (compatibility version 1.0.0, current =
version 1.2.11)
>            =E2=80=A6

How was Python build?=20

>=20
> And when I look at the main executable, the second rpath looks =
questionable:
>=20
>    $ otool -l dist/hello.app/Contents/MacOS/hello
>    =E2=80=A6
>    Load command 16
>              cmd LC_RPATH
>          cmdsize 32
>             path @loader_path/../lib (offset 12)
>    Load command 17
>              cmd LC_RPATH
>          cmdsize 48
>             path @loader_path/../../../../../ (offset 12)

Was this file created by py2app, or did you change it afterwards?  The =
stub executable in current releases of py2app should not contain =
LC_RPATH entries at all.

>=20
> What is the right approach to address this?  Manually copy the missing =
.dylib files into dist/hello.app/Contents/lib?  I=E2=80=99m too new to =
know what to expect from py2app, but I=E2=80=99m surprised that it would =
be necessary for something as ubiquitous as zlib?

Py2app, or rather the macholib library used by py2app, does not process =
@rpath correctly. The code is older than the introduction of this =
feature and is not easily adjusted for it because some information =
needed for correctly dealing with @rpath and @loader_path is lost before =
the code that should use the information is active.  I have rewriting =
that code on my too long todo list.

Note that this works for me, with the Python.org <http://python.org/> =
installation of Python.

Ronald
=E2=80=94

Twitter / micro.blog: @ronaldoussoren
Blog: https://blog.ronaldoussoren.net/
>=20
> Cheers,
> Tim
>=20
> _______________________________________________
> Pythonmac-SIG maillist  -  [email protected]
> https://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG


--Apple-Mail=_C282F7E1-16F5-4357-95D2-73F61A011CE1
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D""><div =
class=3D""><br class=3D"">
</div>
<div><br class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D"">On 13 Dec 2020, at 04:53, Timothy M. Shead &lt;<a =
href=3D"mailto:[email protected]" =
class=3D"">[email protected]</a>&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><div class=3D"">Many =
thanks for py2app, of all the packaging apps I=E2=80=99ve tried, it=E2=80=99=
s been the most usable by far; that said, I have questions. &nbsp;Using =
conda, python 3.8.5, and py2app 0.22 on MacOS 10.15.7 with the following =
test app:<br class=3D""><br class=3D""> &nbsp;&nbsp;&nbsp;# hello.py<br =
class=3D""> &nbsp;&nbsp;&nbsp;print(=E2=80=9CHello, World!=E2=80=9D)<br =
class=3D""><br class=3D"">And the following default setup.py:<br =
class=3D""><br class=3D""> &nbsp;&nbsp;&nbsp;from setuptools import =
setup<br class=3D""><br class=3D""> &nbsp;&nbsp;&nbsp;APP =3D =
["hello.py=E2=80=9D]<br class=3D""> &nbsp;&nbsp;&nbsp;DATA_FILES =3D =
[]<br class=3D""> &nbsp;&nbsp;&nbsp;OPTIONS =3D {}<br class=3D""><br =
class=3D""> &nbsp;&nbsp;&nbsp;setup(<br class=3D""> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;app=3DAPP,<br class=3D""> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data_files=3DDATA_FILES,<br =
class=3D""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options=3D{"py2app":=
 OPTIONS},<br class=3D""> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setup_requires=3D["py2app=E2=80=9D=
],<br class=3D""> &nbsp;&nbsp;&nbsp;)<br class=3D""><br =
class=3D"">Everything builds and runs fine:<br class=3D""><br class=3D""> =
&nbsp;&nbsp;&nbsp;$ python setup.py py2app<br class=3D""> =
&nbsp;&nbsp;&nbsp;$ dist/hello.app/Contents/MacOS/hello<br class=3D""> =
&nbsp;&nbsp;&nbsp;Hello, World!<br class=3D""><br class=3D"">However, =
upon closer inspection, I see that there are a couple of libs that are =
being loaded from outside the bundle:<br class=3D""><br class=3D""> =
&nbsp;&nbsp;&nbsp;$ DYLD_PRINT_LIBRARIES=3D1 =
dist/hello.app/Contents/MacOS/hello<br class=3D""> =
&nbsp;&nbsp;&nbsp;...<br class=3D""> =
&nbsp;&nbsp;&nbsp;/Users/tshead/miniconda3/envs/flow/lib/libz.1.dylib<br =
class=3D""> =
&nbsp;&nbsp;&nbsp;/Users/tshead/miniconda3/envs/flow/lib/libffi.7.dylib<br=
 class=3D""><br class=3D"">Focusing on libz, I see that it=E2=80=99s =
being loaded from a library that is part of the bundle:<br class=3D""><br =
class=3D""> &nbsp;&nbsp;&nbsp;$ otool -L =
dist/hello.app/Contents/Resources/lib/python3.8/lib-dynload/zlib.so<br =
class=3D""> =
&nbsp;&nbsp;&nbsp;dist/hello.app/Contents/Resources/lib/python3.8/lib-dynl=
oad/zlib.so:<br class=3D""><span class=3D"Apple-tab-span" =
style=3D"white-space:pre">	</span> =
&nbsp;&nbsp;&nbsp;@rpath/libz.1.dylib (compatibility version 1.0.0, =
current version 1.2.11)<br class=3D""> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=E2=80=A6=
<br class=3D""></div></div></blockquote><div><br class=3D""></div>How =
was Python build?&nbsp;</div><div><br class=3D""><blockquote type=3D"cite"=
 class=3D""><div class=3D""><div class=3D""><br class=3D"">And when I =
look at the main executable, the second rpath looks questionable:<br =
class=3D""><br class=3D""> &nbsp;&nbsp;&nbsp;$ otool -l =
dist/hello.app/Contents/MacOS/hello<br class=3D""> =
&nbsp;&nbsp;&nbsp;=E2=80=A6<br class=3D""> &nbsp;&nbsp;&nbsp;Load =
command 16<br class=3D""> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;cmd LC_RPATH<br class=3D""> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmdsize 32<br =
class=3D""> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pa=
th @loader_path/../lib (offset 12)<br class=3D""> &nbsp;&nbsp;&nbsp;Load =
command 17<br class=3D""> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;cmd LC_RPATH<br class=3D""> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmdsize 48<br =
class=3D""> =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pa=
th @loader_path/../../../../../ (offset 12)<br =
class=3D""></div></div></blockquote><div><br class=3D""></div><div>Was =
this file created by py2app, or did you change it afterwards? &nbsp;The =
stub executable in current releases of py2app should not contain =
LC_RPATH entries at all.</div><br class=3D""><blockquote type=3D"cite" =
class=3D""><div class=3D""><div class=3D""><br class=3D"">What is the =
right approach to address this? &nbsp;Manually copy the missing .dylib =
files into dist/hello.app/Contents/lib? &nbsp;I=E2=80=99m too new to =
know what to expect from py2app, but I=E2=80=99m surprised that it would =
be necessary for something as ubiquitous as zlib?<br =
class=3D""></div></div></blockquote><div><br class=3D""></div><div>Py2app,=
 or rather the macholib library used by py2app, does not process @rpath =
correctly. The code is older than the introduction of this feature and =
is not easily adjusted for it because some information needed for =
correctly dealing with @rpath and @loader_path is lost before the code =
that should use the information is active. &nbsp;I have rewriting that =
code on my too long todo list.</div><div><br class=3D""></div><div>Note =
that this works for me, with the <a href=3D"http://Python.org" =
class=3D"">Python.org</a>&nbsp;installation of Python.</div><div><br =
class=3D""></div><div>Ronald</div><div>=E2=80=94</div><div><br =
class=3D""></div><div>Twitter / micro.blog: =
@ronaldoussoren</div><div>Blog: <a =
href=3D"https://blog.ronaldoussoren.net/" =
class=3D"">https://blog.ronaldoussoren.net/</a></div><blockquote =
type=3D"cite" class=3D""><div class=3D""><div class=3D""><br =
class=3D"">Cheers,<br class=3D"">Tim<br class=3D""><br =
class=3D"">_______________________________________________<br =
class=3D"">Pythonmac-SIG maillist &nbsp;- &nbsp;<a =
href=3D"mailto:[email protected]" =
class=3D"">[email protected]</a><br class=3D""><a =
href=3D"https://mail.python.org/mailman/listinfo/pythonmac-sig" =
class=3D"">https://mail.python.org/mailman/listinfo/pythonmac-sig</a><br =
class=3D"">unsubscribe: =
https://mail.python.org/mailman/options/Pythonmac-SIG<br =
class=3D""></div></div></blockquote></div><br class=3D""></body></html>=

--Apple-Mail=_C282F7E1-16F5-4357-95D2-73F61A011CE1--

--===============4207006264799427068==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Pythonmac-SIG maillist  -  [email protected]
https://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG

--===============4207006264799427068==--