Commit 5058b42c authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Support on the fly patches in easy_install.

Version string is now N.N.N.postN to follow http://legacy.python.org/dev/peps/pep-0440/ .
(Ideally it should be N.N.N+SlapOSNNN, but version string containing '+' sign does now work
with older setuptools, that can be still used at the very beginning of bootstrap process.)
parent 0b87d146
1.7.1.post6
-----------
- Version string is now N.N.N.postN to follow http://legacy.python.org/dev/peps/pep-0440/ .
(Ideally it should be N.N.N+SlapOSNNN, but version string containing '+' sign does now work
with older setuptools, that can be still used at the very beginning of bootstrap process.)
- Support on the fly patches in easy_install.
1.7.1-dev-SlapOS-005
--------------------
......@@ -74,7 +82,7 @@
- Add support of networkcache for pypi index, extensions and recipes using
buildout internals.
https://bugs.launchpad.net/zc.buildout/+bug/1041249
https://bugs.launchpad.net/zc.buildout/+bug/1041249
1.6.0-dev-SlapOS-006
--------------------
......
......@@ -12,7 +12,7 @@
#
##############################################################################
name = "zc.buildout"
version = "1.7.1-dev-SlapOS-005"
version = "1.7.1.post6"
import os
from setuptools import setup
......
......@@ -78,6 +78,9 @@ BROKEN_DASH_S_WARNING = (
'to the buildout script. Alternatively, use a Python executable with a '
'working -S (such as a standard Python binary).')
PATCH_MARKER = 'SlapOSPatched'
orig_versions_re = re.compile(r'[+\-]%s\d+' % PATCH_MARKER)
if is_jython:
import java.lang.System
jython_os_name = (java.lang.System.getProperties()['os.name']).lower()
......@@ -801,6 +804,11 @@ class Installer:
shutil.rmtree(tmp)
def _obtain(self, requirement, source=None):
# get the non-patched version
req = str(requirement)
if PATCH_MARKER in req:
requirement = pkg_resources.Requirement.parse(re.sub(orig_versions_re, '', req))
# initialize out index for this project:
index = self._index
......@@ -1054,7 +1062,7 @@ class Installer:
return requirement
def install(self, specs, working_set=None):
def install(self, specs, working_set=None, patch_dict=None):
logger.debug('Installing %s.', repr(specs)[1:-1])
......@@ -1074,6 +1082,9 @@ class Installer:
ws = working_set
for requirement in requirements:
if patch_dict and requirement.project_name in patch_dict:
self._env.scan(
self.build(str(requirement), {}, patch_dict=patch_dict))
for dist in self._get_dist(requirement, ws, self._always_unzip):
ws.add(dist)
self._maybe_add_setuptools(ws, dist)
......@@ -1133,7 +1144,7 @@ class Installer:
logger.debug('Egg from site-packages: %s', dist)
return ws
def build(self, spec, build_ext):
def build(self, spec, build_ext, patch_dict=None):
requirement = self._constrain(pkg_resources.Requirement.parse(spec))
......@@ -1177,12 +1188,31 @@ class Installer:
)
base = os.path.dirname(setups[0])
setup_cfg_dict = {'build_ext':build_ext}
patch_dict = (patch_dict or {}).get(re.sub('[<>=].*', '', spec))
if patch_dict:
setup_cfg_dict.update(
{'egg_info':{'tag_build':'+%s%03d' % (PATCH_MARKER,
patch_dict['patch_revision'])}})
for patch in patch_dict['patches']:
url, md5sum = (patch.strip().split('#', 1) + [''])[:2]
download = zc.buildout.download.Download()
path, is_temp = download(url, md5sum=md5sum or None,
path=os.path.join(tmp, 'patch'))
args = [patch_dict['patch_binary']] + patch_dict['patch_options']
kwargs = {'cwd':base,
'stdin':open(path)}
popen = subprocess.Popen(args, **kwargs)
popen.communicate()
if popen.returncode != 0:
raise subprocess.CalledProcessError(
popen.returncode, ' '.join(args))
setup_cfg = os.path.join(base, 'setup.cfg')
if not os.path.exists(setup_cfg):
f = open(setup_cfg, 'w')
f.close()
setuptools.command.setopt.edit_config(
setup_cfg, dict(build_ext=build_ext))
setup_cfg, setup_cfg_dict)
dists = self._call_easy_install(
base, pkg_resources.WorkingSet(),
......@@ -1265,7 +1295,7 @@ def install(specs, dest,
upload_dir_url=None, upload_cache_url=None,
signature_certificate_list=None, signature_private_key_file=None,
shacache_cert_file=None, shacache_key_file=None,
shadir_cert_file=None, shadir_key_file=None):
shadir_cert_file=None, shadir_key_file=None, patch_dict=None):
installer = Installer(
dest, links, index, executable, always_unzip, path, newest,
versions, use_dependency_links, allow_hosts=allow_hosts,
......@@ -1280,20 +1310,21 @@ def install(specs, dest,
shacache_key_file=shacache_key_file,
shadir_cert_file=shadir_cert_file,
shadir_key_file=shadir_key_file)
return installer.install(specs, working_set)
return installer.install(specs, working_set, patch_dict=patch_dict)
def build(spec, dest, build_ext,
links=(), index=None,
executable=sys.executable,
path=None, newest=True, versions=None, allow_hosts=('*',),
include_site_packages=None, allowed_eggs_from_site_packages=None):
include_site_packages=None, allowed_eggs_from_site_packages=None,
patch_dict=None):
installer = Installer(
dest, links, index, executable, True, path, newest, versions,
allow_hosts=allow_hosts,
include_site_packages=include_site_packages,
allowed_eggs_from_site_packages=allowed_eggs_from_site_packages)
return installer.build(spec, build_ext)
return installer.build(spec, build_ext, patch_dict=patch_dict)
......
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