[Checkins] SVN: zc.buildout/trunk/src/zc/buildout/ Refactored
easy_install to use a subprocess. This will be necessary
Jim Fulton
jim at zope.com
Tue Jun 13 10:54:26 EDT 2006
Log message for revision 68615:
Refactored easy_install to use a subprocess. This will be necessary
to be able to use external python interpreters.
Wrote a missing test.
Changed:
U zc.buildout/trunk/src/zc/buildout/easy_install.py
A zc.buildout/trunk/src/zc/buildout/easy_install.txt
U zc.buildout/trunk/src/zc/buildout/tests.py
-=-
Modified: zc.buildout/trunk/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/easy_install.py 2006-06-13 13:20:44 UTC (rev 68614)
+++ zc.buildout/trunk/src/zc/buildout/easy_install.py 2006-06-13 14:54:25 UTC (rev 68615)
@@ -20,36 +20,13 @@
$Id$
"""
-# XXX needs doctest
+import os, sys
-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
-
+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))
Added: zc.buildout/trunk/src/zc/buildout/easy_install.txt
===================================================================
--- zc.buildout/trunk/src/zc/buildout/easy_install.txt 2006-06-13 13:20:44 UTC (rev 68614)
+++ zc.buildout/trunk/src/zc/buildout/easy_install.txt 2006-06-13 14:54:25 UTC (rev 68615)
@@ -0,0 +1,36 @@
+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
+
Property changes on: zc.buildout/trunk/src/zc/buildout/easy_install.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: zc.buildout/trunk/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/tests.py 2006-06-13 13:20:44 UTC (rev 68614)
+++ zc.buildout/trunk/src/zc/buildout/tests.py 2006-06-13 14:54:25 UTC (rev 68615)
@@ -97,7 +97,7 @@
])
),
doctest.DocFileSuite(
- 'egglinker.txt',
+ 'egglinker.txt', 'easy_install.txt',
setUp=linkerSetUp, tearDown=linkerTearDown,
checker=renormalizing.RENormalizing([
(re.compile('(\S+[/%(sep)s]| )'
More information about the Checkins
mailing list