-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature-change/update-best-match-zone
- 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" |