Namespaces

Variants
Actions
Personal tools

Python

From UABgrid Documentation

Jump to: navigation, search

Contents


Python

  • EasyInstall (a python module (easy_install)) is bundled with setuptools to automatically download, build, install, and manage Python packages [1].
  • To have a complete Python development environment (install plugins, apps, eggs) in your $HOME, python path must be configured properly.
  • Default installation of EasyInstall/setuptools would install packages/eggs to the Python’s primary site-packages directory

Mac OS X

Custom Installation of Python Packages

  • Mac OS X comes with a pre-installation of Python, usually one or two years old [2]. Mac OS 10.6 (Snow Leopard) has 2.6.1 version of Python. This is adequate for developing most Python applications like Trac, Galaxy etc. To install a newer version of Python, [see here].
  • The default installation location for Python packages on Mac is /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages.
  • Mac has native support for user installation of Python packages i.e., on a Mac OS X machine, you should just use the ~/Library/Python/2.x/site-packages directory as your custom installation location, because it is already configured to process .pth files, and already knows this [3]. If the above directory does not exist in your $HOME, create it.
mkdir -p ~/Library/Python/2.6/site-packages
  • Before installing EasyInstall/setuptools, just create a ~/.pydistutils.cfg file with the following contents (or add this to the existing contents):
[install]
install_lib = ~/Library/Python/$py_version_short/site-packages
install_scripts = ~/bin
  • This will tell the distutils and EasyInstall to always install packages in your personal site-packages directory, and scripts to ~/bin. (Note: do not replace $py_version_short with an actual Python version in the configuration file! The distutils will substitute the correct value at runtime, so that the above configuration file should work correctly no matter what Python version you use, now or in the future.)
  • Note, however, that ~/bin is not in the default PATH, so you may have to refer to scripts by their full location. You may want to modify your shell startup script (likely .bashrc or .profile) or your ~/.MacOSX/environment.plist to include ~/bin in your PATH.

Setuptools Installation

$ cd ~/Library/Python/2.6/site-packages/

wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086
  • Make the setuptools package executable
chmod +x setuptools-0.6c11-py2.6.egg
  • Run setuptools as a shell script. This will install easy_install to ~/bin
sh setuptools-0.6c11-py2.6.egg

References