Requirements-check: use local repo like any other library
This ensures the playbook has done a local install of the repo so the script run can assume that it is installed and can be loaded without additional handling. Change-Id: Iaf759b183e6821bf6690195586e7e65bf0533c82
This commit is contained in:
parent
50f69d5296
commit
af94ab8479
@ -24,10 +24,9 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
|
||||
requirement = None
|
||||
project = None
|
||||
check = None
|
||||
from openstack_requirements import check # noqa
|
||||
from openstack_requirements import project # noqa
|
||||
from openstack_requirements import requirement # noqa
|
||||
|
||||
|
||||
def run_command(cmd):
|
||||
@ -77,31 +76,6 @@ def tempdir():
|
||||
shutil.rmtree(reqroot)
|
||||
|
||||
|
||||
def install_and_load_requirements(reqroot, reqdir):
|
||||
"""This makes sure a virtualenv is used before attempting to import."""
|
||||
if os.environ.get('VIRTUAL_ENV') or hasattr(sys, 'real_prefix'):
|
||||
print('It looks like we are running from a virtualenv.')
|
||||
print('SKIPPING INSTALLATION')
|
||||
else:
|
||||
sha = run_command("git --git-dir %s/.git rev-parse HEAD" % reqdir)[0]
|
||||
print("requirements git sha: %s" % sha)
|
||||
version = sys.version_info
|
||||
req_venv = os.path.join(reqroot, 'venv')
|
||||
req_pip = os.path.join(req_venv, 'bin/pip3')
|
||||
req_lib = os.path.join(
|
||||
req_venv,
|
||||
'lib/python%s.%s/site-packages' % (version[0], version[1]))
|
||||
_, _ = run_command("virtualenv " + req_venv)
|
||||
_, _ = run_command(req_pip + " install " + reqdir)
|
||||
sys.path.append(req_lib)
|
||||
global check
|
||||
global project
|
||||
global requirement
|
||||
from openstack_requirements import check # noqa
|
||||
from openstack_requirements import project # noqa
|
||||
from openstack_requirements import requirement # noqa
|
||||
|
||||
|
||||
def main():
|
||||
args = grab_args()
|
||||
branch = args.branch
|
||||
@ -130,9 +104,7 @@ def main():
|
||||
|
||||
# build a list of requirements from the global list in the
|
||||
# openstack/requirements project so we can match them to the changes
|
||||
with tempdir() as reqroot:
|
||||
|
||||
install_and_load_requirements(reqroot, reqdir)
|
||||
with tempdir():
|
||||
with open(reqdir + '/global-requirements.txt', 'rt') as f:
|
||||
global_reqs = check.get_global_reqs(f.read())
|
||||
blacklist = requirement.parse(
|
||||
|
@ -1,5 +1,8 @@
|
||||
- hosts: all
|
||||
tasks:
|
||||
- name: Install openstack_requirements
|
||||
command: "pip install --user {{ zuul.projects['opendev.org/openstack/requirements'].src_dir }}"
|
||||
|
||||
- name: Run requirements check script
|
||||
# Use command module here instead of script since Zuul gets output
|
||||
# with command into job-output.txt file.
|
||||
|
Loading…
x
Reference in New Issue
Block a user