Commit 4f679e8d authored by Julien Muchembled's avatar Julien Muchembled

Merge zc.recipe.egg branch

Conflicts:
	zc.recipe.egg_/setup.py
	zc.recipe.egg_/src/zc/recipe/egg/egg.py
parents 792deebc 7af0dfd0
1.3.2.post4
-----------
- Fix a regression in 1.3.2.post3 that breaks setup-eggs option.
1.3.2.post3
-----------
- Support environment in zc.recipe.egg:develop.
1.3.2.post2
-----------
- Version string is now N.N.N.devN to follow http://legacy.python.org/dev/peps/pep-0440/ .
- Support on the fly patches in zc.recipe.egg by ``EGGNAME-patches``,
``EGGNAME-patch-options``, ``EGGNAME-patch-binary`` (or
``patch-binary``) and ``EGGNAME-patch-revision`` options.
- Support on the fly patches in zc.recipe.egg:custom by ``patches``,
``patch-options``, ``patch-binary`` and ``patch-revision`` options.
(options ``EGGNAME-*`` are also supported as well).
1.3.2nxd001
-----------
- Add setup-eggs option in zc.recipe.egg:custom.
...@@ -32,11 +32,69 @@ class Base: ...@@ -32,11 +32,69 @@ class Base:
python = options.get('python', buildout['buildout']['python']) python = options.get('python', buildout['buildout']['python'])
options['executable'] = buildout[python]['executable'] options['executable'] = buildout[python]['executable']
environment_section = options.get('environment')
if environment_section:
self.environment = buildout[environment_section]
else:
self.environment = {}
environment_data = self.environment.items()
environment_data.sort()
options['_environment-data'] = repr(environment_data)
self.build_ext = build_ext(buildout, options) self.build_ext = build_ext(buildout, options)
def install(self):
self._set_environment()
try:
return self._install()
finally:
self._restore_environment()
def update(self): def update(self):
return self.install() return self.install()
def _set_environment(self):
self._saved_environment = {}
for key, value in self.environment.items():
if key in os.environ:
self._saved_environment[key] = os.environ[key]
# Interpolate value with variables from environment. Maybe there
# should be a general way of doing this in buildout with something
# like ${environ:foo}:
os.environ[key] = value % os.environ
def _restore_environment(self):
for key in self.environment:
if key in self._saved_environment:
os.environ[key] = self._saved_environment[key]
else:
try:
del os.environ[key]
except KeyError:
pass
def _get_patch_dict(self, options, distribution):
patch_dict = {}
global_patch_binary = options.get('patch-binary', 'patch')
def get_option(egg, key, default):
return options.get('%s-%s' % (egg, key),
options.get(key, default))
egg = re.sub('[<>=].*', '', distribution)
patches = filter(lambda x:x,
map(lambda x:x.strip(),
get_option(egg, 'patches', '').splitlines()))
if not patches:
return patch_dict
patch_options = get_option(egg, 'patch-options', '-p0').split()
patch_binary = get_option(egg, 'patch-binary', global_patch_binary)
patch_revision = int(get_option(egg, 'patch-revision', len(patches)))
patch_dict[egg] = {
'patches':patches,
'patch_options':patch_options,
'patch_binary':patch_binary,
'patch_revision':patch_revision,
}
return patch_dict
class Custom(Base): class Custom(Base):
...@@ -57,25 +115,16 @@ class Custom(Base): ...@@ -57,25 +115,16 @@ class Custom(Base):
options['index'] = index options['index'] = index
self.index = index self.index = index
environment_section = options.get('environment')
if environment_section:
self.environment = buildout[environment_section]
else:
self.environment = {}
environment_data = self.environment.items()
environment_data.sort()
options['_environment-data'] = repr(environment_data)
options['_e'] = buildout['buildout']['eggs-directory'] options['_e'] = buildout['buildout']['eggs-directory']
assert options.get('unzip') in ('true', 'false', None) assert options.get('unzip') in ('true', 'false', None)
if buildout['buildout'].get('offline') == 'true': if buildout['buildout'].get('offline') == 'true':
self.install = lambda: () self._install = lambda: ()
self.newest = buildout['buildout'].get('newest') == 'true' self.newest = buildout['buildout'].get('newest') == 'true'
def install(self): def _install(self):
options = self.options options = self.options
distribution = options.get('egg') distribution = options.get('egg')
if distribution is None: if distribution is None:
...@@ -88,36 +137,28 @@ class Custom(Base): ...@@ -88,36 +137,28 @@ class Custom(Base):
distribution = options.get('egg', options.get('eggs', self.name) distribution = options.get('egg', options.get('eggs', self.name)
).strip() ).strip()
self._set_environment()
try: setup_eggs = [
return zc.buildout.easy_install.build( r.strip()
distribution, options['_d'], self.build_ext, for r in options.get('setup-eggs', '').split('\n')
self.links, self.index, options['executable'], [options['_e']], if r.strip()]
if setup_eggs:
ws = zc.buildout.easy_install.install(
setup_eggs, options['_e'],
links=self.links,
index=self.index,
executable=options['executable'],
path=[options['_d'], options['_e']],
newest=self.newest, newest=self.newest,
) )
finally: extra_path = os.pathsep.join(ws.entries)
self._restore_environment() self.environment['PYTHONEXTRAPATH'] = os.environ['PYTHONEXTRAPATH'] = extra_path
def _set_environment(self):
self._saved_environment = {}
for key, value in self.environment.items():
if key in os.environ:
self._saved_environment[key] = os.environ[key]
# Interpolate value with variables from environment. Maybe there
# should be a general way of doing this in buildout with something
# like ${environ:foo}:
os.environ[key] = value % os.environ
def _restore_environment(self): patch_dict = self._get_patch_dict(options, distribution)
for key in self.environment: return zc.buildout.easy_install.build(
if key in self._saved_environment: distribution, options['_d'], self.build_ext,
os.environ[key] = self._saved_environment[key] self.links, self.index, options['executable'], [options['_e']],
else: newest=self.newest, patch_dict=patch_dict)
try:
del os.environ[key]
except KeyError:
pass
class Develop(Base): class Develop(Base):
...@@ -127,7 +168,7 @@ class Develop(Base): ...@@ -127,7 +168,7 @@ class Develop(Base):
options['setup'] = os.path.join(buildout['buildout']['directory'], options['setup'] = os.path.join(buildout['buildout']['directory'],
options['setup']) options['setup'])
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,
......
...@@ -61,6 +61,33 @@ class Eggs(object): ...@@ -61,6 +61,33 @@ class Eggs(object):
python = options.setdefault('python', b_options['python']) python = options.setdefault('python', b_options['python'])
options['executable'] = buildout[python]['executable'] options['executable'] = buildout[python]['executable']
def _get_patch_dict(self, options, distribution_list):
patch_dict = {}
global_patch_binary = options.get('patch-binary', 'patch')
def get_option(egg, key, default):
if len(distribution_list) == 1:
return options.get('%s-%s' % (egg, key),
options.get(key, default))
else:
return options.get('%s-%s' % (egg, key), default)
for distribution in distribution_list:
egg = re.sub('[<>=].*', '', distribution)
patches = filter(lambda x:x,
map(lambda x:x.strip(),
get_option(egg, 'patches', '').splitlines()))
if not patches:
continue
patch_options = get_option(egg, 'patch-options', '-p0').split()
patch_binary = get_option(egg, 'patch-binary', global_patch_binary)
patch_revision = int(get_option(egg, 'patch-revision', len(patches)))
patch_dict[egg] = {
'patches':patches,
'patch_options':patch_options,
'patch_binary':patch_binary,
'patch_revision':patch_revision,
}
return patch_dict
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
...@@ -88,6 +115,7 @@ class Eggs(object): ...@@ -88,6 +115,7 @@ class Eggs(object):
kw = {} kw = {}
if 'unzip' in options: if 'unzip' in options:
kw['always_unzip'] = options.query_bool('unzip', None) kw['always_unzip'] = options.query_bool('unzip', None)
for option_key, kw_key in ( for option_key, kw_key in (
('__networkcache__download-cache-url', 'download_cache_url'), ('__networkcache__download-cache-url', 'download_cache_url'),
('__networkcache__download-dir-url', 'download_dir_url'), ('__networkcache__download-dir-url', 'download_dir_url'),
...@@ -109,6 +137,7 @@ class Eggs(object): ...@@ -109,6 +137,7 @@ class Eggs(object):
else: else:
kw[kw_key] = b_options[option_key] kw[kw_key] = b_options[option_key]
patch_dict = self._get_patch_dict(options, distributions)
ws = zc.buildout.easy_install.install( ws = zc.buildout.easy_install.install(
distributions, options['eggs-directory'], distributions, options['eggs-directory'],
links=self.links, links=self.links,
...@@ -119,6 +148,7 @@ class Eggs(object): ...@@ -119,6 +148,7 @@ class Eggs(object):
include_site_packages=self.include_site_packages, include_site_packages=self.include_site_packages,
allowed_eggs_from_site_packages=self.allowed_eggs, allowed_eggs_from_site_packages=self.allowed_eggs,
allow_hosts=self.allow_hosts, allow_hosts=self.allow_hosts,
patch_dict=patch_dict,
**kw) **kw)
return orig_distributions, ws return orig_distributions, ws
......
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