Table of Content

Assumed you have multi python on local disk or usb driver, would like to show you how to setup portable dev tools.

1) portable python env

Instead of using virtualenv, I perfect portable instance, but we can do similar thing like virtualenv – setup own dev env, in fact all we need is just to setup python bin and Script at beginning of PATH.

dreamcloud> /usr/local/bin

$ cat mypy3
#!/bin/bash

OLD_PATH="$PATH"
PATH=/portable/PortablePython3.2.5.1/App:/portable/PortablePython3.2.5.1/App/Scripts:$PATH
export OLD_PATH  PATH
export PS1='(portablepython3) \u> \w
$ '

then source the mypy3

$ source mypy3
(portablepython3)
dreamcloud> /usr/local/bin
$ which -a python
/portable/PortablePython3.2.5.1/App/python.exe
/c/Python27/python.exe

undo the env change after finish:

$ cat /usr/local/bin/back
#!/bin/bash

export PATH=$OLD_PATH
unset OLD_PATH
export PS1='\u> \w
$ '

2) install setuptools

this is python installation tool base, you can download ez_setup.py, install it using own python:

$ python ez_setup.py
Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.zip
Extracting in c:\users\xxx\appdata\local\temp\tmpw0vv6l
Now working in c:\users\xxx\appdata\local\temp\tmpw0vv6l\setuptools-7.0
Installing Setuptools


dreamcloud> /portable/PortablePython3.2.5.1/App/Scripts
$ ls -ltr
total 970
drwxr-xr-x 2 xxx Administrators      0 Nov  2  2013 distribute.egg-info
drwxr-xr-x 2 xxx Administrators      0 Nov  2  2013 _markerlib
drwxr-xr-x 3 xxx Administrators      0 Oct 18 11:02 tests
drwxr-xr-x 4 xxx Administrators      0 Oct 18 11:02 setuptools
drwxr-xr-x 5 xxx Administrators      0 Oct 18 11:02 docs
-rwxr-xr-x 1 xxx Administrators  10476 Nov  9 08:55 ez_setup.py
-rw-r--r-- 1 xxx Administrators 846758 Nov  9 08:56 setuptools-7.0.zip
-rw-r--r-- 1 xxx Administrators    647 Nov  9 08:57 easy_install.exe.manifest
-rwxr-xr-x 1 xxx Administrators  65536 Nov  9 08:57 easy_install.exe
-rwxr-xr-x 1 xxx Administrators    370 Nov  9 08:57 easy_install-script.py
-rw-r--r-- 1 xxx Administrators    651 Nov  9 08:57 easy_install-3.2.exe.manifest
-rwxr-xr-x 1 xxx Administrators  65536 Nov  9 08:57 easy_install-3.2.exe
-rwxr-xr-x 1 xxx Administrators    378 Nov  9 08:57 easy_install-3.2-script.py

easy_install.exe is main tool you needed to install any python package.

$ easy_install --help

Global options:
  --verbose (-v)  run verbosely (default)
  --quiet (-q)    run quietly (turns verbosity off)
  --dry-run (-n)  don't actually do anything
  --help (-h)     show detailed help message

Options for 'easy_install' command:
  --prefix                   installation prefix
  --zip-ok (-z)              install package as a zipfile
  --multi-version (-m)       make apps have to require() a version
  --upgrade (-U)             force upgrade (searches PyPI for latest versions)
  --install-dir (-d)         install package to DIR
  --script-dir (-s)          install scripts to DIR
  --exclude-scripts (-x)     Don't install scripts
  --always-copy (-a)         Copy all needed packages to install dir
  --index-url (-i)           base URL of Python Package Index
  --find-links (-f)          additional URL(s) to search for packages
  --build-directory (-b)     download/extract/build in DIR; keep the results
  --optimize (-O)            also compile with optimization: -O1 for "python -
                             O", -O2 for "python -OO", and -O0 to disable
                             [default: -O0]
  --record                   filename in which to record list of installed
                             files
  --always-unzip (-Z)        don't install as a zipfile, no matter what
  --site-dirs (-S)           list of directories where .pth files work
  --editable (-e)            Install specified packages in editable form
  --no-deps (-N)             don't install dependencies
  --allow-hosts (-H)         pattern(s) that hostnames must match
  --local-snapshots-ok (-l)  allow building eggs from local checkouts
  --version                  print version information and exit
  --no-find-links            Don't load find-links defined in packages being
                             installed
  --user                     install in user site-package
                             'C:\Users\xxx\AppData\Roaming\Python\Python32
                             \site-packages'
