How to create a setup.py that consumes a tar file
Question: Our systems people bundle source up in git and do not support pip. The git
repository contains a compressed tar file. And the tar file has a setup.py
within it. I figure the easiest way to expose this in my project is to add a
`-e git...` line to my pip requirements.txt and add a setup.py in the root of
the git repository for pip to use. The last step is how to write a setup.py
that installs a tar file as a source distribution.

    
    
    /package
        /SOURCES
            package.tar.gz
        /SPECS
            site-specific-server-installation-script
    

* * *

In the alternative, I could just get a setup.py that does these things:

    
    
    cd package/SOURCES
    tar xzfv package-1.0.6.tar.gz
    cd package-1.0.6/
    python setup.py
    


Answer: I went with writing a pseudo setup.py file in the root of the git package:

    
    
    import os
    import subprocess
    
    if __name__ == '__main__':
        package_name = 'package'
        short_package_name = 'package-1.0.6'
    
        print "Changing to SOURCES"
        os.chdir('SOURCES')
    
        tar_file = '.'.join([short_package_name, 'tar', 'gz'])
        print "Untarring ", tar_file
        p = subprocess.Popen(['tar', 'xzfv', tar_file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        output, errors = p.communicate()
    
        print "Changing to ", short_package_name
        os.chdir(short_package_name)
    
        print "Setting up source distribution"
        p = subprocess.Popen(['python', 'setup.py', 'install'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        output, errors = p.communicate()
    

It does not use the setup API at all but relies on using the setup.py name to
get invoke at install-time.

* * *

I am reliably informed, however, that easy_install supports installation from
a tar file: 'easy_install SOURCES/source.tar.gz'. So, is there a pip `-e
...git` directive that allows pulling a git repository from git and install
from a nested tar file?

