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
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
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
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
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.
>
>
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
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.
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.