[Distutils] Can't count on -S to get a clean Python (at least on mac)

Ned Deily nad at acm.org
Sat Apr 7 22:46:07 CEST 2012


In article 
<CAPDm-FiEKjVoU=x7gMY8WDLsK0pHw=DD7rE8o7kvW=10Mk2qiw at mail.gmail.com>,
 Jim Fulton <jim at zope.com> wrote:

> On my mac (Snow Leopard):
> 
> $ which python
> /usr/bin/python
> 
> $ python -S
> Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
> [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
> >>> import setuptools
> >>> setuptools.__file__
> '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/se
> tuptools/__init__.pyc'
> >>> import os
> >>> os.listdir('/System/Library/Frameworks/Python.framework/Versions/2.6/Extra
> >>> s/lib/python')
> ['altgraph', 'altgraph-0.6.8.dev-py2.6.egg-info', 'bdist_mpkg',
> 'bdist_mpkg-0.4.3.dev-py2.6.egg-info', 'bonjour',
> 'bonjour_py-0.3-py2.6.egg-info', 'CoreGraphics', 'dateutil',
> 'easy_install.py', 'easy_install.pyc', 'ez_setup', 'fetchmailconf.py',
> 'fetchmailconf.pyc', 'fetchmailconf.pyo', 'libsvn', 'macholib',
> 'macholib-1.2.1.dev-py2.6.egg-info', 'modulegraph',
> 'modulegraph-0.7.2.dev-py2.6.egg-info', 'numpy',
> 'numpy-1.2.1-py2.6.egg-info', 'OpenSSL', 'pkg_resources.py',
> 'pkg_resources.pyc', 'py2app', 'py2app-0.4.2-py2.6.egg-info',
> 'PyObjC', 'PyObjC.pth', 'pyOpenSSL-0.7-py2.6.egg-info',
> 'PyRSS2Gen-1.0.0-py2.6.egg-info', 'PyRSS2Gen.py', 'PyRSS2Gen.pyc',
> 'python_dateutil-1.2-py2.6.egg-info', 'setuptools',
> 'setuptools-0.6c9-py2.6.egg-info', 'site.py', 'site.pyc', 'site.pyo',
> 'svn', 'twisted', 'Twisted-8.2.0-py2.6.egg-info',
> 'wx-2.8-mac-unicode', 'wx.pth', 'wxaddons',
> 'wxaddons-2.8.8.1-py2.6.egg-info',
> 'wxPython_common-2.8.8.1-py2.6.egg-info', 'wxversion.py',
> 'wxversion.pyc', 'xattr', 'xattr-0.5-py2.6.egg-info', 'zope',
> 'zope.interface-3.5.1-py2.6.egg-info']
> 
> whimper
> 
> I get something similar on a Lion machine.
> 
> I haven't been able to reproduce this lamosity on any linux systems.

Blame it on Apple's modifications to the system Pythons and the 
setuptools they supply in OS X.  The third-party packages they supply 
with the system Python are not installed in the same directory where 
user-installed site-packages go, for instance.

You won't see this behavior with the Pythons for OS X installed from 
python.org:

$ /usr/local/bin/python2.7
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import setuptools
>>> setuptools.__file__
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-pac
kages/distribute-0.6.24-py2.7.egg/setuptools/__init__.pyc'
>>> ^D
$ /usr/local/bin/python2.7 -S
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
>>> import setuptools
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named setuptools
>>> ^D

-- 
 Ned Deily,
 nad at acm.org



More information about the Distutils-SIG mailing list