Re: [Pythonmac-SIG] machine architecture 32/64 with Python 2.6 on Snow Leopard?

2009-09-19 Thread Edward Moy
I looked into the code for platform.architecture(), and it basically  
runs the file command on /usr/bin/python.  If the output contains  
the string 64-bit, it will return 64bit as the first tuple.  So it  
depends on what real question you are trying to answer, because in  
SnowLeopard, /usr/bin/python is a wrapper program that does all the  
versioning, reading preference files, etc, and is independent of the  
real python executable: /System/Library/Frameworks/Python.framework/ 
Versions/2.6/Resources/Python.app/Contents/MacOS/Python.


Testing sys.maxint answers the question whether the current python in  
running in 32 or 64-bit mode.  platform.architecture() just tells if  
the wrapper is capable of running 64-bit (it will run 64-bit by  
default on 64-bit architectures, but could actually be running 32-bit,  
either by choice or on 32-bit only hardware), and doesn't say anything  
about the real python executable.


Ed

On Sep 18, 2009, at 5:46 PM, Bill Janssen wrote:

I think I'm just going to put '32bit' or '64bit' in my installer  
name strings.


Bill

e...@apple.com wrote:


On Sep 18, 2009, at 5:05 PM, Bill Janssen wrote:


William Kyngesburye wokl...@kyngchaos.com wrote:


If you run the CLI 'uname -m' on any Intel Mac, it always has
returned
i386.  So all it really means is 'Intel'.

On Sep 18, 2009, at 5:53 PM, Bill Janssen wrote:


I'm running /usr/bin/python on SL, and

 import platform; print platform.machine()

give me

 i386

But Activity Monitor shows Python as Intel (64-bit).

Is this a bug in platform.machine(), or am I misunderstanding what
i386
means?  platform.architecture() returns ('64bit', '').


Hmmm.  So what's the pythonic way of getting i386 vs. x86_64?

{'32bit': 'i386', '64bit': 'x86_64'}[platform.architecture()[0]]

seems so complicated that there should be a routine for it in sys or
platform.


I don't know the official way, but what I do is:

% python -c 'import sys;print sys.maxint'
9223372036854775807
% env VERSIONER_PYTHON_PREFER_32_BIT=1 python -c 'import sys;print
sys.maxint'
2147483647

So I would look at sys.maxint to determine if python is running 32 or
64-bit.

Ed


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] machine architecture 32/64 with Python 2.6 on Snow Leopard?

2009-09-19 Thread Bill Janssen
You could also use other test I've seen:

  def arch():
 import ctypes
 return {4: i386, 8: x86_64}[ctypes.sizeof(ctypes.c_size_t)]

Bill
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] machine architecture 32/64 with Python 2.6 on Snow Leopard?

2009-09-18 Thread Bill Janssen
I'm running /usr/bin/python on SL, and

import platform; print platform.machine()

give me

i386

But Activity Monitor shows Python as Intel (64-bit).

Is this a bug in platform.machine(), or am I misunderstanding what i386
means?  platform.architecture() returns ('64bit', '').

Bill
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] machine architecture 32/64 with Python 2.6 on Snow Leopard?

2009-09-18 Thread William Kyngesburye
If you run the CLI 'uname -m' on any Intel Mac, it always has returned  
i386.  So all it really means is 'Intel'.


On Sep 18, 2009, at 5:53 PM, Bill Janssen wrote:


I'm running /usr/bin/python on SL, and

   import platform; print platform.machine()

give me

   i386

But Activity Monitor shows Python as Intel (64-bit).

Is this a bug in platform.machine(), or am I misunderstanding what  
i386

means?  platform.architecture() returns ('64bit', '').

Bill
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


-
William Kyngesburye kyngchaos*at*kyngchaos*dot*com
http://www.kyngchaos.com/

Mon Dieu! but they are all alike.  Cheating, murdering, lying,  
fighting, and all for things that the beasts of the jungle would not  
deign to possess - money to purchase the effeminate pleasures of  
weaklings.  And yet withal bound down by silly customs that make them  
slaves to their unhappy lot while firm in the belief that they be the  
lords of creation enjoying the only real pleasures of existence


