Commit a0669e31 authored by Tres Seaver's avatar Tres Seaver

First stab at using setuptools >= 0.7 instead of distribute.

My doctest / renormalizer fu is not strong enough to deal with the
changes to output:

- setuptools now has dependencies, and emits output to add them as
  'find-links'.  I tried adding an 'adding_find_link' renormalizer,
  but it doesn't suppress the output.

- Other failures due to merge tweaking APIs, etc.  Again, I'm not
  competent to fix them in the doctest / renormalizer world:  they make
  my head hurt.
parent 11571375
...@@ -61,15 +61,12 @@ parser.add_option("-f", "--find-links", ...@@ -61,15 +61,12 @@ parser.add_option("-f", "--find-links",
options, args = parser.parse_args() options, args = parser.parse_args()
###################################################################### ######################################################################
# load/install distribute # load/install setuptools
to_reload = False to_reload = False
try: try:
import pkg_resources import pkg_resources
import setuptools import setuptools
if not hasattr(pkg_resources, '_distribute'):
to_reload = True
raise ImportError
except ImportError: except ImportError:
ez = {} ez = {}
...@@ -78,7 +75,7 @@ except ImportError: ...@@ -78,7 +75,7 @@ except ImportError:
except ImportError: except ImportError:
from urllib2 import urlopen from urllib2 import urlopen
exec(urlopen('http://python-distribute.org/distribute_setup.py').read(), exec(urlopen('http://dist.repoze.org/ez_setup-0.7.py').read(),
ez) ez)
setup_args = dict(to_dir=tmpeggs, download_delay=0, no_fake=True) setup_args = dict(to_dir=tmpeggs, download_delay=0, no_fake=True)
ez['use_setuptools'](**setup_args) ez['use_setuptools'](**setup_args)
...@@ -110,8 +107,8 @@ find_links = os.environ.get( ...@@ -110,8 +107,8 @@ find_links = os.environ.get(
if find_links: if find_links:
cmd.extend(['-f', find_links]) cmd.extend(['-f', find_links])
distribute_path = ws.find( setuptools_path = ws.find(
pkg_resources.Requirement.parse('distribute')).location pkg_resources.Requirement.parse('setuptools')).location
requirement = 'zc.buildout' requirement = 'zc.buildout'
version = options.version version = options.version
...@@ -126,7 +123,7 @@ if version is None and not options.accept_buildout_test_releases: ...@@ -126,7 +123,7 @@ if version is None and not options.accept_buildout_test_releases:
return False return False
return True return True
index = setuptools.package_index.PackageIndex( index = setuptools.package_index.PackageIndex(
search_path=[distribute_path]) search_path=[setuptools_path])
if find_links: if find_links:
index.add_find_links((find_links,)) index.add_find_links((find_links,))
req = pkg_resources.Requirement.parse(requirement) req = pkg_resources.Requirement.parse(requirement)
...@@ -149,7 +146,7 @@ if version: ...@@ -149,7 +146,7 @@ if version:
cmd.append(requirement) cmd.append(requirement)
import subprocess import subprocess
if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=distribute_path)) != 0: if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
raise Exception( raise Exception(
"Failed to execute command:\n%s", "Failed to execute command:\n%s",
repr(cmd)[1:-1]) repr(cmd)[1:-1])
......
...@@ -46,7 +46,7 @@ try: ...@@ -46,7 +46,7 @@ try:
except ImportError: except ImportError:
from urllib2 import urlopen from urllib2 import urlopen
exec(urlopen('http://python-distribute.org/distribute_setup.py').read(), ez) exec(urlopen('http://dist.repoze.org/ez_setup-0.7.py').read(), ez)
ez['use_setuptools'](to_dir='eggs', download_delay=0) ez['use_setuptools'](to_dir='eggs', download_delay=0)
import pkg_resources import pkg_resources
......
...@@ -89,7 +89,9 @@ setup( ...@@ -89,7 +89,9 @@ setup(
packages = ['zc', 'zc.buildout'], packages = ['zc', 'zc.buildout'],
package_dir = {'': 'src'}, package_dir = {'': 'src'},
namespace_packages = ['zc'], namespace_packages = ['zc'],
install_requires = 'setuptools', install_requires = [
'setuptools>=0.7',
],
include_package_data = True, include_package_data = True,
entry_points = entry_points, entry_points = entry_points,
extras_require = dict(test=['zope.testing', 'manuel']), extras_require = dict(test=['zope.testing', 'manuel']),
...@@ -98,9 +100,10 @@ setup( ...@@ -98,9 +100,10 @@ setup(
'Intended Audience :: Developers', 'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License', 'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python', 'Programming Language :: Python',
'Programming Language :: Python :: 3', 'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.3',
'Topic :: Software Development :: Build Tools', 'Topic :: Software Development :: Build Tools',
......
...@@ -55,7 +55,7 @@ By default it gets the latest version: ...@@ -55,7 +55,7 @@ By default it gets the latest version:
>>> print_(open(buildout_script).read()) # doctest: +ELLIPSIS >>> print_(open(buildout_script).read()) # doctest: +ELLIPSIS
#... #...
sys.path[0:0] = [ sys.path[0:0] = [
'/sample/eggs/distribute-...egg', '/sample/eggs/setuptools-...egg',
'/sample/eggs/zc.buildout-22.0.0...egg', '/sample/eggs/zc.buildout-22.0.0...egg',
]... ]...
...@@ -86,6 +86,6 @@ Let's make sure the generated `buildout` script uses it:: ...@@ -86,6 +86,6 @@ Let's make sure the generated `buildout` script uses it::
>>> print_(open(buildout_script).read()) # doctest: +ELLIPSIS >>> print_(open(buildout_script).read()) # doctest: +ELLIPSIS
#... #...
sys.path[0:0] = [ sys.path[0:0] = [
'/sample/eggs/distribute-...egg', '/sample/eggs/setuptools-...egg',
'/sample/eggs/zc.buildout-2.0.0...egg', '/sample/eggs/zc.buildout-2.0.0...egg',
]... ]...
...@@ -56,7 +56,7 @@ def print_(*args, **kw): ...@@ -56,7 +56,7 @@ def print_(*args, **kw):
realpath = zc.buildout.easy_install.realpath realpath = zc.buildout.easy_install.realpath
pkg_resources_loc = pkg_resources.working_set.find( pkg_resources_loc = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('distribute')).location pkg_resources.Requirement.parse('setuptools')).location
_isurl = re.compile('([a-zA-Z0-9+.-]+)://').match _isurl = re.compile('([a-zA-Z0-9+.-]+)://').match
...@@ -371,9 +371,9 @@ class Buildout(DictMixin): ...@@ -371,9 +371,9 @@ class Buildout(DictMixin):
self._setup_directories() self._setup_directories()
# Now copy buildout and distribute eggs, and record destination eggs: # Now copy buildout and setuptools eggs, and record destination eggs:
entries = [] entries = []
for name in 'distribute', 'zc.buildout': for name in 'setuptools', 'zc.buildout':
r = pkg_resources.Requirement.parse(name) r = pkg_resources.Requirement.parse(name)
dist = pkg_resources.working_set.find(r) dist = pkg_resources.working_set.find(r)
if dist.precedence == pkg_resources.DEVELOP_DIST: if dist.precedence == pkg_resources.DEVELOP_DIST:
...@@ -871,7 +871,7 @@ class Buildout(DictMixin): ...@@ -871,7 +871,7 @@ class Buildout(DictMixin):
self._log_level = level self._log_level = level
def _maybe_upgrade(self): def _maybe_upgrade(self):
# See if buildout or distribute need to be upgraded. # See if buildout or setuptools need to be upgraded.
# If they do, do the upgrade and restart the buildout process. # If they do, do the upgrade and restart the buildout process.
__doing__ = 'Checking for upgrades.' __doing__ = 'Checking for upgrades.'
...@@ -879,7 +879,7 @@ class Buildout(DictMixin): ...@@ -879,7 +879,7 @@ class Buildout(DictMixin):
return return
ws = zc.buildout.easy_install.install( ws = zc.buildout.easy_install.install(
('zc.buildout', 'distribute'), ('zc.buildout', 'setuptools'),
self['buildout']['eggs-directory'], self['buildout']['eggs-directory'],
links = self['buildout'].get('find-links', '').split(), links = self['buildout'].get('find-links', '').split(),
index = self['buildout'].get('index'), index = self['buildout'].get('index'),
...@@ -888,7 +888,7 @@ class Buildout(DictMixin): ...@@ -888,7 +888,7 @@ class Buildout(DictMixin):
) )
upgraded = [] upgraded = []
for project in 'zc.buildout', 'distribute': for project in 'zc.buildout', 'setuptools':
req = pkg_resources.Requirement.parse(project) req = pkg_resources.Requirement.parse(project)
project_location = pkg_resources.working_set.find(req).location project_location = pkg_resources.working_set.find(req).location
if ws.find(req).location != project_location: if ws.find(req).location != project_location:
...@@ -1041,7 +1041,7 @@ class Buildout(DictMixin): ...@@ -1041,7 +1041,7 @@ class Buildout(DictMixin):
fd, tsetup = tempfile.mkstemp() fd, tsetup = tempfile.mkstemp()
try: try:
os.write(fd, (zc.buildout.easy_install.runsetup_template % dict( os.write(fd, (zc.buildout.easy_install.runsetup_template % dict(
distribute=pkg_resources_loc, setuptools=pkg_resources_loc,
setupdir=os.path.dirname(setup), setupdir=os.path.dirname(setup),
setup=setup, setup=setup,
__file__ = setup, __file__ = setup,
...@@ -1789,7 +1789,7 @@ Commands: ...@@ -1789,7 +1789,7 @@ Commands:
bootstrap bootstrap
Create a new buildout in the current working directory, copying Create a new buildout in the current working directory, copying
the buildout and distribute eggs and, creating a basic directory the buildout and setuptools eggs and, creating a basic directory
structure and a buildout-local buildout script. structure and a buildout-local buildout script.
init init
...@@ -1800,9 +1800,9 @@ Commands: ...@@ -1800,9 +1800,9 @@ Commands:
setup script [setup command and options] setup script [setup command and options]
Run a given setup script arranging that distribute is in the Run a given setup script arranging that setuptools is in the
script's path and and that it has been imported so that script's path and and that it has been imported so that
distribute-provided commands (like bdist_egg) can be used even if setuptools-provided commands (like bdist_egg) can be used even if
the setup script doesn't import setuptools. the setup script doesn't import setuptools.
The script can be given either as a script path or a path to a The script can be given either as a script path or a path to a
......
...@@ -18,7 +18,7 @@ buildout software and create a buildout instance: ...@@ -18,7 +18,7 @@ buildout software and create a buildout instance:
script installed in a Python scripts area. script installed in a Python scripts area.
2. Use the buildout bootstrap script to create a buildout that 2. Use the buildout bootstrap script to create a buildout that
includes both the distribute and zc.buildout eggs. This allows you includes both the setuptools and zc.buildout eggs. This allows you
to use the buildout software without modifying a Python install. to use the buildout software without modifying a Python install.
The buildout script is installed into your buildout local scripts The buildout script is installed into your buildout local scripts
area. area.
...@@ -32,7 +32,7 @@ such as a subversion repository, that includes some software source ...@@ -32,7 +32,7 @@ such as a subversion repository, that includes some software source
directories, buildout configuration files, and a copy of the buildout directories, buildout configuration files, and a copy of the buildout
bootstrap script. To work on the project, one would check out the bootstrap script. To work on the project, one would check out the
project from the repository and run the bootstrap script which project from the repository and run the bootstrap script which
installs distribute and zc.buildout into the checkout as well as any installs setuptools and zc.buildout into the checkout as well as any
parts defined. parts defined.
We have a sample buildout that we created using the bootstrap command We have a sample buildout that we created using the bootstrap command
...@@ -53,8 +53,8 @@ The bin directory contains scripts. ...@@ -53,8 +53,8 @@ The bin directory contains scripts.
- buildout - buildout
>>> ls(sample_buildout, 'eggs') >>> ls(sample_buildout, 'eggs')
- distribute-0.6-py2.4.egg - setuptools-0.7-py3.3.egg
- zc.buildout-1.0-py2.4.egg - zc.buildout.egg-link
The develop-eggs and parts directories are initially empty: The develop-eggs and parts directories are initially empty:
...@@ -228,7 +228,7 @@ classes must be exposed as entry points in the zc.buildout group. we ...@@ -228,7 +228,7 @@ classes must be exposed as entry points in the zc.buildout group. we
give entry points names within the group. give entry points names within the group.
We also need a README.txt for our recipes to avoid an annoying warning We also need a README.txt for our recipes to avoid an annoying warning
from distutils, on which distribute and zc.buildout are based: from distutils, on which setuptools and zc.buildout are based:
>>> write(sample_buildout, 'recipes', 'README.txt', " ") >>> write(sample_buildout, 'recipes', 'README.txt', " ")
...@@ -2482,10 +2482,10 @@ database is shown. ...@@ -2482,10 +2482,10 @@ database is shown.
... """) ... """)
>>> print_(system(buildout+' -vv'), end='') # doctest: +NORMALIZE_WHITESPACE >>> print_(system(buildout+' -vv'), end='') # doctest: +NORMALIZE_WHITESPACE
Installing 'zc.buildout', 'distribute'. Installing 'zc.buildout', 'setuptools'.
We have a develop egg: zc.buildout 1.0.0. We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'distribute'. We have the best distribution that satisfies 'setuptools'.
Picked: distribute = 0.6 Picked: setuptools = 0.7
<BLANKLINE> <BLANKLINE>
Configuration data: Configuration data:
[buildout] [buildout]
...@@ -2707,7 +2707,7 @@ Creating new buildouts and bootstrapping ...@@ -2707,7 +2707,7 @@ Creating new buildouts and bootstrapping
---------------------------------------- ----------------------------------------
If zc.buildout is installed, you can use it to create a new buildout If zc.buildout is installed, you can use it to create a new buildout
with it's own local copies of zc.buildout and distribute and with with it's own local copies of zc.buildout and setuptools and with
local buildout scripts. local buildout scripts.
>>> sample_bootstrapped = tmpdir('sample-bootstrapped') >>> sample_bootstrapped = tmpdir('sample-bootstrapped')
...@@ -2744,13 +2744,13 @@ We also get other buildout artifacts: ...@@ -2744,13 +2744,13 @@ We also get other buildout artifacts:
>>> _ = (ls(sample_bootstrapped, 'eggs'), >>> _ = (ls(sample_bootstrapped, 'eggs'),
... ls(sample_bootstrapped, 'develop-eggs')) ... ls(sample_bootstrapped, 'develop-eggs'))
- distribute-0.6-py2.3.egg - setuptools-0.7-py2.3.egg
- zc.buildout-1.0-py2.3.egg - zc.buildout-1.0-py2.3.egg
(We list both the eggs and develop-eggs directories because the (We list both the eggs and develop-eggs directories because the
buildout or distribute egg could be installed in the develop-eggs buildout or setuptools egg could be installed in the develop-eggs
directory if the original buildout had develop eggs for either directory if the original buildout had develop eggs for either
buildout or distribute.) buildout or setuptools.)
Note that the buildout script was installed but not run. To run Note that the buildout script was installed but not run. To run
the buildout, we'd have to run the installed buildout script. the buildout, we'd have to run the installed buildout script.
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
"""Python easy_install API """Python easy_install API
This module provides a high-level Python API for installing packages. This module provides a high-level Python API for installing packages.
It doesn't install scripts. It uses distribute and requires it to be It doesn't install scripts. It uses setuptools and requires it to be
installed. installed.
""" """
...@@ -57,24 +57,24 @@ if is_jython: ...@@ -57,24 +57,24 @@ if is_jython:
jython_os_name = (java.lang.System.getProperties()['os.name']).lower() jython_os_name = (java.lang.System.getProperties()['os.name']).lower()
# Make sure we're not being run with an older bootstrap.py that gives us # Make sure we're not being run with an older bootstrap.py that gives us
# setuptools instead of distribute # setuptools instead of setuptools
has_distribute = pkg_resources.working_set.find( has_distribute = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('distribute')) is not None pkg_resources.Requirement.parse('distribute')) is not None
has_setuptools = pkg_resources.working_set.find( has_setuptools = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('setuptools')) is not None pkg_resources.Requirement.parse('setuptools')) is not None
if has_setuptools and not has_distribute: if has_distribute and not has_setuptools:
sys.exit("zc.buildout 2 needs distribute, not setuptools." sys.exit("zc.buildout 2 needs setuptools, not distribute."
" Are you using an outdated bootstrap.py? Make sure" " Are you using an outdated bootstrap.py? Make sure"
" you have the latest version downloaded from" " you have the latest version downloaded from"
" http://downloads.buildout.org/2/bootstrap.py") " http://downloads.buildout.org/2/bootstrap.py")
distribute_loc = pkg_resources.working_set.find( setuptools_loc = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('distribute') pkg_resources.Requirement.parse('setuptools')
).location ).location
# Include buildout and distribute eggs in paths # Include buildout and setuptools eggs in paths
buildout_and_distribute_path = [ buildout_and_setuptools_path = [
distribute_loc, setuptools_loc,
pkg_resources.working_set.find( pkg_resources.working_set.find(
pkg_resources.Requirement.parse('zc.buildout')).location, pkg_resources.Requirement.parse('zc.buildout')).location,
] ]
...@@ -182,7 +182,7 @@ class Installer: ...@@ -182,7 +182,7 @@ class Installer:
links.insert(0, self._download_cache) links.insert(0, self._download_cache)
self._index_url = index self._index_url = index
path = (path and path[:] or []) + buildout_and_distribute_path path = (path and path[:] or []) + buildout_and_setuptools_path
if dest is not None and dest not in path: if dest is not None and dest not in path:
path.insert(0, dest) path.insert(0, dest)
self._path = path self._path = path
...@@ -290,7 +290,7 @@ class Installer: ...@@ -290,7 +290,7 @@ class Installer:
tmp = tempfile.mkdtemp(dir=dest) tmp = tempfile.mkdtemp(dir=dest)
try: try:
path = distribute_loc path = setuptools_loc
args = [sys.executable, '-c', _easy_install_cmd, '-mZUNxd', tmp] args = [sys.executable, '-c', _easy_install_cmd, '-mZUNxd', tmp]
level = logger.getEffectiveLevel() level = logger.getEffectiveLevel()
...@@ -432,7 +432,7 @@ class Installer: ...@@ -432,7 +432,7 @@ class Installer:
and (realpath(new_location) == realpath(dist.location)) and (realpath(new_location) == realpath(dist.location))
and os.path.isfile(new_location) and os.path.isfile(new_location)
): ):
# distribute avoids making extra copies, but we want to copy # setuptools avoids making extra copies, but we want to copy
# to the download cache # to the download cache
shutil.copy2(new_location, tmp) shutil.copy2(new_location, tmp)
new_location = os.path.join(tmp, os.path.basename(new_location)) new_location = os.path.join(tmp, os.path.basename(new_location))
...@@ -551,21 +551,21 @@ class Installer: ...@@ -551,21 +551,21 @@ class Installer:
return dists return dists
def _maybe_add_distribute(self, ws, dist): def _maybe_add_setuptools(self, ws, dist):
if dist.has_metadata('namespace_packages.txt'): if dist.has_metadata('namespace_packages.txt'):
for r in dist.requires(): for r in dist.requires():
if r.project_name in ('setuptools', 'distribute'): if r.project_name in ('setuptools', 'setuptools'):
break break
else: else:
# We have a namespace package but no requirement for distribute # We have a namespace package but no requirement for setuptools
if dist.precedence == pkg_resources.DEVELOP_DIST: if dist.precedence == pkg_resources.DEVELOP_DIST:
logger.warn( logger.warn(
"Develop distribution: %s\n" "Develop distribution: %s\n"
"uses namespace packages but the distribution " "uses namespace packages but the distribution "
"does not require distribute.", "does not require setuptools.",
dist) dist)
requirement = self._constrain( requirement = self._constrain(
pkg_resources.Requirement.parse('distribute') pkg_resources.Requirement.parse('setuptools')
) )
if ws.find(requirement) is None: if ws.find(requirement) is None:
for dist in self._get_dist(requirement, ws): for dist in self._get_dist(requirement, ws):
...@@ -600,7 +600,7 @@ class Installer: ...@@ -600,7 +600,7 @@ class Installer:
for requirement in requirements: for requirement in requirements:
for dist in self._get_dist(requirement, ws): for dist in self._get_dist(requirement, ws):
ws.add(dist) ws.add(dist)
self._maybe_add_distribute(ws, dist) self._maybe_add_setuptools(ws, dist)
# OK, we have the requested distributions and they're in the working # OK, we have the requested distributions and they're in the working
# set, but they may have unmet requirements. We'll simply keep # set, but they may have unmet requirements. We'll simply keep
...@@ -625,7 +625,7 @@ class Installer: ...@@ -625,7 +625,7 @@ class Installer:
for dist in self._get_dist(requirement, ws): for dist in self._get_dist(requirement, ws):
ws.add(dist) ws.add(dist)
self._maybe_add_distribute(ws, dist) self._maybe_add_setuptools(ws, dist)
except pkg_resources.VersionConflict: except pkg_resources.VersionConflict:
err = sys.exc_info()[1] err = sys.exc_info()[1]
raise VersionConflict(err, ws) raise VersionConflict(err, ws)
...@@ -848,7 +848,7 @@ def develop(setup, dest, ...@@ -848,7 +848,7 @@ def develop(setup, dest,
undo.append(lambda: os.close(fd)) undo.append(lambda: os.close(fd))
os.write(fd, (runsetup_template % dict( os.write(fd, (runsetup_template % dict(
distribute=distribute_loc, setuptools=setuptools_loc,
setupdir=directory, setupdir=directory,
setup=setup, setup=setup,
__file__ = setup, __file__ = setup,
...@@ -1239,7 +1239,7 @@ if _interactive: ...@@ -1239,7 +1239,7 @@ if _interactive:
runsetup_template = """ runsetup_template = """
import sys import sys
sys.path.insert(0, %(setupdir)r) sys.path.insert(0, %(setupdir)r)
sys.path.insert(0, %(distribute)r) sys.path.insert(0, %(setuptools)r)
import os, setuptools import os, setuptools
......
...@@ -127,10 +127,10 @@ about versions used. If we run the buildout in verbose mode without ...@@ -127,10 +127,10 @@ about versions used. If we run the buildout in verbose mode without
specifying a versions section: specifying a versions section:
>>> print_(system(buildout+' buildout:versions= -v'), end='') >>> print_(system(buildout+' buildout:versions= -v'), end='')
Installing 'zc.buildout', 'distribute'. Installing 'zc.buildout', 'setuptools'.
We have a develop egg: zc.buildout 1.0.0. We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'distribute'. We have the best distribution that satisfies 'setuptools'.
Picked: distribute = 0.6 Picked: setuptools = 0.6
Installing 'spam'. Installing 'spam'.
We have the best distribution that satisfies 'spam'. We have the best distribution that satisfies 'spam'.
Picked: spam = 2. Picked: spam = 2.
...@@ -149,10 +149,10 @@ that we can fix them in a versions section. ...@@ -149,10 +149,10 @@ that we can fix them in a versions section.
If we run the buildout with the versions section: If we run the buildout with the versions section:
>>> print_(system(buildout+' -v'), end='') >>> print_(system(buildout+' -v'), end='')
Installing 'zc.buildout', 'distribute'. Installing 'zc.buildout', 'setuptools'.
We have a develop egg: zc.buildout 1.0.0. We have a develop egg: zc.buildout 1.0.0.
We have the best distribution that satisfies 'distribute'. We have the best distribution that satisfies 'setuptools'.
Picked: distribute = 0.6 Picked: setuptools = 0.6
Installing 'spam'. Installing 'spam'.
We have the distribution that satisfies 'spam==1'. We have the distribution that satisfies 'spam==1'.
Uninstalling foo. Uninstalling foo.
...@@ -160,7 +160,7 @@ If we run the buildout with the versions section: ...@@ -160,7 +160,7 @@ If we run the buildout with the versions section:
recipe v1 recipe v1
We won't get output for the spam distribution, which we didn't pick, We won't get output for the spam distribution, which we didn't pick,
but we will get output for distribute, which we didn't specify but we will get output for setuptools, which we didn't specify
versions for. versions for.
You can request buildout to generate an error if it picks any You can request buildout to generate an error if it picks any
...@@ -184,8 +184,8 @@ versions: ...@@ -184,8 +184,8 @@ versions:
While: While:
Installing. Installing.
Checking for upgrades. Checking for upgrades.
Getting distribution for 'distribute'. Getting distribution for 'setuptools'.
Error: Picked: distribute = 0.6.30 Error: Picked: setuptools = 0.6.30
We can name a version something else, if we wish, using the versions option: We can name a version something else, if we wish, using the versions option:
...@@ -236,12 +236,12 @@ Since buildout 2.0, the functionality of the `buildout-versions ...@@ -236,12 +236,12 @@ Since buildout 2.0, the functionality of the `buildout-versions
<http://packages.python.org/buildout-versions/>`_ extension is part of <http://packages.python.org/buildout-versions/>`_ extension is part of
buildout itself. This makes reporting and managing versions easier. buildout itself. This makes reporting and managing versions easier.
Buildout picks a version for distribute and for the tests, we need to grab the Buildout picks a version for setuptools and for the tests, we need to grab the
version number: version number:
>>> import pkg_resources >>> import pkg_resources
>>> req = pkg_resources.Requirement.parse('distribute') >>> req = pkg_resources.Requirement.parse('setuptools')
>>> distribute_version = pkg_resources.working_set.find(req).version >>> setuptools_version = pkg_resources.working_set.find(req).version
If you set the ``show-picked-versions`` option, buildout will print If you set the ``show-picked-versions`` option, buildout will print
versions it picked at the end of its run: versions it picked at the end of its run:
...@@ -264,7 +264,7 @@ versions it picked at the end of its run: ...@@ -264,7 +264,7 @@ versions it picked at the end of its run:
Versions had to be automatically picked. Versions had to be automatically picked.
The following part definition lists the versions picked: The following part definition lists the versions picked:
[versions] [versions]
distribute = 0.6.99 setuptools = 0.6.99
spam = 2 spam = 2
When everything is pinned, no output is generated: When everything is pinned, no output is generated:
...@@ -277,12 +277,12 @@ When everything is pinned, no output is generated: ...@@ -277,12 +277,12 @@ When everything is pinned, no output is generated:
... show-picked-versions = true ... show-picked-versions = true
... ...
... [versions] ... [versions]
... distribute = %s ... setuptools = %s
... spam = 2 ... spam = 2
... ...
... [foo] ... [foo]
... recipe = spam ... recipe = spam
... ''' % (join('recipe', 'dist'), distribute_version)) ... ''' % (join('recipe', 'dist'), setuptools_version))
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS >>> print_(system(buildout), end='') # doctest: +ELLIPSIS
Updating foo. Updating foo.
recipe v2 recipe v2
...@@ -306,7 +306,7 @@ and case differences won't impact the pinning: ...@@ -306,7 +306,7 @@ and case differences won't impact the pinning:
... ...
... [foo] ... [foo]
... recipe = spam ... recipe = spam
... ''' % (join('recipe', 'dist'), distribute_version)) ... ''' % (join('recipe', 'dist'), setuptools_version))
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS >>> print_(system(buildout), end='') # doctest: +ELLIPSIS
Updating foo. Updating foo.
recipe v2 recipe v2
...@@ -318,9 +318,9 @@ extending from that versions file: ...@@ -318,9 +318,9 @@ extending from that versions file:
>>> write('my_versions.cfg', >>> write('my_versions.cfg',
... ''' ... '''
... [versions] ... [versions]
... distribute = %s ... setuptools = %s
... spam = 2 ... spam = 2
... ''' % distribute_version) ... ''' % setuptools_version)
>>> write('buildout.cfg', >>> write('buildout.cfg',
... ''' ... '''
... [buildout] ... [buildout]
...@@ -343,8 +343,8 @@ at the end. ...@@ -343,8 +343,8 @@ at the end.
>>> write('my_versions.cfg', >>> write('my_versions.cfg',
... ''' ... '''
... [versions] ... [versions]
... distribute = %s ... setuptools = %s
... ''' % distribute_version) ... ''' % setuptools_version)
>>> write('buildout.cfg', >>> write('buildout.cfg',
... ''' ... '''
... [buildout] ... [buildout]
...@@ -384,8 +384,8 @@ printing them to the console): ...@@ -384,8 +384,8 @@ printing them to the console):
>>> write('my_versions.cfg', >>> write('my_versions.cfg',
... ''' ... '''
... [versions] ... [versions]
... distribute = %s ... setuptools = %s
... ''' % distribute_version) ... ''' % setuptools_version)
>>> write('buildout.cfg', >>> write('buildout.cfg',
... ''' ... '''
... [buildout] ... [buildout]
......
...@@ -5,12 +5,12 @@ Buildouts are often used to work on packages that will be distributed ...@@ -5,12 +5,12 @@ Buildouts are often used to work on packages that will be distributed
as eggs. During development, we use develop eggs. When you've as eggs. During development, we use develop eggs. When you've
completed a development cycle, you'll need to run your setup script to completed a development cycle, you'll need to run your setup script to
generate a distribution and, perhaps, uploaded it to the Python generate a distribution and, perhaps, uploaded it to the Python
package index. If your script uses setuptools, you'll need distribute package index. If your script uses setuptools, you'll need setuptools
in your Python path, which may be an issue if you haven't installed in your Python path, which may be an issue if you haven't installed
distribute into your Python installation. setuptools into your Python installation.
The buildout setup command is helpful in a situation like this. It The buildout setup command is helpful in a situation like this. It
can be used to run a setup script and it does so with the distribute can be used to run a setup script and it does so with the setuptools
egg in the Python path and with setuptools already imported. The fact egg in the Python path and with setuptools already imported. The fact
that setuptools is imported means that you can use setuptools-based that setuptools is imported means that you can use setuptools-based
commands, like bdist_egg even with packages that don't use setuptools. commands, like bdist_egg even with packages that don't use setuptools.
......
...@@ -10,7 +10,7 @@ running the script so setuptools-provided commands are available. ...@@ -10,7 +10,7 @@ running the script so setuptools-provided commands are available.
If you use a squeaky-clean Python to do your development, the setup If you use a squeaky-clean Python to do your development, the setup
script that would import setuptools because setuptools isn't in the script that would import setuptools because setuptools isn't in the
path. Because buildout requires setuptools and knows where it has path. Because buildout requires setuptools and knows where it has
installed a distribute egg, it adds the distribute egg to the Python installed a setuptools egg, it adds the setuptools egg to the Python
path before running the script. To run a setup script, use the path before running the script. To run a setup script, use the
buildout setup command, passing the name of a script or a directory buildout setup command, passing the name of a script or a directory
containing a setup script and arguments to the script. Let's look at containing a setup script and arguments to the script. Let's look at
......
...@@ -46,8 +46,8 @@ print_ = zc.buildout.buildout.print_ ...@@ -46,8 +46,8 @@ print_ = zc.buildout.buildout.print_
fsync = getattr(os, 'fsync', lambda fileno: None) fsync = getattr(os, 'fsync', lambda fileno: None)
is_win32 = sys.platform == 'win32' is_win32 = sys.platform == 'win32'
distribute_location = pkg_resources.working_set.find( setuptools_location = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('distribute')).location pkg_resources.Requirement.parse('setuptools')).location
def cat(dir, *names): def cat(dir, *names):
path = os.path.join(dir, *names) path = os.path.join(dir, *names)
...@@ -143,7 +143,7 @@ def _runsetup(setup, *args): ...@@ -143,7 +143,7 @@ def _runsetup(setup, *args):
os.chdir(os.path.dirname(setup)) os.chdir(os.path.dirname(setup))
zc.buildout.easy_install.call_subprocess( zc.buildout.easy_install.call_subprocess(
[sys.executable, setup] + args, [sys.executable, setup] + args,
env=dict(os.environ, PYTHONPATH=distribute_location)) env=dict(os.environ, PYTHONPATH=setuptools_location))
if os.path.exists('build'): if os.path.exists('build'):
rmtree('build') rmtree('build')
finally: finally:
...@@ -525,6 +525,9 @@ normalize_exception_type_for_python_2_and_3 = ( ...@@ -525,6 +525,9 @@ normalize_exception_type_for_python_2_and_3 = (
not_found = (re.compile(r'Not found: [^\n]+/(\w|\.)+/\r?\n'), '') not_found = (re.compile(r'Not found: [^\n]+/(\w|\.)+/\r?\n'), '')
adding_find_link = (re.compile(r"Adding find link '[^']+'"
r" from setuptools 0.7/\r?\n"), '')
ignore_not_upgrading = ( ignore_not_upgrading = (
re.compile( re.compile(
'Not upgrading because not running a local buildout command.\n' 'Not upgrading because not running a local buildout command.\n'
......
This diff is collapsed.
...@@ -2,13 +2,13 @@ Automatic Buildout Updates ...@@ -2,13 +2,13 @@ Automatic Buildout Updates
========================== ==========================
When a buildout is run, one of the first steps performed is to check for When a buildout is run, one of the first steps performed is to check for
updates to either zc.buildout or distribute. To updates to either zc.buildout or setuptools. To
demonstrate this, we've created some "new releases" of buildout and demonstrate this, we've created some "new releases" of buildout and
distribute in a new_releases folder: setuptools in a new_releases folder:
>>> ls(new_releases) >>> ls(new_releases)
d distribute d setuptools
- distribute-99.99-py2.4.egg - setuptools-99.99-py2.4.egg
d zc.buildout d zc.buildout
- zc.buildout-99.99-py2.4.egg - zc.buildout-99.99-py2.4.egg
...@@ -26,7 +26,7 @@ Let's update the sample buildout.cfg to look in this area: ...@@ -26,7 +26,7 @@ Let's update the sample buildout.cfg to look in this area:
... recipe = showversions ... recipe = showversions
... """ % dict(new_releases=new_releases)) ... """ % dict(new_releases=new_releases))
We'll also include a recipe that echos the versions of distribute and We'll also include a recipe that echos the versions of setuptools and
zc.buildout used: zc.buildout used:
>>> mkdir(sample_buildout, 'showversions') >>> mkdir(sample_buildout, 'showversions')
...@@ -43,7 +43,7 @@ zc.buildout used: ...@@ -43,7 +43,7 @@ zc.buildout used:
... pass ... pass
... ...
... def install(self): ... def install(self):
... for project in 'zc.buildout', 'distribute': ... for project in 'zc.buildout', 'setuptools':
... req = pkg_resources.Requirement.parse(project) ... req = pkg_resources.Requirement.parse(project)
... print_(project, pkg_resources.working_set.find(req).version) ... print_(project, pkg_resources.working_set.find(req).version)
... return () ... return ()
...@@ -68,17 +68,17 @@ new versions found in new releases: ...@@ -68,17 +68,17 @@ new versions found in new releases:
>>> print_(system(buildout), end='') >>> print_(system(buildout), end='')
Getting distribution for 'zc.buildout>=1.99'. Getting distribution for 'zc.buildout>=1.99'.
Got zc.buildout 99.99. Got zc.buildout 99.99.
Getting distribution for 'distribute'. Getting distribution for 'setuptools'.
Got distribute 99.99. Got setuptools 99.99.
Upgraded: Upgraded:
zc.buildout version 99.99, zc.buildout version 99.99,
distribute version 99.99; setuptools version 99.99;
restarting. restarting.
Generated script '/sample-buildout/bin/buildout'. Generated script '/sample-buildout/bin/buildout'.
Develop: '/sample-buildout/showversions' Develop: '/sample-buildout/showversions'
Installing show-versions. Installing show-versions.
zc.buildout 99.99 zc.buildout 99.99
distribute 99.99 setuptools 99.99
Our buildout script has been updated to use the new eggs: Our buildout script has been updated to use the new eggs:
...@@ -88,7 +88,7 @@ Our buildout script has been updated to use the new eggs: ...@@ -88,7 +88,7 @@ Our buildout script has been updated to use the new eggs:
import sys import sys
sys.path[0:0] = [ sys.path[0:0] = [
'/sample-buildout/eggs/zc.buildout-99.99-py2.4.egg', '/sample-buildout/eggs/zc.buildout-99.99-py2.4.egg',
'/sample-buildout/eggs/distribute-99.99-py2.4.egg', '/sample-buildout/eggs/setuptools-99.99-py2.4.egg',
] ]
<BLANKLINE> <BLANKLINE>
import zc.buildout.buildout import zc.buildout.buildout
...@@ -97,7 +97,7 @@ Our buildout script has been updated to use the new eggs: ...@@ -97,7 +97,7 @@ Our buildout script has been updated to use the new eggs:
sys.exit(zc.buildout.buildout.main()) sys.exit(zc.buildout.buildout.main())
Now, let's recreate the sample buildout. If we specify constraints on Now, let's recreate the sample buildout. If we specify constraints on
the versions of zc.buildout and distribute to use, running the buildout the versions of zc.buildout and setuptools to use, running the buildout
will install earlier versions of these packages: will install earlier versions of these packages:
>>> write(sample_buildout, 'buildout.cfg', >>> write(sample_buildout, 'buildout.cfg',
...@@ -110,7 +110,7 @@ will install earlier versions of these packages: ...@@ -110,7 +110,7 @@ will install earlier versions of these packages:
... ...
... [versions] ... [versions]
... zc.buildout = < 99 ... zc.buildout = < 99
... distribute = < 99 ... setuptools = < 99
... ...
... [show-versions] ... [show-versions]
... recipe = showversions ... recipe = showversions
...@@ -121,13 +121,13 @@ Now we can see that we actually "upgrade" to an earlier version. ...@@ -121,13 +121,13 @@ Now we can see that we actually "upgrade" to an earlier version.
>>> print_(system(buildout), end='') >>> print_(system(buildout), end='')
Upgraded: Upgraded:
zc.buildout version 1.4.4; zc.buildout version 1.4.4;
distribute version 0.6; setuptools version 0.6;
restarting. restarting.
Generated script '/sample-buildout/bin/buildout'. Generated script '/sample-buildout/bin/buildout'.
Develop: '/sample-buildout/showversions' Develop: '/sample-buildout/showversions'
Updating show-versions. Updating show-versions.
zc.buildout 1.0.0 zc.buildout 1.0.0
distribute 0.6 setuptools 0.6
There are a number of cases, described below, in which the updates There are a number of cases, described below, in which the updates
don't happen. don't happen.
...@@ -150,7 +150,7 @@ We won't upgrade in offline mode: ...@@ -150,7 +150,7 @@ We won't upgrade in offline mode:
Develop: '/sample-buildout/showversions' Develop: '/sample-buildout/showversions'
Updating show-versions. Updating show-versions.
zc.buildout 1.0.0 zc.buildout 1.0.0
distribute 0.6 setuptools 0.6
Or in non-newest mode: Or in non-newest mode:
...@@ -158,7 +158,7 @@ Or in non-newest mode: ...@@ -158,7 +158,7 @@ Or in non-newest mode:
Develop: '/sample-buildout/showversions' Develop: '/sample-buildout/showversions'
Updating show-versions. Updating show-versions.
zc.buildout 1.0.0 zc.buildout 1.0.0
distribute 0.6 setuptools 0.6
We also won't upgrade if the buildout script being run isn't in the We also won't upgrade if the buildout script being run isn't in the
buildouts bin directory. To see this we'll create a new buildout buildouts bin directory. To see this we'll create a new buildout
...@@ -181,8 +181,8 @@ directory: ...@@ -181,8 +181,8 @@ directory:
Creating directory '/sample_buildout2/develop-eggs'. Creating directory '/sample_buildout2/develop-eggs'.
Getting distribution for 'zc.buildout>=1.99'. Getting distribution for 'zc.buildout>=1.99'.
Got zc.buildout 99.99. Got zc.buildout 99.99.
Getting distribution for 'distribute'. Getting distribution for 'setuptools'.
Got distribute 99.99. Got setuptools 99.99.
Not upgrading because not running a local buildout command. Not upgrading because not running a local buildout command.
>>> ls('bin') >>> ls('bin')
...@@ -206,14 +206,14 @@ directory: ...@@ -206,14 +206,14 @@ directory:
>>> print_(system(buildout), end='') >>> print_(system(buildout), end='')
Upgraded: Upgraded:
zc.buildout version 99.99, zc.buildout version 99.99,
distribute version 99.99; setuptools version 99.99;
restarting. restarting.
Generated script '/sample-buildout/bin/buildout'. Generated script '/sample-buildout/bin/buildout'.
Develop: '/sample-buildout/showversions' Develop: '/sample-buildout/showversions'
Unused options for buildout: 'relative-paths'. Unused options for buildout: 'relative-paths'.
Updating show-versions. Updating show-versions.
zc.buildout 99.99 zc.buildout 99.99
distribute 99.99 setuptools 99.99
>>> cat('bin', 'buildout') # doctest +ELL >>> cat('bin', 'buildout') # doctest +ELL
#!/usr/local/bin/python2.7 #!/usr/local/bin/python2.7
...@@ -227,7 +227,7 @@ directory: ...@@ -227,7 +227,7 @@ directory:
import sys import sys
sys.path[0:0] = [ sys.path[0:0] = [
join(base, 'eggs/zc.buildout-99.99-py3.3.egg'), join(base, 'eggs/zc.buildout-99.99-py3.3.egg'),
join(base, 'eggs/distribute-99.99-py3.3.egg'), join(base, 'eggs/setuptools-99.99-py3.3.egg'),
] ]
<BLANKLINE> <BLANKLINE>
import zc.buildout.buildout import zc.buildout.buildout
...@@ -282,7 +282,7 @@ gives us a sys.exit: ...@@ -282,7 +282,7 @@ gives us a sys.exit:
... ...
... [versions] ... [versions]
... zc.buildout = < 99 ... zc.buildout = < 99
... distribute = < 99 ... setuptools = < 99
... ...
... [fail] ... [fail]
... recipe = failrecipe ... recipe = failrecipe
...@@ -293,7 +293,7 @@ Run the buildout: ...@@ -293,7 +293,7 @@ Run the buildout:
>>> print_(system(buildout, with_exit_code=True), end='') >>> print_(system(buildout, with_exit_code=True), end='')
Upgraded: Upgraded:
zc.buildout version 1.4.4; zc.buildout version 1.4.4;
distribute version 0.6; setuptools version 0.6;
restarting. restarting.
Generated script '/sample-buildout/bin/buildout'. Generated script '/sample-buildout/bin/buildout'.
Develop: '/sample-buildout/failrecipe' Develop: '/sample-buildout/failrecipe'
......
...@@ -74,7 +74,7 @@ Now, if we look at the buildout eggs directory: ...@@ -74,7 +74,7 @@ Now, if we look at the buildout eggs directory:
>>> ls(sample_buildout, 'eggs') >>> ls(sample_buildout, 'eggs')
d demo-0.2-py2.3.egg d demo-0.2-py2.3.egg
d demoneeded-1.1-py2.3.egg d demoneeded-1.1-py2.3.egg
d distribute-0.6-py2.3.egg - setuptools-0.7-py2.3.egg
d zc.buildout-1.0-py2.3.egg d zc.buildout-1.0-py2.3.egg
We see that we got an egg for demo that met the requirement, as well We see that we got an egg for demo that met the requirement, as well
...@@ -263,7 +263,7 @@ We didn't get an update for demo: ...@@ -263,7 +263,7 @@ We didn't get an update for demo:
>>> ls(sample_buildout, 'eggs') >>> ls(sample_buildout, 'eggs')
d demo-0.2-py2.3.egg d demo-0.2-py2.3.egg
d demoneeded-1.1-py2.3.egg d demoneeded-1.1-py2.3.egg
d distribute-0.6-py2.3.egg - setuptools-0.7-py2.3.egg
d zc.buildout-1.0-py2.3.egg d zc.buildout-1.0-py2.3.egg
If we run the buildout on the default online and newest modes, If we run the buildout on the default online and newest modes,
...@@ -281,7 +281,7 @@ Then we'll get a new demo egg: ...@@ -281,7 +281,7 @@ Then we'll get a new demo egg:
d demo-0.2-py2.3.egg d demo-0.2-py2.3.egg
d demo-0.3-py2.3.egg d demo-0.3-py2.3.egg
d demoneeded-1.1-py2.3.egg d demoneeded-1.1-py2.3.egg
d distribute-0.6-py2.4.egg - setuptools-0.7-py2.4.egg
d zc.buildout-1.0-py2.4.egg d zc.buildout-1.0-py2.4.egg
The script is updated too: The script is updated too:
......
...@@ -106,7 +106,7 @@ computed by the egg recipe by looking at .installed.cfg: ...@@ -106,7 +106,7 @@ computed by the egg recipe by looking at .installed.cfg:
__buildout_installed__ = __buildout_installed__ =
__buildout_signature__ = sample-6aWMvV2EJ9Ijq+bR8ugArQ== __buildout_signature__ = sample-6aWMvV2EJ9Ijq+bR8ugArQ==
zc.recipe.egg-cAsnudgkduAa/Fd+WJIM6Q== zc.recipe.egg-cAsnudgkduAa/Fd+WJIM6Q==
distribute-0.6-py2.4.egg setuptools-0.7-py2.4.egg
zc.buildout-+rYeCcmFuD1K/aB77XTj5A== zc.buildout-+rYeCcmFuD1K/aB77XTj5A==
_b = /sample-buildout/bin _b = /sample-buildout/bin
_d = /sample-buildout/develop-eggs _d = /sample-buildout/develop-eggs
......
...@@ -145,11 +145,11 @@ class Scripts(Eggs): ...@@ -145,11 +145,11 @@ class Scripts(Eggs):
if get_bool(options, 'dependent-scripts'): if get_bool(options, 'dependent-scripts'):
# Generate scripts for all packages in the working set, # Generate scripts for all packages in the working set,
# except distribute. # except setuptools.
reqs = list(reqs) reqs = list(reqs)
for dist in ws: for dist in ws:
name = dist.project_name name = dist.project_name
if name != 'distribute' and name not in reqs: if name != 'setuptools' and name not in reqs:
reqs.append(name) reqs.append(name)
return zc.buildout.easy_install.scripts( return zc.buildout.easy_install.scripts(
......
...@@ -51,7 +51,7 @@ def test_suite(): ...@@ -51,7 +51,7 @@ def test_suite():
zc.buildout.testing.not_found, zc.buildout.testing.not_found,
(re.compile('[d-] zc.buildout(-\S+)?[.]egg(-link)?'), (re.compile('[d-] zc.buildout(-\S+)?[.]egg(-link)?'),
'zc.buildout.egg'), 'zc.buildout.egg'),
(re.compile('[d-] distribute-[^-]+-'), 'distribute-X-'), (re.compile('[d-] setuptools-[^-]+-'), 'setuptools-X-'),
(re.compile(r'eggs\\\\demo'), 'eggs/demo'), (re.compile(r'eggs\\\\demo'), 'eggs/demo'),
(re.compile(r'[a-zA-Z]:\\\\foo\\\\bar'), '/foo/bar'), (re.compile(r'[a-zA-Z]:\\\\foo\\\\bar'), '/foo/bar'),
]) ])
...@@ -66,7 +66,7 @@ def test_suite(): ...@@ -66,7 +66,7 @@ def test_suite():
(re.compile('__buildout_signature__ = ' (re.compile('__buildout_signature__ = '
'sample-\S+\s+' 'sample-\S+\s+'
'zc.recipe.egg-\S+\s+' 'zc.recipe.egg-\S+\s+'
'distribute-\S+\s+' 'setuptools-\S+\s+'
'zc.buildout-\S+\s*' 'zc.buildout-\S+\s*'
), ),
'__buildout_signature__ = sample- zc.recipe.egg-'), '__buildout_signature__ = sample- zc.recipe.egg-'),
......
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