This repository has been archived by the owner on May 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0002-Use-updated-parallel-install-versions-of-epel-packag.patch
99 lines (88 loc) · 3.63 KB
/
0002-Use-updated-parallel-install-versions-of-epel-packag.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
From 09f474a22aa79e1fa13db7e66d1af7bc0e6b0dc1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Wed, 24 Oct 2012 13:44:37 +0100
Subject: [PATCH] Use updated parallel install versions of epel package
Use sqlalchemy >= 0.6.3 WebOb >= 1.2 Routes >= 1.12.3 PasteDeploy >= 1.5.0
and depend on the parallel installable
versions of these packages to satisfy those requirements.
Delve into pkg_resources a little to get it to modify sys.path,
so that our parallel installed egg takes precedence over the
system default module versions.
---
bin/cinder-manage | 7 +++----
cinder/__init__.py | 30 ++++++++++++++++++++++++++++++
cinder/db/sqlalchemy/migration.py | 7 ++++++-
3 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/bin/cinder-manage b/bin/cinder-manage
index 021c1c8..c809b30 100755
--- a/bin/cinder-manage
+++ b/bin/cinder-manage
@@ -60,10 +60,6 @@ import sys
import uuid
from oslo.config import cfg
-from sqlalchemy import create_engine, MetaData, Table
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy.orm import sessionmaker
-
# If ../cinder/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
@@ -87,6 +83,9 @@ from cinder.openstack.common import uuidutils
from cinder import utils
from cinder import version
+from sqlalchemy import create_engine, MetaData, Table
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import sessionmaker
CONF = cfg.CONF
diff --git a/cinder/__init__.py b/cinder/__init__.py
index d765b08..720320e 100644
--- a/cinder/__init__.py
+++ b/cinder/__init__.py
@@ -30,3 +30,33 @@
.. moduleauthor:: Manish Singh <[email protected]>
.. moduleauthor:: Andy Smith <[email protected]>
"""
+
+import sys
+import pkg_resources
+
+# If there is a conflicting non egg module,
+# i.e. an older standard system module installed,
+# then replace it with this requirement
+def replace_dist(requirement):
+ try:
+ return pkg_resources.require(requirement)
+ except pkg_resources.VersionConflict:
+ e = sys.exc_info()[1]
+ dist=e.args[0]
+ req=e.args[1]
+ if dist.key == req.key and not dist.location.endswith('.egg'):
+ del pkg_resources.working_set.by_key[dist.key]
+ # We assume there is no need to adjust sys.path
+ # and the associated pkg_resources.working_set.entries
+ return pkg_resources.require(requirement)
+
+replace_dist("WebOb >= 1.2")
+replace_dist("SQLAlchemy >= 0.6.3")
+replace_dist("Routes >= 1.12.3")
+
+replace_dist("PasteDeploy >= 1.5.0")
+# This hack is needed because replace_dist() results in
+# the standard paste module path being at the start of __path__.
+# TODO: See can we get pkg_resources to do the right thing directly
+import paste
+paste.__path__.insert(0, paste.__path__.pop(-1))
diff --git a/cinder/db/sqlalchemy/migration.py b/cinder/db/sqlalchemy/migration.py
index e2463bc..9ba7b73 100644
--- a/cinder/db/sqlalchemy/migration.py
+++ b/cinder/db/sqlalchemy/migration.py
@@ -56,7 +56,12 @@ if (not hasattr(migrate, '__version__') or
# NOTE(jkoelker) Delay importing migrate until we are patched
-from migrate import exceptions as versioning_exceptions
+try:
+ # Try the more specific path first (migrate <= 0.6)
+ from migrate.versioning import exceptions as versioning_exceptions
+except ImportError:
+ # Use the newer path (migrate >= 0.7)
+ from migrate import exceptions as versioning_exceptions
from migrate.versioning import api as versioning_api
from migrate.versioning.repository import Repository