use dev-requirements for global sync
This allows us to pass through an exact line from dev-requirements.txt as valid, if it's not exactly valid we'll revert to the base requirement. This is needed so that projects can keep development requirements in their tree. Redo an if statement to make E125 happy.... Change-Id: I50a1292c321b7092ca1c7aeee5068f0828ece7b0
This commit is contained in:
parent
ec0489413f
commit
63322c94d1
12
tests/files/dev-req.txt
Normal file
12
tests/files/dev-req.txt
Normal file
@ -0,0 +1,12 @@
|
||||
#
|
||||
# Use this file to list development versions of OpenStack libraries
|
||||
# which have not yet been released to PyPI.
|
||||
#
|
||||
# By the time OpenStack projects are released, they should switch to
|
||||
# versions of these libraries which have been released to PyPI.
|
||||
#
|
||||
# See also:
|
||||
# https://wiki.openstack.org/wiki/Oslo#FAQs
|
||||
#
|
||||
-f http://tarballs.openstack.org/oslo.config/oslo.config-1.2.0a3.tar.gz#egg=oslo.config-1.2.0a3
|
||||
oslo.config>=1.2.0a3
|
@ -41,6 +41,7 @@ class UpdateTest(testtools.TestCase):
|
||||
self.oslo_dir = os.path.join(self.dir, "project_with_oslo")
|
||||
|
||||
self.req_file = os.path.join(self.dir, "global-requirements.txt")
|
||||
self.dev_req_file = os.path.join(self.dir, "dev-requirements.txt")
|
||||
self.proj_file = os.path.join(self.project_dir, "requirements.txt")
|
||||
self.oslo_file = os.path.join(self.oslo_dir, "requirements.txt")
|
||||
self.proj_test_file = os.path.join(self.project_dir,
|
||||
@ -51,6 +52,7 @@ class UpdateTest(testtools.TestCase):
|
||||
os.mkdir(self.oslo_dir)
|
||||
|
||||
shutil.copy("tests/files/gr-base.txt", self.req_file)
|
||||
shutil.copy("tests/files/dev-req.txt", self.dev_req_file)
|
||||
shutil.copy("tests/files/project-with-oslo-tar.txt", self.oslo_file)
|
||||
shutil.copy("tests/files/project.txt", self.proj_file)
|
||||
shutil.copy("tests/files/test-project.txt", self.proj_test_file)
|
||||
@ -80,7 +82,8 @@ class UpdateTest(testtools.TestCase):
|
||||
oslo_tar = ("-f http://tarballs.openstack.org/oslo.config/"
|
||||
"oslo.config-1.2.0a3.tar.gz#egg=oslo.config-1.2.0a3")
|
||||
self.assertIn(oslo_tar, reqs)
|
||||
self.assertIn("oslo.config>=1.1.0", reqs)
|
||||
self.assertIn("oslo.config>=1.2.0a3", reqs)
|
||||
self.assertNotIn("oslo.config>=1.1.0", reqs)
|
||||
|
||||
def test_test_project(self):
|
||||
reqs = _file_to_list(self.proj_test_file)
|
||||
|
21
update.py
21
update.py
@ -92,7 +92,7 @@ def _parse_reqs(filename):
|
||||
return reqs
|
||||
|
||||
|
||||
def _sync_requirements_file(source_reqs, dest_path):
|
||||
def _sync_requirements_file(source_reqs, dev_reqs, dest_path):
|
||||
dest_reqs = []
|
||||
with open(dest_path, 'r') as dest_reqs_file:
|
||||
dest_reqs = dest_reqs_file.readlines()
|
||||
@ -116,13 +116,19 @@ def _sync_requirements_file(source_reqs, dest_path):
|
||||
continue
|
||||
|
||||
if old_pip in source_reqs:
|
||||
new_reqs.write("%s\n" % source_reqs[old_pip])
|
||||
# allow it to be in dev-requirements
|
||||
if ((old_pip in dev_reqs) and (old_require.lower() ==
|
||||
dev_reqs[old_pip])):
|
||||
new_reqs.write("%s\n" % dev_reqs[old_pip])
|
||||
else:
|
||||
new_reqs.write("%s\n" % source_reqs[old_pip])
|
||||
|
||||
|
||||
def _copy_requires(source_path, dest_dir):
|
||||
def _copy_requires(dest_dir):
|
||||
"""Copy requirements files."""
|
||||
|
||||
source_reqs = _parse_reqs(source_path)
|
||||
source_reqs = _parse_reqs('global-requirements.txt')
|
||||
dev_reqs = _parse_reqs('dev-requirements.txt')
|
||||
|
||||
target_files = (
|
||||
'requirements.txt', 'tools/pip-requires',
|
||||
@ -131,8 +137,9 @@ def _copy_requires(source_path, dest_dir):
|
||||
for dest in target_files:
|
||||
dest_path = os.path.join(dest_dir, dest)
|
||||
if os.path.exists(dest_path):
|
||||
print("_sync_requirements_file(%s, %s)" % (source_reqs, dest_path))
|
||||
_sync_requirements_file(source_reqs, dest_path)
|
||||
print("_sync_requirements_file(%s, %s, %s)" %
|
||||
(source_reqs, dev_reqs, dest_path))
|
||||
_sync_requirements_file(source_reqs, dev_reqs, dest_path)
|
||||
|
||||
|
||||
def _write_setup_py(dest_path):
|
||||
@ -146,7 +153,7 @@ def _write_setup_py(dest_path):
|
||||
|
||||
|
||||
def main(argv):
|
||||
_copy_requires('global-requirements.txt', argv[0])
|
||||
_copy_requires(argv[0])
|
||||
_write_setup_py(argv[0])
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user