- the wisdom of Tarzan


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] machine architecture 32/64 with Python 2.6 on Snow Leopard?

2009-09-18 Thread Bill Janssen
William Kyngesburye wokl...@kyngchaos.com wrote:

 If you run the CLI 'uname -m' on any Intel Mac, it always has returned
 i386.  So all it really means is 'Intel'.
 
 On Sep 18, 2009, at 5:53 PM, Bill Janssen wrote:
 
  I'm running /usr/bin/python on SL, and
 
 import platform; print platform.machine()
 
  give me
 
 i386
 
  But Activity Monitor shows Python as Intel (64-bit).
 
  Is this a bug in platform.machine(), or am I misunderstanding what
  i386
  means?  platform.architecture() returns ('64bit', '').

Hmmm.  So what's the pythonic way of getting i386 vs. x86_64?

 {'32bit': 'i386', '64bit': 'x86_64'}[platform.architecture()[0]]

seems so complicated that there should be a routine for it in sys or
platform.

Bill
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] machine architecture 32/64 with Python 2.6 on Snow Leopard?

2009-09-18 Thread emoy

On Sep 18, 2009, at 5:05 PM, Bill Janssen wrote:


William Kyngesburye wokl...@kyngchaos.com wrote:

If you run the CLI 'uname -m' on any Intel Mac, it always has  
returned

i386.  So all it really means is 'Intel'.

On Sep 18, 2009, at 5:53 PM, Bill Janssen wrote:


I'm running /usr/bin/python on SL, and

  import platform; print platform.machine()

give me

  i386

But Activity Monitor shows Python as Intel (64-bit).

Is this a bug in platform.machine(), or am I misunderstanding what
i386
means?  platform.architecture() returns ('64bit', '').


Hmmm.  So what's the pythonic way of getting i386 vs. x86_64?

{'32bit': 'i386', '64bit': 'x86_64'}[platform.architecture()[0]]

seems so complicated that there should be a routine for it in sys or
platform.


I don't know the official way, but what I do is:

% python -c 'import sys;print sys.maxint'
9223372036854775807
% env VERSIONER_PYTHON_PREFER_32_BIT=1 python -c 'import sys;print  
sys.maxint'

2147483647

So I would look at sys.maxint to determine if python is running 32 or  
64-bit.


Ed
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] machine architecture 32/64 with Python 2.6 on Snow Leopard?

2009-09-18 Thread Bill Janssen
I think I'm just going to put '32bit' or '64bit' in my installer name strings.

Bill

e...@apple.com wrote:

 On Sep 18, 2009, at 5:05 PM, Bill Janssen wrote:
 
  William Kyngesburye wokl...@kyngchaos.com wrote:
 
  If you run the CLI 'uname -m' on any Intel Mac, it always has
  returned
  i386.  So all it really means is 'Intel'.
 
  On Sep 18, 2009, at 5:53 PM, Bill Janssen wrote:
 
  I'm running /usr/bin/python on SL, and
 
import platform; print platform.machine()
 
  give me
 
i386
 
  But Activity Monitor shows Python as Intel (64-bit).
 
  Is this a bug in platform.machine(), or am I misunderstanding what
  i386
  means?  platform.architecture() returns ('64bit', '').
 
  Hmmm.  So what's the pythonic way of getting i386 vs. x86_64?
 
  {'32bit': 'i386', '64bit': 'x86_64'}[platform.architecture()[0]]
 
  seems so complicated that there should be a routine for it in sys or
  platform.
 
 I don't know the official way, but what I do is:
 
 % python -c 'import sys;print sys.maxint'
 9223372036854775807
 % env VERSIONER_PYTHON_PREFER_32_BIT=1 python -c 'import sys;print
 sys.maxint'
 2147483647
 
 So I would look at sys.maxint to determine if python is running 32 or
 64-bit.
 
 Ed
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig