New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix non-idempotent Auth@Edge function deploys #464
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import json | ||
import logging | ||
import os | ||
import shutil | ||
import stat | ||
import subprocess | ||
import sys | ||
|
@@ -455,12 +456,17 @@ def dockerized_pip( | |
|
||
LOGGER.info('using docker image "%s" to build deployment package...', docker_image) | ||
|
||
docker_run_args = {} | ||
if _kwargs.get("python_dontwritebytecode"): | ||
docker_run_args["environment"] = "1" | ||
|
||
container = client.containers.run( | ||
image=docker_image, | ||
command=["/bin/sh", "-c", pip_cmd], | ||
auto_remove=True, | ||
detach=True, | ||
mounts=[work_dir_mount], | ||
**docker_run_args | ||
) | ||
|
||
# 'stream' creates a blocking generator that allows for real-time logs. | ||
|
@@ -582,6 +588,10 @@ def _zip_package( | |
"--no-color", | ||
] | ||
|
||
subprocess_args = {} | ||
if kwargs.get("python_dontwritebytecode"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could instead expose this as an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're probably right. I'm pretty torn on it between an implementation detail to hide away vs a configuration option. Would be really nice if there was reasonable assurance that it wouldn't break things to just bake it in by default; I'm not certain what the implications with different types of packages/platforms. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not sure either. But, I can guarantee you someone will fine some package that will be incompatible. We could still implement it as an environment variables option but, pre-populate it with values (like this one) by default and allow users to override the default by specifying their own to provide an out if it does break things. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was added to get rid of the |
||
subprocess_args["env"] = dict(os.environ, PYTHONDONTWRITEBYTECODE="1") | ||
|
||
# Pyinstaller build or explicit python path | ||
if getattr(sys, "frozen", False) and not python_path: | ||
script_contents = os.linesep.join( | ||
|
@@ -612,13 +622,24 @@ def _zip_package( | |
) | ||
|
||
try: | ||
subprocess.check_call(cmd) | ||
subprocess.check_call(cmd, **subprocess_args) | ||
except subprocess.CalledProcessError: | ||
raise PipError | ||
finally: | ||
if tmp_script.is_file(): | ||
tmp_script.unlink() | ||
|
||
if kwargs.get("python_exclude_bin_dir") and os.path.isdir( | ||
os.path.join(tmpdir, "bin") | ||
): | ||
LOGGER.debug("Removing python /bin directory from Lambda files") | ||
shutil.rmtree(os.path.join(tmpdir, "bin")) | ||
if kwargs.get("python_exclude_setuptools_dirs"): | ||
for i in os.listdir(tmpdir): | ||
if i.endswith(".egg-info") or i.endswith(".dist-info"): | ||
LOGGER.debug("Removing directory %s from Lambda files", i) | ||
shutil.rmtree(os.path.join(tmpdir, i)) | ||
|
||
req_files = _find_files(tmpdir, includes="**", follow_symlinks=False) | ||
return _zip_files(req_files, tmpdir) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since kwargs is being used now, the proceeding underscore should be removed as it indicates an unused variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Legit embarrassing that I copied and pasted and didn't even think about that.