Skip to content

Commit fc4f20c

Browse files
authored
Merge pull request #134 from awslabs/develop
release 0.5.0: Merge to master
2 parents 0620b0e + 24d16a3 commit fc4f20c

File tree

6 files changed

+38
-10
lines changed

6 files changed

+38
-10
lines changed

aws_lambda_builders/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
22
AWS Lambda Builder Library
33
"""
4-
__version__ = '0.4.0'
4+
__version__ = '0.5.0'
55
RPC_PROTOCOL_VERSION = "0.3"

aws_lambda_builders/workflows/java_maven/workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class JavaMavenWorkflow(BaseWorkflow):
2020
dependency_manager="maven",
2121
application_framework=None)
2222

23-
EXCLUDED_FILES = (".aws-sam")
23+
EXCLUDED_FILES = (".aws-sam", ".git")
2424

2525
def __init__(self,
2626
source_dir,

aws_lambda_builders/workflows/python_pip/compat.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,23 @@ def pip_import_string(python_exe):
88
cmd = [
99
python_exe,
1010
"-c",
11-
"import pip; assert int(pip.__version__.split('.')[0]) <= 9"
11+
"import pip; print(pip.__version__)"
1212
]
13-
p = os_utils.popen(cmd,stdout=os_utils.pipe, stderr=os_utils.pipe)
14-
p.communicate()
13+
p = os_utils.popen(cmd, stdout=os_utils.pipe, stderr=os_utils.pipe)
14+
stdout, stderr = p.communicate()
15+
pip_version = stdout.decode('utf-8').strip()
16+
pip_major_version = int(pip_version.split('.')[0])
17+
pip_minor_version = int(pip_version.split('.')[1])
18+
1519
# Pip moved its internals to an _internal module in version 10.
1620
# In order to be compatible with version 9 which has it at at the
1721
# top level we need to figure out the correct import path here.
18-
if p.returncode == 0:
22+
if pip_major_version == 9:
1923
return 'from pip import main'
24+
# Pip changed their import structure again in 19.3
25+
# https://github.com/pypa/pip/commit/09fd200
26+
elif pip_major_version >= 19 and pip_minor_version >= 3:
27+
return 'from pip._internal.main import main'
2028
else:
2129
return 'from pip._internal import main'
2230

aws_lambda_builders/workflows/python_pip/workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class PythonPipWorkflow(BaseWorkflow):
3939
".python-version",
4040

4141
# mypy, Pyre
42-
".mypy_cache", ".dmypy.json", ".pyre"
42+
".mypy_cache", ".dmypy.json", ".pyre",
4343

4444
# environments
4545
".env", ".venv", "venv", "venv.bak", "env.bak", "ENV",

tests/unit/workflows/java_maven/test_workflow.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,12 @@ def test_workflow_sets_up_validators(self):
4242
self.assertEqual(len(validators), 1)
4343

4444
self.assertIsInstance(validators[0], MavenValidator)
45+
46+
def test_workflow_excluded_files(self):
47+
workflow = JavaMavenWorkflow("source", "artifacts", "scratch_dir", "manifest")
48+
49+
self.assertIsInstance(workflow.actions[0], CopySourceAction)
50+
51+
self.assertEqual(".aws-sam", workflow.actions[0].excludes[0])
52+
53+
self.assertEqual(".git", workflow.actions[0].excludes[1])

tests/unit/workflows/python_pip/test_packager.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
from collections import namedtuple
3+
from unittest import TestCase
34

45
import mock
56
import pytest
@@ -70,7 +71,7 @@ def osutils():
7071

7172
class FakePopen(object):
7273
def __init__(self, rc, out, err):
73-
self.returncode = 0
74+
self.returncode = rc
7475
self._out = out
7576
self._err = err
7677

@@ -303,14 +304,24 @@ def test_inject_unknown_error_if_no_stderr(self, pip_factory):
303304
assert str(einfo.value) == 'Unknown error'
304305

305306

306-
class TestSubprocessPip(object):
307+
class TestSubprocessPip(TestCase):
307308
def test_does_use_custom_pip_import_string(self):
308309
fake_osutils = FakePopenOSUtils([FakePopen(0, '', '')])
309310
expected_import_statement = 'foobarbaz'
310311
pip = SubprocessPip(osutils=fake_osutils,
311-
import_string=expected_import_statement)
312+
import_string=expected_import_statement,
313+
python_exe=sys.executable)
312314
pip.main(['--version'])
313315

314316
pip_execution_string = fake_osutils.popens[0][0][0][2]
315317
import_statement = pip_execution_string.split(';')[1].strip()
316318
assert import_statement == expected_import_statement
319+
320+
def test_check_pip_runner_string_pip(self):
321+
fake_osutils = FakePopenOSUtils([FakePopen(0, '', '')])
322+
pip = SubprocessPip(osutils=fake_osutils,
323+
python_exe=sys.executable)
324+
pip.main(['--version'])
325+
326+
pip_runner_string = fake_osutils.popens[0][0][0][2].split(";")[-1:][0]
327+
self.assertIn("main", pip_runner_string)

0 commit comments

Comments
 (0)