Commit d5cc8268 authored by jim's avatar jim

Refactored easy_install to use a subprocess. This will be necessary

to be able to use external python interpreters.

Wrote a missing test.


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@68615 62d5b8a3-27da-0310-9561-8e5933582275
parent 8a32066a
......@@ -20,36 +20,13 @@ installed.
$Id$
"""
# XXX needs doctest
import sys
import setuptools.command.easy_install
import pkg_resources
import setuptools.package_index
import distutils.dist
import distutils.log
def install(spec, dest, links=(), **kw):
index = setuptools.package_index.PackageIndex()
index.add_find_links(links)
easy = setuptools.command.easy_install.easy_install(
distutils.dist.Distribution(),
multi_version=True,
exclude_scripts=True,
sitepy_installed=True,
install_dir=dest,
outputs=[],
verbose = 0,
args = [spec],
find_links = links,
**kw
)
easy.finalize_options()
old_warn = distutils.log.warn
distutils.log.warn = lambda *a, **k: None
easy.easy_install(spec, deps=True)
distutils.log.warn = old_warn
import os, sys
def install(spec, dest, links, python=sys.executable):
prefix = sys.exec_prefix + os.path.sep
path = os.pathsep.join([p for p in sys.path if not p.startswith(prefix)])
os.spawnle(
os.P_WAIT, python, python,
'-c', 'from setuptools.command.easy_install import main; main()',
'-mqxd', dest, '-f', ' '.join(links), spec,
dict(PYTHONPATH=path))
Minimal Python interface to easy_install
========================================
The easy_install module provides a minimal interface to the setuptools
easy_install command. This API is likely to grow, although I hope
that it will ultimately be replaced by a setuptools-provided API.
The easy_install module provides a single method, install. The
install function takes 3 arguments:
- A setuptools requirement specification for a distribution to be
installed,
- A destination egg directory to install to and to satisfy
requirements from, and
- a sequence of lications to look for distributions.
For example, given the sample eggs:
>>> ls(sample_eggs)
- demo-0.1-py2.3.egg
- demo-0.2-py2.3.egg
- demo-0.3-py2.3.egg
- demoneeded-1.0-py2.3.egg
let's make directory and install the demo egg to it:
>>> import tempfile
>>> dest = tempfile.mkdtemp()
>>> import zc.buildout.easy_install
>>> zc.buildout.easy_install.install('demo', dest, [sample_eggs])
>>> ls(dest)
- demo-0.3-py2.3.egg
- demoneeded-1.0-py2.3.egg
......@@ -97,7 +97,7 @@ def test_suite():
])
),
doctest.DocFileSuite(
'egglinker.txt',
'egglinker.txt', 'easy_install.txt',
setUp=linkerSetUp, tearDown=linkerTearDown,
checker=renormalizing.RENormalizing([
(re.compile('(\S+[/%(sep)s]| )'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment