Import eventlet patch from oslo.
This was abandoned once before: https://review.openstack.org/#/c/25781/ However this is not to do with packaging. This is required if we use eventlet subprocess module (like we should be) in jenkins tests for python2.6. Also imports patch_tox_venv.py. This is a cutdown version of what would happen in run_tests.sh but for tox environments which is how jenkins runs tests now. Change-Id: I369c3e464dfbe3a754f90db58785e97ac87b36c0
This commit is contained in:
parent
e183b93481
commit
7da3a69865
|
@ -0,0 +1,16 @@
|
||||||
|
--- .nova-venv/lib/python2.6/site-packages/eventlet/green/subprocess.py.orig
|
||||||
|
2011-05-25
|
||||||
|
23:31:34.597271402 +0000
|
||||||
|
+++ .nova-venv/lib/python2.6/site-packages/eventlet/green/subprocess.py
|
||||||
|
2011-05-25
|
||||||
|
23:33:24.055602468 +0000
|
||||||
|
@@ -32,7 +32,7 @@
|
||||||
|
setattr(self, attr, wrapped_pipe)
|
||||||
|
__init__.__doc__ = subprocess_orig.Popen.__init__.__doc__
|
||||||
|
|
||||||
|
- def wait(self, check_interval=0.01):
|
||||||
|
+ def wait(self, check_interval=0.01, timeout=None):
|
||||||
|
# Instead of a blocking OS call, this version of wait() uses logic
|
||||||
|
# borrowed from the eventlet 0.2 processes.Process.wait() method.
|
||||||
|
try:
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
module=importutils
|
module=importutils
|
||||||
module=install_venv_common
|
module=install_venv_common
|
||||||
module=jsonutils
|
module=jsonutils
|
||||||
|
module=patch_tox_venv
|
||||||
module=policy
|
module=policy
|
||||||
|
module=redhat-eventlet.patch
|
||||||
module=timeutils
|
module=timeutils
|
||||||
|
|
||||||
# The base module to hold the copy of openstack.common
|
# The base module to hold the copy of openstack.common
|
||||||
|
|
|
@ -18,10 +18,15 @@
|
||||||
"""Provides methods needed by installation script for OpenStack development
|
"""Provides methods needed by installation script for OpenStack development
|
||||||
virtual environments.
|
virtual environments.
|
||||||
|
|
||||||
|
Since this script is used to bootstrap a virtualenv from the system's Python
|
||||||
|
environment, it should be kept strictly compatible with Python 2.6.
|
||||||
|
|
||||||
Synced in from openstack-common
|
Synced in from openstack-common
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import optparse
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
@ -39,7 +44,7 @@ class InstallVenv(object):
|
||||||
self.project = project
|
self.project = project
|
||||||
|
|
||||||
def die(self, message, *args):
|
def die(self, message, *args):
|
||||||
print >> sys.stderr, message % args
|
print(message % args, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def check_python_version(self):
|
def check_python_version(self):
|
||||||
|
@ -86,20 +91,20 @@ class InstallVenv(object):
|
||||||
virtual environment.
|
virtual environment.
|
||||||
"""
|
"""
|
||||||
if not os.path.isdir(self.venv):
|
if not os.path.isdir(self.venv):
|
||||||
print 'Creating venv...',
|
print('Creating venv...', end=' ')
|
||||||
if no_site_packages:
|
if no_site_packages:
|
||||||
self.run_command(['virtualenv', '-q', '--no-site-packages',
|
self.run_command(['virtualenv', '-q', '--no-site-packages',
|
||||||
self.venv])
|
self.venv])
|
||||||
else:
|
else:
|
||||||
self.run_command(['virtualenv', '-q', self.venv])
|
self.run_command(['virtualenv', '-q', self.venv])
|
||||||
print 'done.'
|
print('done.')
|
||||||
print 'Installing pip in venv...',
|
print('Installing pip in venv...', end=' ')
|
||||||
if not self.run_command(['tools/with_venv.sh', 'easy_install',
|
if not self.run_command(['tools/with_venv.sh', 'easy_install',
|
||||||
'pip>1.0']).strip():
|
'pip>1.0']).strip():
|
||||||
self.die("Failed to install pip.")
|
self.die("Failed to install pip.")
|
||||||
print 'done.'
|
print('done.')
|
||||||
else:
|
else:
|
||||||
print "venv already exists..."
|
print("venv already exists...")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def pip_install(self, *args):
|
def pip_install(self, *args):
|
||||||
|
@ -108,7 +113,7 @@ class InstallVenv(object):
|
||||||
redirect_output=False)
|
redirect_output=False)
|
||||||
|
|
||||||
def install_dependencies(self):
|
def install_dependencies(self):
|
||||||
print 'Installing dependencies with pip (this can take a while)...'
|
print('Installing dependencies with pip (this can take a while)...')
|
||||||
|
|
||||||
# First things first, make sure our venv has the latest pip and
|
# First things first, make sure our venv has the latest pip and
|
||||||
# distribute.
|
# distribute.
|
||||||
|
@ -131,12 +136,12 @@ class InstallVenv(object):
|
||||||
|
|
||||||
def parse_args(self, argv):
|
def parse_args(self, argv):
|
||||||
"""Parses command-line arguments."""
|
"""Parses command-line arguments."""
|
||||||
parser = argparse.ArgumentParser()
|
parser = optparse.OptionParser()
|
||||||
parser.add_argument('-n', '--no-site-packages',
|
parser.add_option('-n', '--no-site-packages',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Do not inherit packages from global Python "
|
help="Do not inherit packages from global Python "
|
||||||
"install")
|
"install")
|
||||||
return parser.parse_args(argv[1:])
|
return parser.parse_args(argv[1:])[0]
|
||||||
|
|
||||||
|
|
||||||
class Distro(InstallVenv):
|
class Distro(InstallVenv):
|
||||||
|
@ -150,12 +155,12 @@ class Distro(InstallVenv):
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.check_cmd('easy_install'):
|
if self.check_cmd('easy_install'):
|
||||||
print 'Installing virtualenv via easy_install...',
|
print('Installing virtualenv via easy_install...', end=' ')
|
||||||
if self.run_command(['easy_install', 'virtualenv']):
|
if self.run_command(['easy_install', 'virtualenv']):
|
||||||
print 'Succeeded'
|
print('Succeeded')
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
print 'Failed'
|
print('Failed')
|
||||||
|
|
||||||
self.die('ERROR: virtualenv not found.\n\n%s development'
|
self.die('ERROR: virtualenv not found.\n\n%s development'
|
||||||
' requires virtualenv, please install it using your'
|
' requires virtualenv, please install it using your'
|
||||||
|
@ -180,10 +185,6 @@ class Fedora(Distro):
|
||||||
return self.run_command_with_code(['rpm', '-q', pkg],
|
return self.run_command_with_code(['rpm', '-q', pkg],
|
||||||
check_exit_code=False)[1] == 0
|
check_exit_code=False)[1] == 0
|
||||||
|
|
||||||
def yum_install(self, pkg, **kwargs):
|
|
||||||
print "Attempting to install '%s' via yum" % pkg
|
|
||||||
self.run_command(['sudo', 'yum', 'install', '-y', pkg], **kwargs)
|
|
||||||
|
|
||||||
def apply_patch(self, originalfile, patchfile):
|
def apply_patch(self, originalfile, patchfile):
|
||||||
self.run_command(['patch', '-N', originalfile, patchfile],
|
self.run_command(['patch', '-N', originalfile, patchfile],
|
||||||
check_exit_code=False)
|
check_exit_code=False)
|
||||||
|
@ -193,7 +194,7 @@ class Fedora(Distro):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.check_pkg('python-virtualenv'):
|
if not self.check_pkg('python-virtualenv'):
|
||||||
self.yum_install('python-virtualenv', check_exit_code=False)
|
self.die("Please install 'python-virtualenv'.")
|
||||||
|
|
||||||
super(Fedora, self).install_virtualenv()
|
super(Fedora, self).install_virtualenv()
|
||||||
|
|
||||||
|
@ -206,12 +207,13 @@ class Fedora(Distro):
|
||||||
This can be removed when the fix is applied upstream.
|
This can be removed when the fix is applied upstream.
|
||||||
|
|
||||||
Nova: https://bugs.launchpad.net/nova/+bug/884915
|
Nova: https://bugs.launchpad.net/nova/+bug/884915
|
||||||
Upstream: https://bitbucket.org/which_linden/eventlet/issue/89
|
Upstream: https://bitbucket.org/eventlet/eventlet/issue/89
|
||||||
|
RHEL: https://bugzilla.redhat.com/958868
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Install "patch" program if it's not there
|
# Install "patch" program if it's not there
|
||||||
if not self.check_pkg('patch'):
|
if not self.check_pkg('patch'):
|
||||||
self.yum_install('patch')
|
self.die("Please install 'patch'.")
|
||||||
|
|
||||||
# Apply the eventlet patch
|
# Apply the eventlet patch
|
||||||
self.apply_patch(os.path.join(self.venv, 'lib', self.py_version,
|
self.apply_patch(os.path.join(self.venv, 'lib', self.py_version,
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
|
# Copyright 2013 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import install_venv_common as install_venv
|
||||||
|
|
||||||
|
|
||||||
|
def first_file(file_list):
|
||||||
|
for candidate in file_list:
|
||||||
|
if os.path.exists(candidate):
|
||||||
|
return candidate
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
|
||||||
|
venv = os.environ['VIRTUAL_ENV']
|
||||||
|
|
||||||
|
pip_requires = first_file([
|
||||||
|
os.path.join(root, 'requirements.txt'),
|
||||||
|
os.path.join(root, 'tools', 'pip-requires'),
|
||||||
|
])
|
||||||
|
test_requires = first_file([
|
||||||
|
os.path.join(root, 'test-requirements.txt'),
|
||||||
|
os.path.join(root, 'tools', 'test-requires'),
|
||||||
|
])
|
||||||
|
py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
|
||||||
|
project = 'keystone'
|
||||||
|
install = install_venv.InstallVenv(root, venv, pip_requires, test_requires,
|
||||||
|
py_version, project)
|
||||||
|
#NOTE(dprince): For Tox we only run post_process (which patches files, etc)
|
||||||
|
install.post_process()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main(sys.argv)
|
3
tox.ini
3
tox.ini
|
@ -11,7 +11,8 @@ setenv = VIRTUAL_ENV={envdir}
|
||||||
NOSE_OPENSTACK_STDOUT=1
|
NOSE_OPENSTACK_STDOUT=1
|
||||||
deps = -r{toxinidir}/requirements.txt
|
deps = -r{toxinidir}/requirements.txt
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
commands = nosetests {posargs}
|
commands = python tools/patch_tox_venv.py
|
||||||
|
nosetests {posargs}
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
commands =
|
commands =
|
||||||
|
|
Loading…
Reference in New Issue