Commit c32aa1b2 authored by Jim Fulton's avatar Jim Fulton

Removed multi-python support

parent b00423b2
...@@ -113,8 +113,6 @@ _buildout_default_options = _annotate_section({ ...@@ -113,8 +113,6 @@ _buildout_default_options = _annotate_section({
'bin-directory': 'bin', 'bin-directory': 'bin',
'parts-directory': 'parts', 'parts-directory': 'parts',
'installed': '.installed.cfg', 'installed': '.installed.cfg',
'python': 'buildout',
'executable': sys.executable,
'log-level': 'INFO', 'log-level': 'INFO',
'log-format': '', 'log-format': '',
}, 'DEFAULT_VALUE') }, 'DEFAULT_VALUE')
......
...@@ -739,8 +739,6 @@ COMMAND_LINE_VALUE). ...@@ -739,8 +739,6 @@ COMMAND_LINE_VALUE).
COMPUTED_VALUE COMPUTED_VALUE
eggs-directory= eggs eggs-directory= eggs
DEFAULT_VALUE DEFAULT_VALUE
executable= ...
DEFAULT_VALUE
installed= .installed.cfg installed= .installed.cfg
DEFAULT_VALUE DEFAULT_VALUE
log-format= log-format=
...@@ -751,8 +749,6 @@ COMMAND_LINE_VALUE). ...@@ -751,8 +749,6 @@ COMMAND_LINE_VALUE).
/sample-buildout/buildout.cfg /sample-buildout/buildout.cfg
parts-directory= parts parts-directory= parts
DEFAULT_VALUE DEFAULT_VALUE
python= buildout
DEFAULT_VALUE
<BLANKLINE> <BLANKLINE>
[data-dir] [data-dir]
path= foo bins path= foo bins
...@@ -2209,7 +2205,6 @@ database is shown. ...@@ -2209,7 +2205,6 @@ database is shown.
develop-eggs-directory = /sample-buildout/develop-eggs develop-eggs-directory = /sample-buildout/develop-eggs
directory = /sample-buildout directory = /sample-buildout
eggs-directory = /sample-buildout/eggs eggs-directory = /sample-buildout/eggs
executable = /usr/local/bin/python2.3
installed = /sample-buildout/.installed.cfg installed = /sample-buildout/.installed.cfg
log-format = log-format =
log-level = INFO log-level = INFO
...@@ -2217,7 +2212,6 @@ database is shown. ...@@ -2217,7 +2212,6 @@ database is shown.
offline = false offline = false
parts = parts =
parts-directory = /sample-buildout/parts parts-directory = /sample-buildout/parts
python = buildout
verbosity = 20 verbosity = 20
<BLANKLINE> <BLANKLINE>
...@@ -2245,10 +2239,6 @@ eggs-directory ...@@ -2245,10 +2239,6 @@ eggs-directory
*never* be modified. This can be a relative path, which is *never* be modified. This can be a relative path, which is
interpreted relative to the directory option. interpreted relative to the directory option.
executable
The Python executable used to run the buildout. See the python
option below.
installed installed
The file path where information about the results of the previous The file path where information about the results of the previous
buildout run is written. This can be a relative path, which is buildout run is written. This can be a relative path, which is
...@@ -2268,16 +2258,6 @@ parts ...@@ -2268,16 +2258,6 @@ parts
parts-directory parts-directory
A working directory that parts can used to store data. A working directory that parts can used to store data.
python
The name of a section containing information about the default
Python interpreter. Recipes that need a installation
typically have options to tell them which Python installation to
use. By convention, if a section-specific option isn't used, the
option is looked for in the buildout section. The option must
point to a section with an executable option giving the path to a
Python executable. By default, the buildout section defines the
default Python as the Python used to run the buildout.
verbosity verbosity
A log-level adjustment. Typically, this is set via the -q and -v A log-level adjustment. Typically, this is set via the -q and -v
command-line options. command-line options.
......
...@@ -72,31 +72,8 @@ class IncompatibleVersionError(zc.buildout.UserError): ...@@ -72,31 +72,8 @@ class IncompatibleVersionError(zc.buildout.UserError):
"""A specified version is incompatible with a given requirement. """A specified version is incompatible with a given requirement.
""" """
_versions = {sys.executable: '%d.%d' % sys.version_info[:2]}
def _get_version(executable):
try:
return _versions[executable]
except KeyError:
cmd = executable + ' -V'
p = subprocess.Popen(cmd,
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
close_fds=not is_win32)
i, o = (p.stdin, p.stdout)
i.close()
version = o.read().strip()
o.close()
pystring, version = version.split()
assert pystring == 'Python'
version = re.match('(\d[.]\d)([.].*\d)?$', version).group(1)
_versions[executable] = version
return version
FILE_SCHEME = re.compile('file://', re.I).match FILE_SCHEME = re.compile('file://', re.I).match
class AllowHostsPackageIndex(setuptools.package_index.PackageIndex): class AllowHostsPackageIndex(setuptools.package_index.PackageIndex):
"""Will allow urls that are local to the system. """Will allow urls that are local to the system.
...@@ -109,17 +86,15 @@ class AllowHostsPackageIndex(setuptools.package_index.PackageIndex): ...@@ -109,17 +86,15 @@ class AllowHostsPackageIndex(setuptools.package_index.PackageIndex):
_indexes = {} _indexes = {}
def _get_index(executable, index_url, find_links, allow_hosts=('*',)): def _get_index(index_url, find_links, allow_hosts=('*',)):
key = executable, index_url, tuple(find_links) key = index_url, tuple(find_links)
index = _indexes.get(key) index = _indexes.get(key)
if index is not None: if index is not None:
return index return index
if index_url is None: if index_url is None:
index_url = default_index_url index_url = default_index_url
index = AllowHostsPackageIndex( index = AllowHostsPackageIndex(index_url, hosts=allow_hosts)
index_url, hosts=allow_hosts, python=_get_version(executable)
)
if find_links: if find_links:
index.add_find_links(find_links) index.add_find_links(find_links)
...@@ -167,6 +142,7 @@ class Installer: ...@@ -167,6 +142,7 @@ class Installer:
use_dependency_links=None, use_dependency_links=None,
allow_hosts=('*',) allow_hosts=('*',)
): ):
assert executable == sys.executable, (executable, sys.executable)
self._dest = dest self._dest = dest
self._allow_hosts = allow_hosts self._allow_hosts = allow_hosts
...@@ -184,7 +160,6 @@ class Installer: ...@@ -184,7 +160,6 @@ class Installer:
links.insert(0, self._download_cache) links.insert(0, self._download_cache)
self._index_url = index self._index_url = index
self._executable = executable
if always_unzip is not None: if always_unzip is not None:
self._always_unzip = always_unzip self._always_unzip = always_unzip
path = (path and path[:] or []) + buildout_and_setuptools_path path = (path and path[:] or []) + buildout_and_setuptools_path
...@@ -194,9 +169,8 @@ class Installer: ...@@ -194,9 +169,8 @@ class Installer:
if self._dest is None: if self._dest is None:
newest = False newest = False
self._newest = newest self._newest = newest
self._env = pkg_resources.Environment(path, self._env = pkg_resources.Environment(path)
python=_get_version(executable)) self._index = _get_index(index, links, self._allow_hosts)
self._index = _get_index(executable, index, links, self._allow_hosts)
if versions is not None: if versions is not None:
self._versions = versions self._versions = versions
...@@ -291,10 +265,7 @@ class Installer: ...@@ -291,10 +265,7 @@ class Installer:
return best_we_have, None return best_we_have, None
def _load_dist(self, dist): def _load_dist(self, dist):
dists = pkg_resources.Environment( dists = pkg_resources.Environment(dist.location)[dist.project_name]
dist.location,
python=_get_version(self._executable),
)[dist.project_name]
assert len(dists) == 1 assert len(dists) == 1
return dists[0] return dists[0]
...@@ -304,7 +275,7 @@ class Installer: ...@@ -304,7 +275,7 @@ class Installer:
try: try:
path = setuptools_loc path = setuptools_loc
args = [self._executable, '-c', _easy_install_cmd, '-mUNxd', tmp] args = [sys.executable, '-c', _easy_install_cmd, '-mUNxd', tmp]
if self._always_unzip: if self._always_unzip:
args.append('-Z') args.append('-Z')
level = logger.getEffectiveLevel() level = logger.getEffectiveLevel()
...@@ -316,8 +287,8 @@ class Installer: ...@@ -316,8 +287,8 @@ class Installer:
args.append(spec) args.append(spec)
if level <= logging.DEBUG: if level <= logging.DEBUG:
logger.debug('Running easy_install:\n%s "%s"\npath=%s\n', logger.debug('Running easy_install:\n"%s"\npath=%s\n',
self._executable, '" "'.join(args), path) '" "'.join(args), path)
sys.stdout.flush() # We want any pending output first sys.stdout.flush() # We want any pending output first
...@@ -326,10 +297,7 @@ class Installer: ...@@ -326,10 +297,7 @@ class Installer:
env=dict(os.environ, PYTHONPATH=path)) env=dict(os.environ, PYTHONPATH=path))
dists = [] dists = []
env = pkg_resources.Environment( env = pkg_resources.Environment([tmp])
[tmp],
python=_get_version(self._executable),
)
for project in env: for project in env:
dists.extend(env[project]) dists.extend(env[project])
...@@ -373,10 +341,7 @@ class Installer: ...@@ -373,10 +341,7 @@ class Installer:
os.remove(newloc) os.remove(newloc)
os.rename(d.location, newloc) os.rename(d.location, newloc)
[d] = pkg_resources.Environment( [d] = pkg_resources.Environment([newloc])[d.project_name]
[newloc],
python=_get_version(self._executable),
)[d.project_name]
result.append(d) result.append(d)
...@@ -525,10 +490,8 @@ class Installer: ...@@ -525,10 +490,8 @@ class Installer:
# Getting the dist from the environment causes the # Getting the dist from the environment causes the
# distribution meta data to be read. Cloning isn't # distribution meta data to be read. Cloning isn't
# good enough. # good enough.
dists = pkg_resources.Environment( dists = pkg_resources.Environment([newloc])[
[newloc], dist.project_name]
python=_get_version(self._executable),
)[dist.project_name]
else: else:
# It's some other kind of dist. We'll let easy_install # It's some other kind of dist. We'll let easy_install
# deal with it: # deal with it:
...@@ -558,8 +521,7 @@ class Installer: ...@@ -558,8 +521,7 @@ class Installer:
if link not in self._links: if link not in self._links:
logger.debug('Adding find link %r from %s', link, dist) logger.debug('Adding find link %r from %s', link, dist)
self._links.append(link) self._links.append(link)
self._index = _get_index(self._executable, self._index = _get_index(self._index_url, self._links,
self._index_url, self._links,
self._allow_hosts) self._allow_hosts)
for dist in dists: for dist in dists:
...@@ -787,7 +749,9 @@ def install(specs, dest, ...@@ -787,7 +749,9 @@ def install(specs, dest,
executable=sys.executable, always_unzip=None, executable=sys.executable, always_unzip=None,
path=None, working_set=None, newest=True, versions=None, path=None, working_set=None, newest=True, versions=None,
use_dependency_links=None, allow_hosts=('*',)): use_dependency_links=None, allow_hosts=('*',)):
installer = Installer(dest, links, index, executable, always_unzip, path, assert executable == sys.executable, (executable, sys.executable)
installer = Installer(dest, links, index, sys.executable,
always_unzip, path,
newest, versions, use_dependency_links, newest, versions, use_dependency_links,
allow_hosts=allow_hosts) allow_hosts=allow_hosts)
return installer.install(specs, working_set) return installer.install(specs, working_set)
...@@ -797,7 +761,9 @@ def build(spec, dest, build_ext, ...@@ -797,7 +761,9 @@ def build(spec, dest, build_ext,
links=(), index=None, links=(), index=None,
executable=sys.executable, executable=sys.executable,
path=None, newest=True, versions=None, allow_hosts=('*',)): path=None, newest=True, versions=None, allow_hosts=('*',)):
installer = Installer(dest, links, index, executable, True, path, newest, assert executable == sys.executable, (executable, sys.executable)
installer = Installer(dest, links, index, sys.executable,
True, path, newest,
versions, allow_hosts=allow_hosts) versions, allow_hosts=allow_hosts)
return installer.build(spec, build_ext) return installer.build(spec, build_ext)
...@@ -828,7 +794,7 @@ def _copyeggs(src, dest, suffix, undo): ...@@ -828,7 +794,7 @@ def _copyeggs(src, dest, suffix, undo):
def develop(setup, dest, def develop(setup, dest,
build_ext=None, build_ext=None,
executable=sys.executable): executable=sys.executable):
assert executable == sys.executable, (executable, sys.executable)
if os.path.isdir(setup): if os.path.isdir(setup):
directory = setup directory = setup
setup = os.path.join(directory, 'setup.py') setup = os.path.join(directory, 'setup.py')
...@@ -866,7 +832,7 @@ def develop(setup, dest, ...@@ -866,7 +832,7 @@ def develop(setup, dest,
tmp3 = tempfile.mkdtemp('build', dir=dest) tmp3 = tempfile.mkdtemp('build', dir=dest)
undo.append(lambda : shutil.rmtree(tmp3)) undo.append(lambda : shutil.rmtree(tmp3))
args = [executable, tsetup, '-q', 'develop', '-mxN', '-d', tmp3] args = [sys.executable, tsetup, '-q', 'develop', '-mxN', '-d', tmp3]
log_level = logger.getEffectiveLevel() log_level = logger.getEffectiveLevel()
if log_level <= 0: if log_level <= 0:
...@@ -886,10 +852,15 @@ def develop(setup, dest, ...@@ -886,10 +852,15 @@ def develop(setup, dest,
[f() for f in undo] [f() for f in undo]
def working_set(specs, executable, path): def working_set(specs, executable, path=None):
return install(specs, None, executable=executable, path=path) # Backward compat:
if path is None:
path = executable
else:
assert executable == sys.executable, (executable, sys.executable)
return install(specs, None, path=path)
def scripts(reqs, working_set, executable, dest, def scripts(reqs, working_set, executable, dest=None,
scripts=None, scripts=None,
extra_paths=(), extra_paths=(),
arguments='', arguments='',
...@@ -897,6 +868,7 @@ def scripts(reqs, working_set, executable, dest, ...@@ -897,6 +868,7 @@ def scripts(reqs, working_set, executable, dest,
initialization='', initialization='',
relative_paths=False, relative_paths=False,
): ):
assert executable == sys.executable, (executable, sys.executable)
path = [dist.location for dist in working_set] path = [dist.location for dist in working_set]
path.extend(extra_paths) path.extend(extra_paths)
...@@ -942,14 +914,14 @@ def scripts(reqs, working_set, executable, dest, ...@@ -942,14 +914,14 @@ def scripts(reqs, working_set, executable, dest,
spath, rpsetup = _relative_path_and_setup(sname, path, relative_paths) spath, rpsetup = _relative_path_and_setup(sname, path, relative_paths)
generated.extend( generated.extend(
_script(module_name, attrs, spath, sname, executable, arguments, _script(module_name, attrs, spath, sname, arguments,
initialization, rpsetup) initialization, rpsetup)
) )
if interpreter: if interpreter:
sname = os.path.join(dest, interpreter) sname = os.path.join(dest, interpreter)
spath, rpsetup = _relative_path_and_setup(sname, path, relative_paths) spath, rpsetup = _relative_path_and_setup(sname, path, relative_paths)
generated.extend(_pyscript(spath, sname, executable, rpsetup)) generated.extend(_pyscript(spath, sname, rpsetup))
return generated return generated
...@@ -1014,15 +986,14 @@ join = os.path.join ...@@ -1014,15 +986,14 @@ join = os.path.join
base = os.path.dirname(os.path.abspath(os.path.realpath(__file__))) base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
""" """
def _script(module_name, attrs, path, dest, executable, arguments, def _script(module_name, attrs, path, dest, arguments, initialization, rsetup):
initialization, rsetup):
generated = [] generated = []
script = dest script = dest
if is_win32: if is_win32:
dest += '-script.py' dest += '-script.py'
contents = script_template % dict( contents = script_template % dict(
python = _safe_arg(executable), python = _safe_arg(sys.executable),
path = path, path = path,
module_name = module_name, module_name = module_name,
attrs = attrs, attrs = attrs,
...@@ -1074,14 +1045,14 @@ if __name__ == '__main__': ...@@ -1074,14 +1045,14 @@ if __name__ == '__main__':
''' '''
def _pyscript(path, dest, executable, rsetup): def _pyscript(path, dest, rsetup):
generated = [] generated = []
script = dest script = dest
if is_win32: if is_win32:
dest += '-script.py' dest += '-script.py'
contents = py_script_template % dict( contents = py_script_template % dict(
python = _safe_arg(executable), python = _safe_arg(sys.executable),
path = path, path = path,
relative_paths_setup = rsetup, relative_paths_setup = rsetup,
) )
......
...@@ -53,10 +53,6 @@ index ...@@ -53,10 +53,6 @@ index
we'll just point to an empty directory on our link server. This we'll just point to an empty directory on our link server. This
will make our examples run a little bit faster. will make our examples run a little bit faster.
executable
A path to a Python executable. Distributions will be installed
using this executable and will be for the matching Python version.
path path
A list of additional directories to search for locally-installed A list of additional directories to search for locally-installed
distributions. distributions.
...@@ -547,7 +543,7 @@ from the demo egg: ...@@ -547,7 +543,7 @@ from the demo egg:
>>> scripts = zc.buildout.easy_install.scripts( >>> scripts = zc.buildout.easy_install.scripts(
... ['demo'], ws, sys.executable, bin) ... ['demo'], ws, sys.executable, bin)
the four arguments we passed were: the three arguments we passed were:
1. A sequence of distribution requirements. These are of the same 1. A sequence of distribution requirements. These are of the same
form as setuptools requirements. Here we passed a single form as setuptools requirements. Here we passed a single
...@@ -555,8 +551,6 @@ the four arguments we passed were: ...@@ -555,8 +551,6 @@ the four arguments we passed were:
2. A working set, 2. A working set,
3. The Python executable to use, and
3. The destination directory. 3. The destination directory.
The bin directory now contains a generated script: The bin directory now contains a generated script:
...@@ -582,7 +576,7 @@ interpreter and without having to provide a '.py' suffix. ...@@ -582,7 +576,7 @@ interpreter and without having to provide a '.py' suffix.
The demo script run the entry point defined in the demo egg: The demo script run the entry point defined in the demo egg:
>>> cat(bin, 'demo') # doctest: +NORMALIZE_WHITESPACE >>> cat(bin, 'demo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
<BLANKLINE> <BLANKLINE>
import sys import sys
sys.path[0:0] = [ sys.path[0:0] = [
...@@ -615,11 +609,11 @@ For example, we could have passed entry point information directly ...@@ -615,11 +609,11 @@ For example, we could have passed entry point information directly
rather than passing a requirement: rather than passing a requirement:
>>> scripts = zc.buildout.easy_install.scripts( >>> scripts = zc.buildout.easy_install.scripts(
... [('demo', 'eggrecipedemo', 'main')], ... [('demo', 'eggrecipedemo', 'main')], ws,
... ws, sys.executable, bin) ... sys.executable, bin)
>>> cat(bin, 'demo') # doctest: +NORMALIZE_WHITESPACE >>> cat(bin, 'demo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
<BLANKLINE> <BLANKLINE>
import sys import sys
sys.path[0:0] = [ sys.path[0:0] = [
...@@ -663,7 +657,7 @@ The py script simply runs the Python interactive interpreter with ...@@ -663,7 +657,7 @@ The py script simply runs the Python interactive interpreter with
the path set: the path set:
>>> cat(bin, 'py') # doctest: +NORMALIZE_WHITESPACE >>> cat(bin, 'py') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
<BLANKLINE> <BLANKLINE>
import sys import sys
<BLANKLINE> <BLANKLINE>
...@@ -723,7 +717,7 @@ original script names to new script names. ...@@ -723,7 +717,7 @@ original script names to new script names.
>>> bin = tmpdir('bin2') >>> bin = tmpdir('bin2')
>>> scripts = zc.buildout.easy_install.scripts( >>> scripts = zc.buildout.easy_install.scripts(
... ['demo'], ws, sys.executable, bin, dict(demo='run')) ... ['demo'], ws, sys.executable, bin, dict(demo='run'))
>>> if sys.platform == 'win32': >>> if sys.platform == 'win32':
... scripts == [os.path.join(bin, 'run.exe'), ... scripts == [os.path.join(bin, 'run.exe'),
...@@ -749,7 +743,7 @@ to be included in the a generated script: ...@@ -749,7 +743,7 @@ to be included in the a generated script:
... extra_paths=[foo]) ... extra_paths=[foo])
>>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE >>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
<BLANKLINE> <BLANKLINE>
import sys import sys
sys.path[0:0] = [ sys.path[0:0] = [
...@@ -775,7 +769,7 @@ parentheses in the call: ...@@ -775,7 +769,7 @@ parentheses in the call:
... arguments='1, 2') ... arguments='1, 2')
>>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE >>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
import sys import sys
sys.path[0:0] = [ sys.path[0:0] = [
'/sample-install/demo-0.3-py2.4.egg', '/sample-install/demo-0.3-py2.4.egg',
...@@ -798,7 +792,7 @@ You can also pass script initialization code: ...@@ -798,7 +792,7 @@ You can also pass script initialization code:
... initialization='import os\nos.chdir("foo")') ... initialization='import os\nos.chdir("foo")')
>>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE >>> cat(bin, 'run') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
import sys import sys
sys.path[0:0] = [ sys.path[0:0] = [
'/sample-install/demo-0.3-py2.4.egg', '/sample-install/demo-0.3-py2.4.egg',
...@@ -838,7 +832,7 @@ to pass a common base directory of the scripts and eggs: ...@@ -838,7 +832,7 @@ to pass a common base directory of the scripts and eggs:
... relative_paths=bo) ... relative_paths=bo)
>>> cat(bo, 'bin', 'run') >>> cat(bo, 'bin', 'run')
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
<BLANKLINE> <BLANKLINE>
import os import os
<BLANKLINE> <BLANKLINE>
...@@ -870,7 +864,7 @@ Of course, running the script works: ...@@ -870,7 +864,7 @@ Of course, running the script works:
We specified an interpreter and its paths are adjusted too: We specified an interpreter and its paths are adjusted too:
>>> cat(bo, 'bin', 'py') >>> cat(bo, 'bin', 'py')
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
<BLANKLINE> <BLANKLINE>
import os import os
<BLANKLINE> <BLANKLINE>
...@@ -950,10 +944,6 @@ index ...@@ -950,10 +944,6 @@ index
we'll just point to an empty directory on our link server. This we'll just point to an empty directory on our link server. This
will make our examples run a little bit faster. will make our examples run a little bit faster.
executable
A path to a Python executable. Distributions will be installed
using this executable and will be for the matching Python version.
path path
A list of additional directories to search for locally-installed A list of additional directories to search for locally-installed
distributions. distributions.
...@@ -1122,10 +1112,6 @@ build_ext ...@@ -1122,10 +1112,6 @@ build_ext
A dictionary of options to be passed to the distutils build_ext A dictionary of options to be passed to the distutils build_ext
command when building extensions. command when building extensions.
executable
A path to a Python executable. Distributions will be installed
using this executable and will be for the matching Python version.
We have a local directory containing the extdemo source: We have a local directory containing the extdemo source:
>>> ls(extdemo) >>> ls(extdemo)
......
...@@ -108,7 +108,7 @@ def system(command, input=''): ...@@ -108,7 +108,7 @@ def system(command, input=''):
def get(url): def get(url):
return urllib2.urlopen(url).read() return urllib2.urlopen(url).read()
def _runsetup(setup, executable, *args): def _runsetup(setup, *args):
if os.path.isdir(setup): if os.path.isdir(setup):
setup = os.path.join(setup, 'setup.py') setup = os.path.join(setup, 'setup.py')
args = list(args) args = list(args)
...@@ -117,7 +117,7 @@ def _runsetup(setup, executable, *args): ...@@ -117,7 +117,7 @@ def _runsetup(setup, executable, *args):
try: try:
os.chdir(os.path.dirname(setup)) os.chdir(os.path.dirname(setup))
zc.buildout.easy_install.call_subprocess( zc.buildout.easy_install.call_subprocess(
[executable, setup] + args, [sys.executable, setup] + args,
env=dict(os.environ, PYTHONPATH=setuptools_location)) env=dict(os.environ, PYTHONPATH=setuptools_location))
if os.path.exists('build'): if os.path.exists('build'):
rmtree('build') rmtree('build')
...@@ -125,64 +125,15 @@ def _runsetup(setup, executable, *args): ...@@ -125,64 +125,15 @@ def _runsetup(setup, executable, *args):
os.chdir(here) os.chdir(here)
def sdist(setup, dest): def sdist(setup, dest):
_runsetup(setup, sys.executable, 'sdist', '-d', dest, '--formats=zip') _runsetup(setup, 'sdist', '-d', dest, '--formats=zip')
def bdist_egg(setup, executable, dest): def bdist_egg(setup, executable, dest=None):
_runsetup(setup, executable, 'bdist_egg', '-d', dest) # Backward compat:
if dest is None:
def find_python(version): dest = executable
e = os.environ.get('PYTHON%s' % version)
if e is not None:
return e
if is_win32:
e = '\Python%s%s\python.exe' % tuple(version.split('.'))
if os.path.exists(e):
return e
else: else:
cmd = 'python%s -c "import sys; print sys.executable"' % version assert executable == sys.executable, (executable, sys.executable)
p = subprocess.Popen(cmd, _runsetup(setup, 'bdist_egg', '-d', dest)
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
close_fds=MUST_CLOSE_FDS)
i, o = (p.stdin, p.stdout)
i.close()
e = o.read().strip()
o.close()
if os.path.exists(e):
return e
cmd = 'python -c "import sys; print \'%s.%s\' % sys.version_info[:2]"'
p = subprocess.Popen(cmd,
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
close_fds=MUST_CLOSE_FDS)
i, o = (p.stdin, p.stdout)
i.close()
e = o.read().strip()
o.close()
if e == version:
cmd = 'python -c "import sys; print sys.executable"'
p = subprocess.Popen(cmd,
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
close_fds=MUST_CLOSE_FDS)
i, o = (p.stdin, p.stdout)
i.close()
e = o.read().strip()
o.close()
if os.path.exists(e):
return e
raise ValueError(
"Couldn't figure out the executable for Python %(version)s.\n"
"Set the environment variable PYTHON%(version)s to the location\n"
"of the Python %(version)s executable before running the tests."
% {'version': version})
def wait_until(label, func, *args, **kw): def wait_until(label, func, *args, **kw):
if 'timeout' in kw: if 'timeout' in kw:
......
...@@ -109,26 +109,12 @@ number of names to the test namespace: ...@@ -109,26 +109,12 @@ number of names to the test namespace:
setup argument is a directory, the thge setup.py file in that setup argument is a directory, the thge setup.py file in that
directory is used. directory is used.
``bdist_egg(setup, executable, dest)`` ``bdist_egg(setup, dest)``
Create an egg by running the given setup file with the given Create an egg by running the given setup file
Python executable and placing the result in the given destination and placing the result in the given destination
directory. If the setup argument is a directory, then the directory. If the setup argument is a directory, then the
setup.py file in that directory is used. setup.py file in that directory is used.
``find_python(version)``
Find a Python executable for the given version, where version is a
string like "2.4".
This function uses the following strategy to find a Python of the
given version:
- Look for an environment variable of the form PYTHON%(version)s.
- On windows, look for \Pythonm%(version)s\python
- on Unix, try running python%(version)s or just python to get the
executable
``zc.buildout.testing.buildoutTearDown(test)`` ``zc.buildout.testing.buildoutTearDown(test)``
---------------------------------------------- ----------------------------------------------
......
...@@ -22,7 +22,6 @@ import tempfile ...@@ -22,7 +22,6 @@ import tempfile
import unittest import unittest
import zc.buildout.easy_install import zc.buildout.easy_install
import zc.buildout.testing import zc.buildout.testing
import zc.buildout.testselectingpython
import zipfile import zipfile
os_path_sep = os.path.sep os_path_sep = os.path.sep
...@@ -499,55 +498,6 @@ Then try to install it again: ...@@ -499,55 +498,6 @@ Then try to install it again:
""" """
def make_sure__get_version_works_with_2_digit_python_versions():
"""
This is a test of an internal function used by higher-level machinery.
We'll start by creating a faux 'python' that executable that prints a
2-digit version. This is a bit of a pain to do portably. :(
>>> mkdir('demo')
>>> write('demo', 'setup.py',
... '''
... from setuptools import setup
... setup(name='demo',
... entry_points = {'console_scripts': ['demo = demo:main']},
... )
... ''')
>>> write('demo', 'demo.py',
... '''
... def main():
... print 'Python 2.5'
... ''')
>>> write('buildout.cfg',
... '''
... [buildout]
... develop = demo
... parts =
... ''')
>>> print system(join('bin', 'buildout')),
Develop: '/sample-buildout/demo'
>>> import zc.buildout.easy_install
>>> ws = zc.buildout.easy_install.working_set(
... ['demo'], sys.executable, ['develop-eggs'])
>>> bool(zc.buildout.easy_install.scripts(
... ['demo'], ws, sys.executable, 'bin'))
True
>>> print system(join('bin', 'demo')),
Python 2.5
Now, finally, let's test _get_version:
>>> zc.buildout.easy_install._get_version(join('bin', 'demo'))
'2.5'
"""
def create_sections_on_command_line(): def create_sections_on_command_line():
""" """
>>> write('buildout.cfg', >>> write('buildout.cfg',
...@@ -2655,6 +2605,7 @@ def increment_on_command_line(): ...@@ -2655,6 +2605,7 @@ def increment_on_command_line():
###################################################################### ######################################################################
def create_sample_eggs(test, executable=sys.executable): def create_sample_eggs(test, executable=sys.executable):
assert executable == sys.executable, (executable, sys.executable)
write = test.globs['write'] write = test.globs['write']
dest = test.globs['sample_eggs'] dest = test.globs['sample_eggs']
tmp = tempfile.mkdtemp() tmp = tempfile.mkdtemp()
...@@ -2680,7 +2631,7 @@ def create_sample_eggs(test, executable=sys.executable): ...@@ -2680,7 +2631,7 @@ def create_sample_eggs(test, executable=sys.executable):
"setup(name='other', zip_safe=False, version='1.0', " "setup(name='other', zip_safe=False, version='1.0', "
"py_modules=['eggrecipedemoneeded'])\n" "py_modules=['eggrecipedemoneeded'])\n"
) )
zc.buildout.testing.bdist_egg(tmp, executable, dest) zc.buildout.testing.bdist_egg(tmp, sys.executable, dest)
os.remove(os.path.join(tmp, 'eggrecipedemoneeded.py')) os.remove(os.path.join(tmp, 'eggrecipedemoneeded.py'))
...@@ -2701,7 +2652,7 @@ def create_sample_eggs(test, executable=sys.executable): ...@@ -2701,7 +2652,7 @@ def create_sample_eggs(test, executable=sys.executable):
"['demo = eggrecipedemo:main']}," "['demo = eggrecipedemo:main']},"
" zip_safe=True, version='0.%s%s')\n" % (i, c1) " zip_safe=True, version='0.%s%s')\n" % (i, c1)
) )
zc.buildout.testing.bdist_egg(tmp, executable, dest) zc.buildout.testing.bdist_egg(tmp, dest)
write(tmp, 'eggrecipebigdemo.py', 'import eggrecipedemo') write(tmp, 'eggrecipebigdemo.py', 'import eggrecipedemo')
write( write(
...@@ -2712,7 +2663,7 @@ def create_sample_eggs(test, executable=sys.executable): ...@@ -2712,7 +2663,7 @@ def create_sample_eggs(test, executable=sys.executable):
" py_modules=['eggrecipebigdemo'], " " py_modules=['eggrecipebigdemo'], "
" zip_safe=True, version='0.1')\n" " zip_safe=True, version='0.1')\n"
) )
zc.buildout.testing.bdist_egg(tmp, executable, dest) zc.buildout.testing.bdist_egg(tmp, sys.executable, dest)
finally: finally:
shutil.rmtree(tmp) shutil.rmtree(tmp)
...@@ -2858,7 +2809,7 @@ def bootstrapSetup(test): ...@@ -2858,7 +2809,7 @@ def bootstrapSetup(test):
normalize_bang = ( normalize_bang = (
re.compile(re.escape('#!'+ re.compile(re.escape('#!'+
zc.buildout.easy_install._safe_arg(sys.executable))), zc.buildout.easy_install._safe_arg(sys.executable))),
'#!/usr/local/bin/python2.4', '#!/usr/local/bin/python2.7',
) )
def test_suite(): def test_suite():
...@@ -2874,8 +2825,6 @@ def test_suite(): ...@@ -2874,8 +2825,6 @@ def test_suite():
zc.buildout.testing.normalize_egg_py, zc.buildout.testing.normalize_egg_py,
(re.compile('__buildout_signature__ = recipes-\S+'), (re.compile('__buildout_signature__ = recipes-\S+'),
'__buildout_signature__ = recipes-SSSSSSSSSSS'), '__buildout_signature__ = recipes-SSSSSSSSSSS'),
(re.compile('executable = [\S ]+python\S*', re.I),
'executable = python'),
(re.compile('[-d] setuptools-\S+[.]egg'), 'setuptools.egg'), (re.compile('[-d] setuptools-\S+[.]egg'), 'setuptools.egg'),
(re.compile('zc.buildout(-\S+)?[.]egg(-link)?'), (re.compile('zc.buildout(-\S+)?[.]egg(-link)?'),
'zc.buildout.egg'), 'zc.buildout.egg'),
...@@ -2989,7 +2938,6 @@ def test_suite(): ...@@ -2989,7 +2938,6 @@ def test_suite():
(re.compile(r'^[*]...'), '...'), (re.compile(r'^[*]...'), '...'),
]), ]),
), ),
zc.buildout.testselectingpython.test_suite(),
zc.buildout.rmtree.test_suite(), zc.buildout.rmtree.test_suite(),
doctest.DocFileSuite( doctest.DocFileSuite(
'windows.txt', 'windows.txt',
......
##############################################################################
#
# Copyright (c) 2006 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import os, re, sys, unittest
from zope.testing import doctest, renormalizing
import zc.buildout.tests
import zc.buildout.testing
if sys.version_info[:2] == (2, 4):
other_version = "2.5"
else:
other_version = "2.4"
__test__ = dict(
test_selecting_python_via_easy_install=
"""\
We can specify a specific Python executable.
>>> dest = tmpdir('sample-install')
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server],
... index='http://www.python.org/pypi/',
... always_unzip=True, executable=other_executable)
>>> ls(dest)
d demo-0.3-py%(other_version)s.egg
d demoneeded-1.1-py%(other_version)s.egg
""" % dict(other_version=other_version)
)
def multi_python(test):
other_executable = zc.buildout.testing.find_python(other_version)
sample_eggs = test.globs['tmpdir']('sample_eggs')
os.mkdir(os.path.join(sample_eggs, 'index'))
test.globs['sample_eggs'] = sample_eggs
zc.buildout.tests.create_sample_eggs(test, executable=other_executable)
test.globs['other_executable'] = other_executable
def setup(test):
zc.buildout.testing.buildoutSetUp(test)
multi_python(test)
zc.buildout.tests.add_source_dist(test)
test.globs['link_server'] = test.globs['start_server'](
test.globs['sample_eggs'])
def test_suite():
return doctest.DocTestSuite(
setUp=setup,
tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
(re.compile('setuptools-\S+-py%s.egg' % other_version),
'setuptools-V-py%s.egg' % other_version),
]),
)
...@@ -89,7 +89,7 @@ Our buildout script has been updated to use the new eggs (HACK: only for ...@@ -89,7 +89,7 @@ Our buildout script has been updated to use the new eggs (HACK: only for
setuptools): setuptools):
>>> cat(sample_buildout, 'bin', 'buildout') >>> cat(sample_buildout, 'bin', 'buildout')
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
<BLANKLINE> <BLANKLINE>
import sys import sys
sys.path[0:0] = [ sys.path[0:0] = [
......
...@@ -47,7 +47,6 @@ test: we only want to test that ``_get_dist()`` isn't getting called: ...@@ -47,7 +47,6 @@ test: we only want to test that ``_get_dist()`` isn't getting called:
... dest=dest, ... dest=dest,
... links=[link_server], ... links=[link_server],
... index=link_server+'index/', ... index=link_server+'index/',
... executable=sys.executable,
... always_unzip=True) ... always_unzip=True)
>>> installer._get_dist = mock_get_dist >>> installer._get_dist = mock_get_dist
>>> installer._call_easy_install('setuptools', None, dest, dist) >>> installer._call_easy_install('setuptools', None, dest, dist)
......
...@@ -23,12 +23,6 @@ index ...@@ -23,12 +23,6 @@ index
we'll just point to an empty directory on our link server. This we'll just point to an empty directory on our link server. This
will make our examples run a little bit faster. will make our examples run a little bit faster.
python
The name of a section to get the Python executable from.
If not specified, then the buildout python option is used. The
Python executable is found in the executable option of the named
section.
We have a link server that has a number of distributions: We have a link server that has a number of distributions:
>>> print get(link_server), >>> print get(link_server),
...@@ -373,7 +367,7 @@ extra-paths option: ...@@ -373,7 +367,7 @@ extra-paths option:
Let's look at the script that was generated: Let's look at the script that was generated:
>>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE >>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
<BLANKLINE> <BLANKLINE>
import sys import sys
sys.path[0:0] = [ sys.path[0:0] = [
...@@ -420,7 +414,7 @@ breaking scripts. ...@@ -420,7 +414,7 @@ breaking scripts.
Let's look at the script that was generated: Let's look at the script that was generated:
>>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE >>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
<BLANKLINE> <BLANKLINE>
import os import os
<BLANKLINE> <BLANKLINE>
...@@ -467,7 +461,7 @@ each individual script section: ...@@ -467,7 +461,7 @@ each individual script section:
Generated script '/sample-buildout/bin/foo'. Generated script '/sample-buildout/bin/foo'.
>>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE >>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
<BLANKLINE> <BLANKLINE>
import os import os
<BLANKLINE> <BLANKLINE>
...@@ -520,7 +514,7 @@ to be included in generated scripts: ...@@ -520,7 +514,7 @@ to be included in generated scripts:
Generated script '/sample-buildout/bin/foo'. Generated script '/sample-buildout/bin/foo'.
>>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE >>> cat(sample_buildout, 'bin', 'foo') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
<BLANKLINE> <BLANKLINE>
import sys import sys
sys.path[0:0] = [ sys.path[0:0] = [
...@@ -578,7 +572,7 @@ declare entry points using the entry-points option: ...@@ -578,7 +572,7 @@ declare entry points using the entry-points option:
- other - other
>>> cat(sample_buildout, 'bin', 'other') >>> cat(sample_buildout, 'bin', 'other')
#!/usr/local/bin/python2.4 #!/usr/local/bin/python2.7
<BLANKLINE> <BLANKLINE>
import sys import sys
sys.path[0:0] = [ sys.path[0:0] = [
......
...@@ -6,7 +6,7 @@ and generate scripts based on the resulting working sets. The egg ...@@ -6,7 +6,7 @@ and generate scripts based on the resulting working sets. The egg
recipe provides an API that other recipes can use. recipe provides an API that other recipes can use.
A recipe can reuse the egg recipe, supporting the eggs, find-links, A recipe can reuse the egg recipe, supporting the eggs, find-links,
index, extra-paths, and python options. This is done by creating an index, and extra-paths options. This is done by creating an
egg recipe instance in a recipes's contructor. In the recipe's egg recipe instance in a recipes's contructor. In the recipe's
install script, the egg-recipe instance's working_set method is used install script, the egg-recipe instance's working_set method is used
to collect the requested eggs and working set. to collect the requested eggs and working set.
...@@ -112,7 +112,6 @@ computed by the egg recipe by looking at .installed.cfg: ...@@ -112,7 +112,6 @@ computed by the egg recipe by looking at .installed.cfg:
develop-eggs-directory = /sample-buildout/develop-eggs develop-eggs-directory = /sample-buildout/develop-eggs
eggs = demo<0.3 eggs = demo<0.3
eggs-directory = /sample-buildout/eggs eggs-directory = /sample-buildout/eggs
executable = /usr/local/bin/python2.3
extras = other extras = other
find-links = http://localhost:27071/ find-links = http://localhost:27071/
index = http://localhost:27071/index index = http://localhost:27071/index
......
...@@ -16,8 +16,12 @@ ...@@ -16,8 +16,12 @@
$Id$ $Id$
""" """
import logging, os, re, zipfile import logging
import os
import re
import sys
import zc.buildout.easy_install import zc.buildout.easy_install
import zipfile
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -29,9 +33,6 @@ class Base: ...@@ -29,9 +33,6 @@ class Base:
options['_d'] = buildout['buildout']['develop-eggs-directory'] options['_d'] = buildout['buildout']['develop-eggs-directory']
python = options.get('python', buildout['buildout']['python'])
options['executable'] = buildout[python]['executable']
self.build_ext = build_ext(buildout, options) self.build_ext = build_ext(buildout, options)
def update(self): def update(self):
...@@ -92,8 +93,8 @@ class Custom(Base): ...@@ -92,8 +93,8 @@ class Custom(Base):
try: try:
return zc.buildout.easy_install.build( return zc.buildout.easy_install.build(
distribution, options['_d'], self.build_ext, distribution, options['_d'], self.build_ext,
self.links, self.index, options['executable'], [options['_e']], self.links, self.index, sys.executable,
newest=self.newest, [options['_e']], newest=self.newest,
) )
finally: finally:
self._restore_environment() self._restore_environment()
...@@ -130,9 +131,7 @@ class Develop(Base): ...@@ -130,9 +131,7 @@ class Develop(Base):
def install(self): def install(self):
options = self.options options = self.options
return zc.buildout.easy_install.develop( return zc.buildout.easy_install.develop(
options['setup'], options['_d'], self.build_ext, options['setup'], options['_d'], self.build_ext)
options['executable'],
)
def build_ext(buildout, options): def build_ext(buildout, options):
......
...@@ -50,7 +50,7 @@ compiler ...@@ -50,7 +50,7 @@ compiler
swig swig
The path to the swig executable The path to the swig executable
swig-cpp swig-cpp
Make SWIG create C++ files (default is C) Make SWIG create C++ files (default is C)
swig-opts swig-opts
...@@ -73,15 +73,9 @@ index ...@@ -73,15 +73,9 @@ index
alternate index with this option. If you use the links option and alternate index with this option. If you use the links option and
if the links point to the needed distributions, then the index can if the links point to the needed distributions, then the index can
be anything and will be largely ignored. In the examples, here, be anything and will be largely ignored. In the examples, here,
we'll just point to an empty directory on our link server. This we'll just point to an empty directory on our link server. This
will make our examples run a little bit faster. will make our examples run a little bit faster.
python
The name of a section to get the Python executable from.
If not specified, then the buildout python option is used. The
Python executable is found in the executable option of the named
section.
environment environment
The name of a section with additional environment variables. The The name of a section with additional environment variables. The
environment variables are set before the egg is built. environment variables are set before the egg is built.
...@@ -188,7 +182,7 @@ Let's define a script that uses out ext demo: ...@@ -188,7 +182,7 @@ Let's define a script that uses out ext demo:
... ...
... [demo] ... [demo]
... recipe = zc.recipe.egg ... recipe = zc.recipe.egg
... eggs = demo ... eggs = demo
... extdemo ... extdemo
... entry-points = demo=demo:main ... entry-points = demo=demo:main
... """ % dict(server=link_server)) ... """ % dict(server=link_server))
...@@ -270,7 +264,7 @@ We can specify a specific version using the egg option: ...@@ -270,7 +264,7 @@ We can specify a specific version using the egg option:
... ...
... [demo] ... [demo]
... recipe = zc.recipe.egg ... recipe = zc.recipe.egg
... eggs = demo ... eggs = demo
... extdemo ==1.4 ... extdemo ==1.4
... entry-points = demo=demo:main ... entry-points = demo=demo:main
... """ % dict(server=link_server)) ... """ % dict(server=link_server))
...@@ -440,7 +434,7 @@ Create a clean buildout.cfg w/o the checkenv recipe, and delete the recipe: ...@@ -440,7 +434,7 @@ Create a clean buildout.cfg w/o the checkenv recipe, and delete the recipe:
Uninstalling extdemo. Uninstalling extdemo.
Installing extdemo. Installing extdemo.
zip_safe flag not set; analyzing archive contents... zip_safe flag not set; analyzing archive contents...
>>> rmdir(sample_buildout, 'recipes') >>> rmdir(sample_buildout, 'recipes')
...@@ -496,18 +490,12 @@ compiler ...@@ -496,18 +490,12 @@ compiler
swig swig
The path to the swig executable The path to the swig executable
swig-cpp swig-cpp
Make SWIG create C++ files (default is C) Make SWIG create C++ files (default is C)
swig-opts swig-opts
List of SWIG command line options List of SWIG command line options
python
The name of a section to get the Python executable from.
If not specified, then the buildout python option is used. The
Python executable is found in the executable option of the named
section.
To illustrate this, we'll use a directory containing the extdemo To illustrate this, we'll use a directory containing the extdemo
example from the earlier section: example from the earlier section:
...@@ -532,7 +520,7 @@ example from the earlier section: ...@@ -532,7 +520,7 @@ example from the earlier section:
... ...
... [demo] ... [demo]
... recipe = zc.recipe.egg ... recipe = zc.recipe.egg
... eggs = demo ... eggs = demo
... extdemo ... extdemo
... entry-points = demo=demo:main ... entry-points = demo=demo:main
... """ % dict(extdemo=extdemo)) ... """ % dict(extdemo=extdemo))
......
...@@ -12,12 +12,14 @@ ...@@ -12,12 +12,14 @@
# #
############################################################################## ##############################################################################
"""Install packages as eggs """Install packages as eggs
$Id$
""" """
import logging, os, re, zipfile import logging
import os
import re
import sys
import zc.buildout.easy_install import zc.buildout.easy_install
import zipfile
class Eggs(object): class Eggs(object):
...@@ -52,9 +54,6 @@ class Eggs(object): ...@@ -52,9 +54,6 @@ class Eggs(object):
assert options.get('unzip') in ('true', 'false', None) assert options.get('unzip') in ('true', 'false', None)
python = options.get('python', buildout['buildout']['python'])
options['executable'] = buildout[python]['executable']
def working_set(self, extra=()): def working_set(self, extra=()):
"""Separate method to just get the working set """Separate method to just get the working set
...@@ -71,7 +70,7 @@ class Eggs(object): ...@@ -71,7 +70,7 @@ class Eggs(object):
if self.buildout['buildout'].get('offline') == 'true': if self.buildout['buildout'].get('offline') == 'true':
ws = zc.buildout.easy_install.working_set( ws = zc.buildout.easy_install.working_set(
distributions, options['executable'], distributions,
[options['develop-eggs-directory'], options['eggs-directory']] [options['develop-eggs-directory'], options['eggs-directory']]
) )
else: else:
...@@ -83,7 +82,6 @@ class Eggs(object): ...@@ -83,7 +82,6 @@ class Eggs(object):
distributions, options['eggs-directory'], distributions, options['eggs-directory'],
links=self.links, links=self.links,
index=self.index, index=self.index,
executable=options['executable'],
path=[options['develop-eggs-directory']], path=[options['develop-eggs-directory']],
newest=self.buildout['buildout'].get('newest') == 'true', newest=self.buildout['buildout'].get('newest') == 'true',
allow_hosts=self.allow_hosts, allow_hosts=self.allow_hosts,
...@@ -159,8 +157,7 @@ class Scripts(Eggs): ...@@ -159,8 +157,7 @@ class Scripts(Eggs):
reqs.append(name) reqs.append(name)
return zc.buildout.easy_install.scripts( return zc.buildout.easy_install.scripts(
reqs, ws, options['executable'], reqs, ws, sys.executable, options['bin-directory'],
options['bin-directory'],
scripts=scripts, scripts=scripts,
extra_paths=self.extra_paths, extra_paths=self.extra_paths,
interpreter=options.get('interpreter'), interpreter=options.get('interpreter'),
......
Controlling which Python to use
-------------------------------
The following assumes that you have Python 2.4 installed.
We can specify the python to use by specifying the name of a section
to read the Python executable from. The default is the section
defined by the python buildout option.
We have a link server:
>>> print get(link_server),
<html><body>
<a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
<a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
<a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br>
<a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br>
<a href="demo-0.4c1-py2.4.egg">demo-0.4c1-py2.4.egg</a><br>
<a href="demoneeded-1.0.zip">demoneeded-1.0.zip</a><br>
<a href="demoneeded-1.1.zip">demoneeded-1.1.zip</a><br>
<a href="demoneeded-1.2c1.zip">demoneeded-1.2c1.zip</a><br>
<a href="extdemo-1.4.zip">extdemo-1.4.zip</a><br>
<a href="index/">index/</a><br>
<a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>
</body></html>
We have a sample buildout. Let's update it's configuration file to
install the demo package using Python 2.4.
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... parts = demo
... eggs-directory = eggs
... index = http://www.python.org/pypi/
...
... [python2.4]
... executable = %(python23)s
...
... [demo]
... recipe = zc.recipe.egg
... eggs = demo <0.3
... find-links = %(server)s
... python = python2.4
... interpreter = py-demo
... """ % dict(server=link_server, python23=other_executable))
Now, if we run the buildout:
>>> import os
>>> os.chdir(sample_buildout)
>>> buildout = os.path.join(sample_buildout, 'bin', 'buildout')
>>> print system(buildout),
Installing demo.
Getting distribution for 'demo<0.3'.
Got demo 0.2.
Getting distribution for 'demoneeded'.
Getting distribution for 'setuptools'.
Got setuptools 0.6.
Got demoneeded 1.2c1.
Generated script '/sample-buildout/bin/demo'.
Generated interpreter '/sample-buildout/bin/py-demo'.
we'll get the Python 2.4 eggs for demo and demoneeded:
>>> ls(sample_buildout, 'eggs')
- demo-0.2-py2.4.egg
- demoneeded-1.2c1-py2.4.egg
d setuptools-0.6-py2.4.egg
d setuptools-0.6-py2.5.egg
- zc.buildout-1.0-py2.5.egg
And the generated scripts invoke Python 2.4:
>>> import sys
>>> if sys.platform == 'win32':
... script_name = 'demo-script.py'
... else:
... script_name = 'demo'
>>> f = open(os.path.join(sample_buildout, 'bin', script_name))
>>> shebang = f.readline().strip()
>>> if shebang[:3] == '#!"' and shebang[-1] == '"':
... shebang = '#!'+shebang[3:-1]
>>> shebang == '#!' + other_executable
True
>>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
<BLANKLINE>
import sys
sys.path[0:0] = [
'/sample-buildout/eggs/demo-0.2-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
]
<BLANKLINE>
import eggrecipedemo
<BLANKLINE>
if __name__ == '__main__':
eggrecipedemo.main()
>>> if sys.platform == 'win32':
... f = open(os.path.join(sample_buildout, 'bin', 'py-demo-script.py'))
... else:
... f = open(os.path.join(sample_buildout, 'bin', 'py-demo'))
>>> shebang = f.readline().strip()
>>> if shebang[:3] == '#!"' and shebang[-1] == '"':
... shebang = '#!'+shebang[3:-1]
>>> shebang == '#!' + other_executable
True
>>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
<BLANKLINE>
import sys
<BLANKLINE>
sys.path[0:0] = [
'/sample-buildout/eggs/demo-0.2-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
]
<BLANKLINE>
_interactive = True
if len(sys.argv) > 1:
_options, _args = __import__("getopt").getopt(sys.argv[1:], 'ic:m:')
_interactive = False
for (_opt, _val) in _options:
if _opt == '-i':
_interactive = True
elif _opt == '-c':
exec _val
elif _opt == '-m':
sys.argv[1:] = _args
_args = []
__import__("runpy").run_module(
_val, {}, "__main__", alter_sys=True)
<BLANKLINE>
if _args:
sys.argv[:] = _args
__file__ = _args[0]
del _options, _args
execfile(__file__)
<BLANKLINE>
if _interactive:
del _interactive
__import__("code").interact(banner="", local=globals())
>>> f.close()
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
import os, re, shutil, sys import os, re, shutil, sys
import zc.buildout.tests import zc.buildout.tests
import zc.buildout.testselectingpython
import zc.buildout.testing import zc.buildout.testing
import unittest import unittest
...@@ -33,10 +32,6 @@ def setUp(test): ...@@ -33,10 +32,6 @@ def setUp(test):
zc.buildout.tests.easy_install_SetUp(test) zc.buildout.tests.easy_install_SetUp(test)
zc.buildout.testing.install_develop('zc.recipe.egg', test) zc.buildout.testing.install_develop('zc.recipe.egg', test)
def setUpSelecting(test):
zc.buildout.testselectingpython.setup(test)
zc.buildout.testing.install_develop('zc.recipe.egg', test)
def test_suite(): def test_suite():
suite = unittest.TestSuite(( suite = unittest.TestSuite((
doctest.DocFileSuite( doctest.DocFileSuite(
...@@ -68,8 +63,6 @@ def test_suite(): ...@@ -68,8 +63,6 @@ def test_suite():
'zc.buildout-\S+\s*' 'zc.buildout-\S+\s*'
), ),
'__buildout_signature__ = sample- zc.recipe.egg-'), '__buildout_signature__ = sample- zc.recipe.egg-'),
(re.compile('executable = [\S ]+python\S*', re.I),
'executable = python'),
(re.compile('find-links = http://localhost:\d+/'), (re.compile('find-links = http://localhost:\d+/'),
'find-links = http://localhost:8080/'), 'find-links = http://localhost:8080/'),
(re.compile('index = http://localhost:\d+/index'), (re.compile('index = http://localhost:\d+/index'),
...@@ -89,33 +82,7 @@ def test_suite(): ...@@ -89,33 +82,7 @@ def test_suite():
(re.compile('extdemo[.]pyd'), 'extdemo.so') (re.compile('extdemo[.]pyd'), 'extdemo.so')
]), ]),
), ),
)) ))
if sys.version_info[:2] == (2, 5):
# Only run selecting python tests if not 2.4, since
# 2.4 is the alternate python used in the tests.
suite.addTest(
doctest.DocFileSuite(
'selecting-python.txt',
setUp=setUpSelecting,
tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
zc.buildout.testing.normalize_path,
zc.buildout.testing.normalize_endings,
zc.buildout.testing.normalize_script,
(re.compile('Got setuptools \S+'), 'Got setuptools V'),
(re.compile('([d-] )?setuptools-\S+-py'),
'setuptools-V-py'),
(re.compile('-py2[.][0-35-9][.]'), 'py2.5.'),
(re.compile('zc.buildout-\S+[.]egg'),
'zc.buildout.egg'),
(re.compile('zc.buildout[.]egg-link'),
'zc.buildout.egg'),
]),
),
)
return suite return suite
if __name__ == '__main__': if __name__ == '__main__':
......
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