cyaninc/git-fat — pull request #3 by d9frog9n (2014-01-07 23:40:58+00:00)
Title: Running git-fat under custom isolated envs

TLDR
--------
This pull requests applying a patch in installation run-time, which provides access to `git_fat` package sources from `git-fat` script anytime with any `$PYTHONPATH`/`$PYTHONHOME` configuration.

Problem
------------
By default `pip install` places sources of installed packages under `/usr/local/lib/pythonX.X/dist-packages` and scripts under `/usr/local/bin` at Debian-based distros. In some cases for custom envs, which manipulates `$PYTHONPATH`/`$PYTHONHOME` or in mutli-pythonic configurations, sources from dist-packages unavailable and `git-fat` fails with `ImportError`.

Lets follows step-by-step:

$ sudo pip install git-fat==0.2.2
$ git-fat
usage: git-fat [global options] command [command options]
git-fat -h for full usage.
git-fat: error: too few arguments
$ whereis git-fat
git-fat: /usr/local/bin/git-fat
$ python -c 'import git_fat;print(git_fat.__file__)'
/usr/local/lib/python2.7/dist-packages/git_fat/__init__.pyc

Works. Now creating a simple env:

$ echo "export PYTHONHOME=/opt/cyan/cyms-base-py27
export PYTHONPATH=/opt/cyan/cyms-base-py27/lib/python2.7/site-packages/" > env.sh
$ source env.sh
$ git-fat
Traceback (most recent call last):
File "/usr/local/bin/git-fat", line 3, in
from git_fat import main
ImportError: No module named git_fat

Reverting system

$ unset PYTHONPATH
$ unset PYTHONHOME
$ sudo pip uninstall -y git-fat

Solution
-----------

Installing `git-fat` version with described fix:

$ sudo pip install ./git-fat
$ git-fat
usage: git-fat [global options] command [command options]
git-fat -h for full usage.
git-fat: error: too few arguments
$ source env.sh
$ git-fat
usage: git-fat [global options] command [command options]
git-fat -h for full usage.
git-fat: error: too few arguments

But env is still isolated as expected:

$ python -c 'import git_fat'
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named git_fat
$ unset PYTHONHOME
$ unset PYTHONPATH
$ python -c 'import git_fat;print("Ok")'
Ok