Merge "Add support for nested requirements files"
This commit is contained in:
commit
02aeac0b14
|
@ -125,6 +125,13 @@ def parse_requirements(requirements_files=None):
|
|||
if (not line.strip()) or line.startswith('#'):
|
||||
continue
|
||||
|
||||
# Handle nested requirements files such as:
|
||||
# -r other-requirements.txt
|
||||
if line.startswith('-r'):
|
||||
req_file = line.partition(' ')[2]
|
||||
requirements += parse_requirements([req_file])
|
||||
continue
|
||||
|
||||
try:
|
||||
project_name = pkg_resources.Requirement.parse(line).project_name
|
||||
except ValueError:
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
|
@ -145,3 +146,17 @@ class TestPresenceOfGit(base.BaseTestCase):
|
|||
'_run_shell_command') as _command:
|
||||
_command.side_effect = OSError
|
||||
self.assertEqual(False, packaging._git_is_installed())
|
||||
|
||||
|
||||
class TestNestedRequirements(base.BaseTestCase):
|
||||
|
||||
def test_nested_requirement(self):
|
||||
tempdir = tempfile.mkdtemp()
|
||||
requirements = os.path.join(tempdir, 'requirements.txt')
|
||||
nested = os.path.join(tempdir, 'nested.txt')
|
||||
with open(requirements, 'w') as f:
|
||||
f.write('-r ' + nested)
|
||||
with open(nested, 'w') as f:
|
||||
f.write('pbr')
|
||||
result = packaging.parse_requirements([requirements])
|
||||
self.assertEqual(result, ['pbr'])
|
||||
|
|
Loading…
Reference in New Issue