Links
- TODO
- I currently install a custom (idempotent and
identical)
/Library/Python/2.7/site-packages/sitecustomize.py
,/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sitecustomize.py
, etc. in every installation on every platform.- Switch to using
usercustomize.py
andsitecustomize.py
- This will break python 2.4 compatibility
- Switch to using
- I currently install a custom (idempotent and
identical)
- distutils
- Environment variables
- pymotw: sysconfig – Interpreter Compile-time Configuration
- site module
- addsitedir
- For OS X, a usercustomize.py in the Framework
user dir (
/Users/chirayu/Library/Python/2.7
) toaddsitedir()
~/.local
(verify is this can also set USER_SITE to~/.local/lib/python2.7/site-packages
) may be the way to go to reconcile the two different user site paths.
- For OS X, a usercustomize.py in the Framework
user dir (
- PYTHONUSERBASE
- addsitedir
- user installation scheme
- PEP 370 – Per user site-packages directory
- Running code at Python startup
- pymotw: Modules and Imports
- pymotw: site
- pymotw: Python Runtime Services
- User (root/sudo free) installation of Python modules.
- What's the proper way to install pip, virtualenv, and distribute for Python?
- NO. NEVER EVER do 'sudo python setup.py install'
whatever. Write a
~/.pydistutils.cfg
that puts your pip installation into~/.local
or something. Especially files named'ez_setup.py'
tend to suck down newer versions of things like setuptools and easy_install, which can potentially break other things on your operating system. – Glyph
- NO. NEVER EVER do 'sudo python setup.py install'
whatever. Write a
Bag
# What is sys.path, user base and user site? Is user # site enabled? # % python -m site # That pretty prints sys.path, USER_BASE, USER_SITE and # if it's enabled. # Where is the user library location import site print site.USER_BASE # Prints: /Users/chirayu/Library/Python/2.7 # Where is the user site-packages location print site.USER_SITE # Prints: /Users/chirayu/Library/Python/2.7/lib/python/site-packages # OR # # % python -m site --user-base # /Users/chirayu/Library/Python/2.7 # % python -m site --user-site # /Users/chirayu/Library/Python/2.7/lib/python/site-packages # What is the platform? # The preferred way is sysconfig.get_platform() which # can fallback to platform.platform() – but they do have # different return values. # # >>> sysconfig.get_platform() # 'macosx-10.7-x86_64' # >>> platform.platform() # 'Darwin-11.3.0-x86_64-i386-64bit' # What options were used to build this python? pprint.pprint(sysconfig.get_config_vars())