Update the lookup plugin to force dep ordering

This change ensures that the dependency file ordering
for requirements file is kept intact for all fot the discovered
file used to build the repo environment.

Change-Id: I36d2044965c8a0809a417083c3f24c406b5a36c9
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2016-07-15 12:28:12 -05:00 committed by Jimmy McCrory
parent 54ce4cec97
commit 7f50658956
2 changed files with 20 additions and 4 deletions

View File

@ -40,10 +40,10 @@ ROLE_PACKAGES = dict()
REQUIREMENTS_FILE_TYPES = [
'global-requirements.txt',
'test-requirements.txt',
'dev-requirements.txt',
'requirements.txt',
'global-requirements.txt',
'global-requirement-pins.txt'
]
@ -296,7 +296,6 @@ class DependencyFileProcessor(object):
@staticmethod
def _filter_files(file_names, ext):
"""Filter the files and return a sorted list.
:type file_names:
:type ext: ``str`` or ``tuple``
:returns: ``list``
@ -513,8 +512,16 @@ class DependencyFileProcessor(object):
var_name=key
)
for file_name in self._filter_files(self.file_names, 'txt'):
if os.path.basename(file_name) in REQUIREMENTS_FILE_TYPES:
return_list = self._filter_files(self.file_names, 'txt')
for file_name in return_list:
base_name = os.path.basename(file_name)
if base_name in REQUIREMENTS_FILE_TYPES:
index = REQUIREMENTS_FILE_TYPES.index(base_name)
return_list.remove(file_name)
return_list.insert(index, file_name)
else:
print return_list
for file_name in return_list:
with open(file_name, 'r') as f:
packages = [
i.split()[0] for i in f.read().splitlines()

View File

@ -0,0 +1,9 @@
---
features:
- The ``py_pkgs`` lookup plugin now has strict ordering for requirement files
discovered. These files are used to add additional requirements to the
python packages discovered. The order is defined by the constant,
``REQUIREMENTS_FILE_TYPES`` which contains the following entries,
'test-requirements.txt', 'dev-requirements.txt', 'requirements.txt',
'global-requirements.txt', 'global-requirement-pins.txt'. The items in this
list are arranged from least to most priority.