Merge "Update RPM-specs to 2013.1.2 version" into openstack-ci/build/grizzly
[openstack-build/cinder-build.git] / rpm / SOURCES / 0002-Use-updated-parallel-install-versions-of-epel-packag.patch
1 From 632186c1a4e3d971bab1d017ea3289e92c85d86c Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
3 Date: Wed, 24 Oct 2012 13:44:37 +0100
4 Subject: [PATCH] Use updated parallel install versions of epel package
5
6 Use sqlalchemy >= 0.6.3 WebOb >= 1.0 Routes >= 1.12.3 PasteDeploy >= 1.5.0
7 and depend on the parallel installable
8 versions of these packages to satisfy those requirements.
9
10 Delve into pkg_resources a little to get it to modify sys.path,
11 so that our parallel installed egg takes precedence over the
12 system default module versions.
13 (cherry picked from commit 7b25747ffc21d0771e864f57ab2088725c8851f0)
14
15 Conflicts:
16         bin/cinder-manage
17 ---
18  bin/cinder-manage                 |  7 ++++---
19  cinder/__init__.py                | 30 ++++++++++++++++++++++++++++++
20  cinder/db/sqlalchemy/migration.py |  7 ++++++-
21  3 files changed, 40 insertions(+), 4 deletions(-)
22
23 diff --git a/bin/cinder-manage b/bin/cinder-manage
24 index de7955d..364944a 100755
25 --- a/bin/cinder-manage
26 +++ b/bin/cinder-manage
27 @@ -59,9 +59,6 @@ import os
28  import sys
29  import uuid
30  
31 -from sqlalchemy import create_engine, MetaData, Table
32 -from sqlalchemy.ext.declarative import declarative_base
33 -from sqlalchemy.orm import sessionmaker
34  
35  
36  # If ../cinder/__init__.py exists, add ../ to Python search path, so that
37 @@ -87,6 +84,10 @@ from cinder.openstack.common import uuidutils
38  from cinder import utils
39  from cinder import version
40  
41 +from sqlalchemy import create_engine, MetaData, Table
42 +from sqlalchemy.orm import sessionmaker
43 +from sqlalchemy.ext.declarative import declarative_base
44 +
45  FLAGS = flags.FLAGS
46  
47  
48 diff --git a/cinder/__init__.py b/cinder/__init__.py
49 index f8db8e8..1b4ac39 100644
50 --- a/cinder/__init__.py
51 +++ b/cinder/__init__.py
52 @@ -31,6 +31,36 @@
53  .. moduleauthor:: Andy Smith <andy@anarkystic.com>
54  """
55  
56 +import sys
57 +import pkg_resources
58 +
59 +# If there is a conflicting non egg module,
60 +# i.e. an older standard system module installed,
61 +# then replace it with this requirement
62 +def replace_dist(requirement):
63 +    try:
64 +        return pkg_resources.require(requirement)
65 +    except pkg_resources.VersionConflict:
66 +        e = sys.exc_info()[1]
67 +        dist=e.args[0]
68 +        req=e.args[1]
69 +        if dist.key == req.key and not dist.location.endswith('.egg'):
70 +            del pkg_resources.working_set.by_key[dist.key]
71 +            # We assume there is no need to adjust sys.path
72 +            # and the associated pkg_resources.working_set.entries
73 +            return pkg_resources.require(requirement)
74 +
75 +replace_dist("WebOb >= 1.0")
76 +replace_dist("SQLAlchemy >= 0.6.3")
77 +replace_dist("Routes >= 1.12.3")
78 +
79 +replace_dist("PasteDeploy >= 1.5.0")
80 +# This hack is needed because replace_dist() results in
81 +# the standard paste module path being at the start of __path__.
82 +# TODO: See can we get pkg_resources to do the right thing directly
83 +import paste
84 +paste.__path__.insert(0, paste.__path__.pop(-1))
85 +
86  import gettext
87  
88  
89 diff --git a/cinder/db/sqlalchemy/migration.py b/cinder/db/sqlalchemy/migration.py
90 index 5365d9c..e2fcd83 100644
91 --- a/cinder/db/sqlalchemy/migration.py
92 +++ b/cinder/db/sqlalchemy/migration.py
93 @@ -57,7 +57,12 @@ if (not hasattr(migrate, '__version__') or
94  
95  
96  # NOTE(jkoelker) Delay importing migrate until we are patched
97 -from migrate import exceptions as versioning_exceptions
98 +try:
99 +    # Try the more specific path first (migrate <= 0.6)
100 +    from migrate.versioning import exceptions as versioning_exceptions
101 +except ImportError:
102 +    # Use the newer path (migrate >= 0.7)
103 +    from migrate import exceptions as versioning_exceptions
104  from migrate.versioning import api as versioning_api
105  from migrate.versioning.repository import Repository
106