Skip to content

Commit

Permalink
Fix local package installation
Browse files Browse the repository at this point in the history
When packaging the dependencies only the first local package would be
included in the final bundle. This change adds support for any number
of local directory links to be treated as buildable dependencies. Tests
were also added for the case of 1 or 2 local directory links specified
in the requirements.txt.
  • Loading branch information
stealthycoin committed Jan 14, 2019
1 parent 9f20ec2 commit b67eaf0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
CHANGELOG
=========

Next Release (TBD)
==================

* Fix packaging multiple local directories as dependencies
(`#1047 <https://github.com/aws/chalice/pull/1047>`__)


1.6.2
=====

Expand Down
4 changes: 2 additions & 2 deletions chalice/deploy/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions tests/unit/deploy/test_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'',
Expand Down

0 comments on commit b67eaf0

Please sign in to comment.