How to get VirtualEnv to use a custom version of setuptools?

The large corporation I work with uses a custom version of Setuptools. This private setuptools plug is designed to solve specific network and security issues that are unique to our organization. The bottom line is that neither the standard Setuptools nor Distribute will work as expected in our environment.

I like to use Ian Bicking's excellent VirtualEnv tool for systems, especially in our test systems, where we need to set up a large number of isolated areas for test code - for example, in our continuous integration environment.

Unfortunately, when I try to create a new virtual environment, the virtualenv tool tries to get and install the latest version of the official version of Setuptools. This is not for the reasons stated above, but also because the corporate firewall has blocked the action.

Instead of installing the official version:

setuptools-0.6c11-py2.4.egg

I would like to install our custom version, which can be called something like:

setuptools-foo-0.6c11-py2.4.egg

This egg can always be guaranteed to be found in system global site packages. I can also guarantee that it is present on all of our corporate servers.

Can you help me make my virtualenv use my customized setuptools instead of the regular version of setuptools.

+3
source share
3 answers

virtualenv.py. virtualenv.py, setuptools egg setuppools-0.6c11-py2.4.egg '

+2

-, virtualenv. , dpkgs , distribute, - , .

, . , - symlink/ setuptools virtualenv:

import os, subprocess, sys, virtualenv

# virtualenv changed its internal api slightly after 1.5. 
NEW_API = (1, 5)

def get_version(version):
    return tuple([int(v) for v in version.split('.')])

def main():
    # set the logging level here
    level = virtualenv.Logger.level_for_integer(0)
    logger = virtualenv.Logger([(level, sys.stdout)])
    virtualenv.logger = logger

    # insert your command-line parsing code here, if needed
    root = sys.argv[1]

    home, lib, inc, bin = virtualenv.path_locations(root)
    result = virtualenv.install_python(home, lib, inc, bin,
            site_packages=True, clear=False)
    pyexec = os.path.abspath(result)
    version = get_version(virtualenv.virtualenv_version)
    if version < NEW_API:
        virtualenv.install_distutils(lib, home)
    else:
        virtualenv.install_distutils(home)
    virtualenv.install_activate(home, bin)

    # insert whatever post-virtualenv-setup code you need here 

if __name__ == '__main__':
    main()

:

% python wrapper.py [path]
+1

--extra-search-dir, , setuptools. docs.

0

All Articles