Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion aws_lambda_builders/workflows/python_pip/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,12 +772,14 @@ def _execute(self, command, args, env_vars=None, shim=None):
main_args = [command] + args
LOG.debug("calling pip %s", " ".join(main_args))
rc, out, err = self._wrapped_pip.main(main_args, env_vars=env_vars, shim=shim)
LOG.debug("pip stdout: %s", out)
LOG.debug("pip stderr: %s", err)
return rc, out, err

def build_wheel(self, wheel, directory, compile_c=True):
"""Build an sdist into a wheel file."""
arguments = ["--no-deps", "--wheel-dir", directory, wheel]
env_vars = self._osutils.environ()
env_vars = self._osutils.original_environ()
shim = ""
if not compile_c:
env_vars.update(pip_no_compile_c_env_vars)
Expand Down
3 changes: 0 additions & 3 deletions aws_lambda_builders/workflows/python_pip/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@


class OSUtils(object):
def environ(self):
return os.environ

def original_environ(self):
# https://pyinstaller.readthedocs.io/en/stable/runtime-information.html#ld-library-path-libpath-considerations
env = dict(os.environ)
Expand Down
14 changes: 12 additions & 2 deletions tests/functional/workflows/python_pip/test_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import tarfile
import io
from collections import defaultdict, namedtuple
from unittest import mock
from unittest import TestCase, mock

import pytest

Expand Down Expand Up @@ -182,7 +182,7 @@ def osutils():
@pytest.fixture
def empty_env_osutils():
class EmptyEnv(object):
def environ(self):
def original_environ(self):
return {}

return EmptyEnv()
Expand Down Expand Up @@ -830,6 +830,16 @@ def test_build_into_existing_dir_with_preinstalled_packages(self, tmpdir, osutil
assert installed_packages == ["bar"]


class TestPipRunner(TestCase):
def test_build_wheel_calls_pip_without_ld_library_path(self):
pip_mock = mock.Mock()
pip_mock.main.return_value = (0, "out", "err")
os_utils_mock = mock.Mock()
pip_runner = PipRunner(mock.Mock(), pip_mock, os_utils_mock)
pip_runner.build_wheel("wheel", "dir")
os_utils_mock.original_environ.assert_called_once()


class TestSubprocessPip(object):
def test_can_invoke_pip(self):
pip = SubprocessPip(python_exe=sys.executable)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/workflows/python_pip/test_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CustomEnv(OSUtils):
def __init__(self, env):
self._env = env

def environ(self):
def original_environ(self):
return self._env


Expand Down