usage: easy_install-script.py [options] requirement_or_url ...
   or: easy_install-script.py --help

3) pip installation

pip is a python package manager which based on setuptools. We have easy_install why still need pip? easy_install can install/upgrade/uninstall but cannot list local installed packages :)

$ easy_install pip
F:\oldhorse\portableapps\PortablePython3.2.5.1\App\lib\site-packages\setuptools-7.0-py3.2.egg\setuptools\package_index.py:269: UserWarning: Unbuilt
egg for distribute [unknown version] (f:\oldhorse\portableapps\portablepython3.2.5.1\app\scripts)
F:\oldhorse\portableapps\PortablePython3.2.5.1\App\lib\site-packages\setuptools-7.0-py3.2.egg\setuptools\command\easy_install.py:315: UserWarning: Unbuilt egg for distribute [unknown version] (f:\oldhorse\portableapps\portablepython3.2.5.1\app\scripts)
Searching for pip
Reading https://pypi.python.org/simple/pip/
Best match: pip 1.5.6
Downloading https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz#md5=01026f87978932060cc86c1dc527903e
Processing pip-1.5.6.tar.gz

Installed f:\oldhorse\portableapps\portablepython3.2.5.1\app\lib\site-packages\pip-1.5.6-py3.2.egg
Processing dependencies for pip
Finished processing dependencies for pip

$pip list
Exception:
Traceback (most recent call last):
  File "F:\oldhorse\portableapps\PortablePython3.2.5.1\App\lib\site-packages\pip-1.5.6-py3.2.egg\pip\_vendor\pkg_resources.py", line 2259, in version
    return self._version
  File "F:\oldhorse\portableapps\PortablePython3.2.5.1\App\lib\site-packages\pip-1.5.6-py3.2.egg\pip\_vendor\pkg_resources.py", line 2344, in __getattr__
    raise AttributeError(attr)
AttributeError: _version

remedy is simple but indirectly:

$ rm -r distribute.egg-info/
$ easy_install distribute

$ pip list
distribute (0.7.3)
ipython (0.13.1)
lxml (2.3)
matplotlib (1.2.1)
numpy (1.7.1)
pandas (0.11.0)
pip (1.5.6)
pyodbc (3.0.2)
pyreadline (2.0-dev1)
pyserial-py3k (2.5)
pywin32 (218)
scipy (0.12.0)
setuptools (7.0)
wsgiref (0.1.2)

4) yolk installation

$ pip install yolk
Downloading/unpacking yolk
  Running setup.py (path:c:\users\xxx\appdata\local\temp\pip_build_xxx\yolk\setup.py) egg_info for package yolk

the latest yolk release from pypi in fact not works with Python3, print/exception syntax still in Python2.

You have to download yolk develop release from github:
https://github.com/cakebread/yolk

then install it manually:

dreamcloud> /portable/PortablePython3.2.5.1/App/Scripts/yolk-develop
$ python setup.py install
$ yolk -l
distribute      - 0.7.3        - active
ipython         - 0.13.1       - active
lxml            - 2.3          - active
matplotlib      - 1.2.1        - active
numpy           - 1.7.1        - active
pandas          - 0.11.0       - active
pip             - 1.5.6        - active
pyodbc          - 3.0.2        - active
pyreadline      - 2.0-dev1     - active
pywin32         - 218          - active
scipy           - 0.12.0       - active
setuptools      - 7.0          - active
wsgiref         - 0.1.2        - active development (f:\oldhorse\portableapps\portablepython3.2.5.1\app\lib)
yolk            - 0.4.3        - non-active
yolk            - 0.4.3        - non-active
yolk            - 0.4.3        - active
yolk            - 0.4.3        - active