forked from zappa/Zappa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bypass python version runtime check when code run in docker (zappa#1180)
* ✨ Handle spaces in x-forwared-for (zappa#1127) * 🔥 remove `six` (no longer needed as 2.x is no longer supported) * ✅ add testcase for SUPPORTED_VERSION check to increase code coverage. * 🎨 run black/isort * 🔧 rename function for clarity * 🔥 remove unnecessary import * 🔧 change name of unused mock instance * ✨ (zappa#879) Fix url decoding for query string * 🔧 change docstring type multi-line comment to standard multiline comment ✨ handle case where "requestContext" is not provided by the event. > Systems calling the Lambda (other than API Gateway) may not provide the field requestContext in the event. ✅ add testcases * 🔥 remove duplicate comment * 📝 add docstring to util function, `get_unsupported_sys_versioninfo()` * ✨ Add any python version support in the case where code is run in docker * 🎨 run black/isort * ✅ fix testcase ✅ update testcase to output the full filepath of file you are expected to compare the README.md to. * 🔧 Add python minor version check when using docker. * 🎨 fix flake8 * 🔧 don't limit the upper version of zappa on setup. Internal checks will perform version check, but docker based installs shouldn't be capped.
- Loading branch information
Showing
6 changed files
with
74 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,36 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
|
||
def running_in_docker() -> bool: | ||
""" | ||
Determine if zappa is running in docker. | ||
- When docker is used allow usage of any python version | ||
""" | ||
# https://stackoverflow.com/a/20012536/24718 | ||
cgroup_content = Path("/proc/1/cgroup").read_text() | ||
in_docker = "/docker/" in cgroup_content or "/lxc/" in cgroup_content | ||
return in_docker | ||
|
||
|
||
SUPPORTED_VERSIONS = [(3, 7), (3, 8), (3, 9)] | ||
MINIMUM_SUPPORTED_MINOR_VERSION = 7 | ||
|
||
if sys.version_info[:2] not in SUPPORTED_VERSIONS: | ||
if not running_in_docker() and sys.version_info[:2] not in SUPPORTED_VERSIONS: | ||
print(running_in_docker()) | ||
formatted_supported_versions = ["{}.{}".format(*version) for version in SUPPORTED_VERSIONS] | ||
err_msg = "This version of Python ({}.{}) is not supported!\n".format( | ||
*sys.version_info | ||
) + "Zappa (and AWS Lambda) support the following versions of Python: {}".format(formatted_supported_versions) | ||
err_msg = ( | ||
f"This version of Python ({sys.version_info.major}.{sys.version_info.minor}) is not supported!\n" | ||
f"Zappa (and AWS Lambda) support the following versions of Python: {formatted_supported_versions}" | ||
) | ||
raise RuntimeError(err_msg) | ||
elif running_in_docker() and sys.version_info.minor < MINIMUM_SUPPORTED_MINOR_VERSION: | ||
# when running in docker enforce minimum version only | ||
err_msg = ( | ||
f"This version of Python ({sys.version_info.major}.{sys.version_info.minor}) is not supported!\n" | ||
f"Zappa requires a minimum version of 3.{MINIMUM_SUPPORTED_MINOR_VERSION}" | ||
) | ||
raise RuntimeError(err_msg) | ||
|
||
|
||
__version__ = "0.55.0" |