Skip to content

Commit 0d3d7b4

Browse files
author
Wenbing Li
authored
Use cloudformation-cli-python-lib from PyPi (#104)
1 parent 4036eba commit 0d3d7b4

File tree

2 files changed

+4
-36
lines changed

2 files changed

+4
-36
lines changed

python/rpdk/python/codegen.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,6 @@ def _build(self, base_path):
204204
self._pip_build(base_path)
205205
LOG.debug("Dependencies build finished")
206206

207-
@staticmethod
208-
def _check_for_support_lib_sdist(base_path):
209-
# TODO: remove this check (and exception) when published to PyPI
210-
sdist = base_path / f"{SUPPORT_LIB_NAME}-0.0.1.tar.gz"
211-
try:
212-
sdist.resolve(strict=True)
213-
except FileNotFoundError:
214-
raise StandardDistNotFoundError(
215-
f"Could not find packaged CloudFormation support library: {sdist}\n"
216-
)
217-
218207
@staticmethod
219208
def _make_pip_command(base_path):
220209
return [
@@ -224,9 +213,6 @@ def _make_pip_command(base_path):
224213
"--no-color",
225214
"--disable-pip-version-check",
226215
"--upgrade",
227-
# TODO: remove find-links when published to PyPI
228-
"--find-links",
229-
str(base_path),
230216
"--requirement",
231217
str(base_path / "requirements.txt"),
232218
"--target",
@@ -235,8 +221,6 @@ def _make_pip_command(base_path):
235221

236222
@classmethod
237223
def _docker_build(cls, external_path):
238-
cls._check_for_support_lib_sdist(external_path)
239-
240224
internal_path = PurePosixPath("/project")
241225
command = " ".join(cls._make_pip_command(internal_path))
242226
LOG.debug("command is '%s'", command)
@@ -275,7 +259,6 @@ def _docker_build(cls, external_path):
275259

276260
@classmethod
277261
def _pip_build(cls, base_path):
278-
cls._check_for_support_lib_sdist(base_path)
279262
command = cls._make_pip_command(base_path)
280263
LOG.debug("command is '%s'", command)
281264

tests/plugin/codegen_test.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
SUPPORT_LIB_NAME,
1717
SUPPORT_LIB_PKG,
1818
Python36LanguagePlugin as PythonLanguagePlugin,
19-
StandardDistNotFoundError,
2019
validate_no,
2120
)
2221

@@ -71,12 +70,6 @@ def test_validate_no(value, result):
7170
assert validate_no(value) is result
7271

7372

74-
def test__check_for_support_lib_sdist(tmp_path):
75-
with pytest.raises(StandardDistNotFoundError):
76-
PythonLanguagePlugin._check_for_support_lib_sdist(tmp_path)
77-
# good path tested in generate
78-
79-
8073
def test__remove_build_artifacts_file_found(tmp_path):
8174
deps_path = tmp_path / "build"
8275
deps_path.mkdir()
@@ -172,32 +165,28 @@ def test_package_pip(project):
172165

173166
def test__pip_build_executable_not_found(tmp_path):
174167
executable_name = str(uuid4())
175-
patch_sdist = patch.object(PythonLanguagePlugin, "_check_for_support_lib_sdist")
176168
patch_cmd = patch.object(
177169
PythonLanguagePlugin, "_make_pip_command", return_value=[executable_name]
178170
)
179171

180-
with patch_sdist as mock_sdist, patch_cmd as mock_cmd:
172+
with patch_cmd as mock_cmd:
181173
with pytest.raises(DownstreamError) as excinfo:
182174
PythonLanguagePlugin._pip_build(tmp_path)
183175

184-
mock_sdist.assert_called_once_with(tmp_path)
185176
mock_cmd.assert_called_once_with(tmp_path)
186177

187178
assert isinstance(excinfo.value.__cause__, FileNotFoundError)
188179

189180

190181
def test__pip_build_called_process_error(tmp_path):
191-
patch_sdist = patch.object(PythonLanguagePlugin, "_check_for_support_lib_sdist")
192182
patch_cmd = patch.object(
193183
PythonLanguagePlugin, "_make_pip_command", return_value=["false"]
194184
)
195185

196-
with patch_sdist as mock_sdist, patch_cmd as mock_cmd:
186+
with patch_cmd as mock_cmd:
197187
with pytest.raises(DownstreamError) as excinfo:
198188
PythonLanguagePlugin._pip_build(tmp_path)
199189

200-
mock_sdist.assert_called_once_with(tmp_path)
201190
mock_cmd.assert_called_once_with(tmp_path)
202191

203192
assert isinstance(excinfo.value.__cause__, CalledProcessError)
@@ -228,15 +217,13 @@ def test__build_docker(plugin):
228217

229218

230219
def test__docker_build_good_path(plugin, tmp_path):
231-
patch_sdist = patch.object(PythonLanguagePlugin, "_check_for_support_lib_sdist")
232220
patch_from_env = patch("rpdk.python.codegen.docker.from_env", autospec=True)
233221

234-
with patch_sdist as mock_sdist, patch_from_env as mock_from_env:
222+
with patch_from_env as mock_from_env:
235223
mock_run = mock_from_env.return_value.containers.run
236224
mock_run.return_value = [b"output\n\n"]
237225
plugin._docker_build(tmp_path)
238226

239-
mock_sdist.assert_called_once_with(tmp_path)
240227
mock_from_env.assert_called_once_with()
241228
mock_run.assert_called_once_with(
242229
image=ANY,
@@ -260,17 +247,15 @@ def test__docker_build_good_path(plugin, tmp_path):
260247
],
261248
)
262249
def test__docker_build_bad_path(plugin, tmp_path, exception):
263-
patch_sdist = patch.object(PythonLanguagePlugin, "_check_for_support_lib_sdist")
264250
patch_from_env = patch("rpdk.python.codegen.docker.from_env", autospec=True)
265251

266-
with patch_sdist as mock_sdist, patch_from_env as mock_from_env:
252+
with patch_from_env as mock_from_env:
267253
mock_run = mock_from_env.return_value.containers.run
268254
mock_run.side_effect = exception()
269255

270256
with pytest.raises(DownstreamError):
271257
plugin._docker_build(tmp_path)
272258

273-
mock_sdist.assert_called_once_with(tmp_path)
274259
mock_from_env.assert_called_once_with()
275260
mock_run.assert_called_once_with(
276261
image=ANY,

0 commit comments

Comments
 (0)