diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 95fc1f4cc..cce901c59 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,13 @@ CHANGELOG ========= +Next Release (TBD) +================== + +* Fix packaging multiple local directories as dependencies + (`#1047 `__) + + 1.6.2 ===== diff --git a/chalice/deploy/packager.py b/chalice/deploy/packager.py index 9372c40df..3a94ad55e 100644 --- a/chalice/deploy/packager.py +++ b/chalice/deploy/packager.py @@ -743,8 +743,8 @@ def download_all_dependencies(self, requirements_filename, directory): raise NoSuchPackageError(str(package_name)) raise PackageDownloadError(error) stdout = out.decode() - match = re.search(self._LINK_IS_DIR_PATTERN, stdout) - if match: + matches = re.finditer(self._LINK_IS_DIR_PATTERN, stdout) + for match in matches: wheel_package_path = str(match.group(1)) # Looks odd we do not check on the error status of building the # wheel here. We can assume this is a valid package path since diff --git a/tests/unit/deploy/test_packager.py b/tests/unit/deploy/test_packager.py index 2d60f1ab5..cff183731 100644 --- a/tests/unit/deploy/test_packager.py +++ b/tests/unit/deploy/test_packager.py @@ -208,6 +208,36 @@ def test_download_wheels_no_wheels(self, pip_factory): runner.download_manylinux_wheels('cp36m', [], 'directory') assert len(pip.calls) == 0 + def test_does_find_local_directory(self, pip_factory): + pip, runner = pip_factory() + pip.add_return((0, + (b"Processing ../local-dir\n" + b" Link is a directory," + b" ignoring download_dir"), + b'')) + runner.download_all_dependencies('requirements.txt', 'directory') + assert len(pip.calls) == 2 + assert pip.calls[1].args == ['wheel', '--no-deps', '--wheel-dir', + 'directory', '../local-dir'] + + def test_does_find_multiple_local_directories(self, pip_factory): + pip, runner = pip_factory() + pip.add_return((0, + (b"Processing ../local-dir-1\n" + b" Link is a directory," + b" ignoring download_dir" + b"\nsome pip output...\n" + b"Processing ../local-dir-2\n" + b" Link is a directory," + b" ignoring download_dir"), + b'')) + runner.download_all_dependencies('requirements.txt', 'directory') + assert len(pip.calls) == 3 + assert pip.calls[1].args == ['wheel', '--no-deps', '--wheel-dir', + 'directory', '../local-dir-1'] + assert pip.calls[2].args == ['wheel', '--no-deps', '--wheel-dir', + 'directory', '../local-dir-2'] + def test_raise_no_such_package_error(self, pip_factory): pip, runner = pip_factory() pip.add_return((1, b'',