1.5rc1 fails on Mac OS 10.6

25 views
Skip to first unread message

Nathan Weston

unread,
Dec 2, 2010, 6:09:04 PM12/2/10
to pyins...@googlegroups.com
PyInstaller 1.5rc1 fails to build executables on Snow Leopard. It always
wants to use the 64-bit bootloader (which doesn't exist) even when I
configure/build with a 32-bit python.

Python on Snow Leopard is an i386/x64 universal binary, which runs as a
64-bit executable by default. You can choose 32-bit by setting the
environment variable VERSIONER_PYTHON_PREFER_32_BIT=yes. However,
platform.architecture(), which PyInstaller uses to choose a bootloader,
doesn't work correctly -- it apparently gets confused by the universal
binary an always returns ('64bit', '').

After poking around a bit it seems that the most reliable way to detect
the architecture is by checking sys.maxint. I was able to fix the
problem by replacing "platform.architecture()[0]" with this function:

def architecture():
if sys.maxint > 3**32:
return '64bit'
else:
return '32bit'

I can submit a patch if that would be helpful.

The good news is that once I fix this problem, it works perfectly -- I
don't need any of the patches or workarounds that I had with previous
versions.

- Nathan

Giovanni Bajo

unread,
Dec 3, 2010, 5:06:37 AM12/3/10
to pyins...@googlegroups.com
On Thu, 2010-12-02 at 18:09 -0500, Nathan Weston wrote:
> PyInstaller 1.5rc1 fails to build executables on Snow Leopard. It always
> wants to use the 64-bit bootloader (which doesn't exist) even when I
> configure/build with a 32-bit python.
>
> Python on Snow Leopard is an i386/x64 universal binary, which runs as a
> 64-bit executable by default. You can choose 32-bit by setting the
> environment variable VERSIONER_PYTHON_PREFER_32_BIT=yes. However,
> platform.architecture(), which PyInstaller uses to choose a bootloader,
> doesn't work correctly -- it apparently gets confused by the universal
> binary an always returns ('64bit', '').
>
> After poking around a bit it seems that the most reliable way to detect
> the architecture is by checking sys.maxint. I was able to fix the
> problem by replacing "platform.architecture()[0]" with this function:
>
> def architecture():
> if sys.maxint > 3**32:
> return '64bit'
> else:
> return '32bit'
>
> I can submit a patch if that would be helpful.

Yes, please! If you can submit a patch that you know it is fully
working, I can slip it in before PyInstaller 1.5 is released.

So, let see if I understood:

* Mac OSX 64-bit does not work (or at least there is no bootloader --
it would be interesting to find out what happens if you build the
bootloader as explained in the manual, it might even work).

* To use the 32-bit version within the universal binary (which defaults
to 64-bit), you need an environment variable set but then PyInstaller
fails to detect that it's a 32-bit version because of
platform.architecture() (which is a Python bug IMO).

* By manually implementing architecture(), PyInstaller correctly
detects that you are running a 32-bit version of Python and works as
expected.

Since you are at it, it would be really great if you could add at the
top of Configure.py an early error for Darwin 64-bit, something like:

if darwin and architecture() == "64bit":
print "ERROR: PyInstaller does not support Python 64-bit on Mac OSX"
print "Try using the 32-bit version of Python, by setting"
print "VERSIONER_PYTHON_PREFER_32_BIT=yes in the environment"
sys.exit(2)

This would lead to less confusion for Mac people.

> The good news is that once I fix this problem, it works perfectly -- I
> don't need any of the patches or workarounds that I had with previous
> versions.

I'm really happy to hear that, Lorenzo has gone through many hoops to
test and complete the patches that were dangling around :)

Since you seem to be knowledgeable on the Mac OSX platform, any idea
about the issue reported by Isaac Wagner on this mailing list ("Mac OSX
Support", Dec 1st)? He can't build a working executable with Python 2.7
from python.org on Mac.

Thanks!
--
Giovanni Bajo :: ra...@develer.com
Develer S.r.l. :: http://www.develer.com

My Blog: http://giovanni.bajo.it
Last post: Compile-time Function Execution in D

Nathan Weston

unread,
Dec 3, 2010, 9:14:00 AM12/3/10
to pyins...@googlegroups.com
On 12/03/2010 05:06 AM, Giovanni Bajo wrote:
>> I can submit a patch if that would be helpful.
>
> Yes, please! If you can submit a patch that you know it is fully
> working, I can slip it in before PyInstaller 1.5 is released.

Great. I can probably get a patch together on Monday.

> So, let see if I understood:
>
> * Mac OSX 64-bit does not work (or at least there is no bootloader --
> it would be interesting to find out what happens if you build the
> bootloader as explained in the manual, it might even work).
>
> * To use the 32-bit version within the universal binary (which defaults
> to 64-bit), you need an environment variable set but then PyInstaller
> fails to detect that it's a 32-bit version because of
> platform.architecture() (which is a Python bug IMO).
>
> * By manually implementing architecture(), PyInstaller correctly
> detects that you are running a 32-bit version of Python and works as
> expected.

That's correct.

> Since you seem to be knowledgeable on the Mac OSX platform, any idea
> about the issue reported by Isaac Wagner on this mailing list ("Mac OSX
> Support", Dec 1st)? He can't build a working executable with Python 2.7
> from python.org on Mac.

Sorry, I don't have any ideas about that one.

- Nathan

Nathan Weston

unread,
Dec 6, 2010, 10:15:13 AM12/6/10
to pyins...@googlegroups.com
On 12/3/2010 5:06 AM, Giovanni Bajo wrote:
>> I can submit a patch if that would be helpful.
>
> Yes, please! If you can submit a patch that you know it is fully
> working, I can slip it in before PyInstaller 1.5 is released.
>

Ok, here's the patch. I included the warning message as well as the
correct architecture detection. I made this against the current
subversion trunk (r1282), and it works for me on Snow Leopard. I didn't
test on Windows/Linux.


- Nathan

pyinstaller-mac64.patch

Isaac Wagner

unread,
Dec 6, 2010, 11:12:26 AM12/6/10
to pyins...@googlegroups.com
Shouldn't the comparison be 2**31 instead of 3**32?

The fails for me on Win64 with a 64-bit Python install. For some
reason sys.maxint returns the same on my Win32 or Win64 boxes.

> --
> You received this message because you are subscribed to the Google Groups
> "PyInstaller" group.
> To post to this group, send email to pyins...@googlegroups.com.
> To unsubscribe from this group, send email to
> pyinstaller...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pyinstaller?hl=en.
>
>

Nathan Weston

unread,
Dec 6, 2010, 11:42:15 AM12/6/10
to pyins...@googlegroups.com, Isaac Wagner
On 12/6/2010 11:12 AM, Isaac Wagner wrote:
> Shouldn't the comparison be 2**31 instead of 3**32?
>
Oops, typo there. The left side should obviously be 2, not 3.

But I intentionally used 32 for the exponent, not 31. My thinking was
that on some hypothetical system, sys.maxint might be the maximum
unsigned int (not likely, but who knows?), so it was safer to use 32. We
don't need to be terribly precise since 64-bit maxint is many orders of
magnitude larger.

> The fails for me on Win64 with a 64-bit Python install. For some
> reason sys.maxint returns the same on my Win32 or Win64 boxes.

That's inconvenient. I guess we should stick with
platform.architecture() on non-Mac platforms.

I've attached a new patch that incorporates both these fixes.

- Nathan

pyinstaller-mac64-v2.patch

Giovanni Bajo

unread,
Dec 6, 2010, 12:17:10 PM12/6/10
to pyins...@googlegroups.com

Thanks, committed with slight changes in -rc2 (which I'm going to
release soon).

One change was to use 2L instead of 2, to cope with older Python
versions which don't mute int into long in case of overflow.

Martin Zibricky

unread,
Dec 6, 2010, 6:37:12 PM12/6/10
to pyins...@googlegroups.com
Giovanni Bajo píše v Po 06. 12. 2010 v 18:17 +0100:

> Thanks, committed with slight changes in -rc2 (which I'm going to
> release soon).

It is not possible to use in this fix module platform without breaking
compatibility with python 2.2.

'platform' is available in python since 2.3.

Reply all
Reply to author
Forward
0 new messages