From 917a07559dc8e41d4d22827b51d959fe9d204d51 Mon Sep 17 00:00:00 2001 From: iakinsey Date: Mon, 2 Nov 2020 16:54:08 -0800 Subject: [PATCH 1/2] Support python 3.8 in custom runtime --- api/assistants/deployments/aws/utils.py | 4 + .../task_spawner/task_spawner_assistant.py | 10 + api/controller/lambdas/controllers.py | 5 + api/lambda_bases/python3.8 | 27 ++ api/pyconstants/project_constants.py | 3 + api/tasks/aws_lambda.py | 10 +- api/tasks/build/python.py | 284 +++++++++++++++--- .../src/constants/project-editor-constants.ts | 6 +- .../store/modules/panes/edit-block-pane.ts | 9 +- front-end/src/types/graph.ts | 3 +- front-end/src/types/project-editor-types.ts | 9 +- front-end/src/utils/project-debug-utils.ts | 15 +- 12 files changed, 325 insertions(+), 60 deletions(-) create mode 100644 api/lambda_bases/python3.8 diff --git a/api/assistants/deployments/aws/utils.py b/api/assistants/deployments/aws/utils.py index 0a392bafc..170a82853 100644 --- a/api/assistants/deployments/aws/utils.py +++ b/api/assistants/deployments/aws/utils.py @@ -96,6 +96,10 @@ def get_layers_for_lambda(language): new_layers.append( "arn:aws:lambda:us-west-2:134071937287:layer:refinery-python36-custom-runtime:29" ) + elif language == "python3.8": + new_layers.append( + "arn:aws:lambda:us-west-2:134071937287:layer:refinery-python38-custom-runtime:29" + ) elif language == "ruby2.6.4": new_layers.append( "arn:aws:lambda:us-west-2:134071937287:layer:refinery-ruby264-custom-runtime:29" diff --git a/api/assistants/task_spawner/task_spawner_assistant.py b/api/assistants/task_spawner/task_spawner_assistant.py index 921d0c1bc..e263b2a27 100644 --- a/api/assistants/task_spawner/task_spawner_assistant.py +++ b/api/assistants/task_spawner/task_spawner_assistant.py @@ -80,6 +80,7 @@ start_node810_codebuild, start_node10163_codebuild, start_node10201_codebuild) from tasks.build.python import ( + start_python38_codebuild, start_python36_codebuild, start_python27_codebuild ) @@ -614,6 +615,15 @@ def delete_lambda_event_source_mapping(self, credentials, event_source_uuid): def get_final_zip_package_path(self, language, libraries): return get_final_zip_package_path(language, libraries) + @run_on_executor + @emit_runtime_metrics("start_python38_codebuild") + def start_python38_codebuild(self, credentials, libraries_object): + return start_python38_codebuild( + self.aws_client_factory, + credentials, + libraries_object + ) + @run_on_executor @emit_runtime_metrics("start_python36_codebuild") def start_python36_codebuild(self, credentials, libraries_object): diff --git a/api/controller/lambdas/controllers.py b/api/controller/lambdas/controllers.py index 4d2b4a39c..9bea0233a 100644 --- a/api/controller/lambdas/controllers.py +++ b/api/controller/lambdas/controllers.py @@ -207,6 +207,11 @@ def post(self): credentials, libraries_dict ) + elif self.json["language"] == "python3.8": + build_id = yield self.task_spawner.start_python38_codebuild( + credentials, + libraries_dict + ) elif self.json["language"] == "nodejs8.10": build_id = yield self.task_spawner.start_node810_codebuild( credentials, diff --git a/api/lambda_bases/python3.8 b/api/lambda_bases/python3.8 new file mode 100644 index 000000000..c14304f19 --- /dev/null +++ b/api/lambda_bases/python3.8 @@ -0,0 +1,27 @@ +import traceback +import json +import sys + +def _init(): + raw_input_data = sys.stdin.read() + input_data = json.loads( raw_input_data ) + lambda_input = input_data[ "lambda_input" ] + backpack = input_data[ "backpack" ] + + try: + output = main( lambda_input, backpack ) + print( "" + json.dumps({ + "backpack": backpack, + "output": output, + }) + "" ) + backpack = {} + except: + print( "" + json.dumps({ + "backpack": backpack, + "output": traceback.format_exc() + }) + "" ) + backpack = {} + exit(-1) + + exit(0) +_init() \ No newline at end of file diff --git a/api/pyconstants/project_constants.py b/api/pyconstants/project_constants.py index f5dbb829a..1be57ba91 100644 --- a/api/pyconstants/project_constants.py +++ b/api/pyconstants/project_constants.py @@ -16,6 +16,7 @@ LAMBDA_SUPPORTED_LANGUAGES = [ + "python3.8", "python3.6", "python2.7", "nodejs8.10", @@ -36,11 +37,13 @@ "go1.12", "python2.7", "python3.6", + "python3.8", "ruby2.6.4" ] LAMBDA_BASE_LIBRARIES: Dict[str, List[str]] = { + "python3.8": [], "python3.6": [], "python2.7": [], "nodejs8.10": [], diff --git a/api/tasks/aws_lambda.py b/api/tasks/aws_lambda.py index 531323da3..f75cd6a2b 100644 --- a/api/tasks/aws_lambda.py +++ b/api/tasks/aws_lambda.py @@ -21,7 +21,7 @@ from tasks.build.golang import get_go_112_base_code from tasks.build.nodejs import build_nodejs_10163_lambda, build_nodejs_810_lambda, build_nodejs_10201_lambda from tasks.build.php import build_php_73_lambda -from tasks.build.python import build_python36_lambda, build_python27_lambda +from tasks.build.python import build_python38_lambda, build_python36_lambda, build_python27_lambda from tasks.s3 import s3_object_exists from utils.general import logit, log_exception from utils.wrapped_aws_functions import lambda_list_event_source_mappings, api_gateway_get_rest_api, \ @@ -220,6 +220,14 @@ def build_lambda(app_config, aws_client_factory, credentials, lambda_object): lambda_object.code, lambda_object.libraries ) + elif lambda_object.language == "python3.8": + package_zip_data = build_python38_lambda( + app_config, + aws_client_factory, + credentials, + lambda_object.code, + lambda_object.libraries + ) elif lambda_object.language == "python3.6": package_zip_data = build_python36_lambda( app_config, diff --git a/api/tasks/build/python.py b/api/tasks/build/python.py index 1700906fd..7686ce772 100644 --- a/api/tasks/build/python.py +++ b/api/tasks/build/python.py @@ -13,8 +13,12 @@ from utils.block_libraries import generate_libraries_dict +############################################################################### +# Python 3.8 +############################################################################### -def get_python36_lambda_base_zip(aws_client_factory, credentials, libraries): + +def get_python38_lambda_base_zip(aws_client_factory, credentials, libraries): s3_client = aws_client_factory.get_aws_client( "s3", credentials @@ -23,7 +27,7 @@ def get_python36_lambda_base_zip(aws_client_factory, credentials, libraries): libraries_object = generate_libraries_dict(libraries) final_s3_package_zip_path = get_final_zip_package_path( - "python3.6", + "python3.8", libraries_object ) @@ -44,7 +48,7 @@ def get_python36_lambda_base_zip(aws_client_factory, credentials, libraries): # Kick off CodeBuild for the libraries to get a zip artifact of # all of the libraries. - build_id = start_python36_codebuild( + build_id = start_python38_codebuild( aws_client_factory, credentials, libraries_object @@ -60,7 +64,142 @@ def get_python36_lambda_base_zip(aws_client_factory, credentials, libraries): ) -def get_python27_lambda_base_zip(aws_client_factory, credentials, libraries): +def start_python38_codebuild(aws_client_factory, credentials, libraries_object): + """ + Returns a build ID to be polled at a later time + """ + codebuild_client = aws_client_factory.get_aws_client( + "codebuild", + credentials + ) + + s3_client = aws_client_factory.get_aws_client( + "s3", + credentials + ) + + requirements_text = "" + for key, value in libraries_object.items(): + if value != "latest": + requirements_text += key + "==" + value + "\n" + else: + requirements_text += key + "\n" + + # Create empty zip file + codebuild_zip = BytesIO(EMPTY_ZIP_DATA) + + buildspec_template = { + "artifacts": { + "files": [ + "**/*" + ] + }, + "phases": { + "build": { + "commands": [ + "pip3 install --target . -r requirements.txt" + ] + }, + }, + "run-as": "root", + "version": 0.1 + } + + with ZipFile(codebuild_zip, "a", ZIP_DEFLATED) as zip_file_handler: + # Write buildspec.yml defining the build process + buildspec = ZipInfo( + "buildspec.yml" + ) + buildspec.external_attr = 0o777 << 16 + zip_file_handler.writestr( + buildspec, + yaml.dump( + buildspec_template + ) + ) + + # Write the package.json + requirements_txt_file = ZipInfo( + "requirements.txt" + ) + requirements_txt_file.external_attr = 0o777 << 16 + zip_file_handler.writestr( + requirements_txt_file, + requirements_text + ) + + codebuild_zip_data = codebuild_zip.getvalue() + codebuild_zip.close() + + # S3 object key of the build package, randomly generated. + s3_key = "buildspecs/" + str(uuid4()) + ".zip" + + # Write the CodeBuild build package to S3 + s3_response = s3_client.put_object( + Bucket=credentials["lambda_packages_bucket"], + Body=codebuild_zip_data, + Key=s3_key, + ACL="public-read", # THIS HAS TO BE PUBLIC READ FOR SOME FUCKED UP REASON I DONT KNOW WHY + ) + + # Fire-off the build + codebuild_response = codebuild_client.start_build( + projectName="refinery-builds", + sourceTypeOverride="S3", + imageOverride="docker.io/python:3.8", + sourceLocationOverride=credentials["lambda_packages_bucket"] + "/" + s3_key, + ) + + build_id = codebuild_response["build"]["id"] + return build_id + + +def get_python38_base_code(app_config, code): + code = code + "\n\n" + app_config.get("LAMDBA_BASE_CODES")["python3.8"] + return code + + +def build_python38_lambda(app_config, aws_client_factory, credentials, code, libraries): + code = get_python38_base_code( + app_config, + code + ) + + base_zip_data = copy.deepcopy(EMPTY_ZIP_DATA) + if len(libraries) > 0: + base_zip_data = get_python38_lambda_base_zip( + aws_client_factory, + credentials, + libraries + ) + + # Create a virtual file handler for the Lambda zip package + lambda_package_zip = BytesIO(base_zip_data) + + with ZipFile(lambda_package_zip, "a", ZIP_DEFLATED) as zip_file_handler: + info = zipfile.ZipInfo( + "lambda" + ) + info.external_attr = 0o777 << 16 + + # Write lambda.py into new .zip + zip_file_handler.writestr( + info, + str(code) + ) + + lambda_package_zip_data = lambda_package_zip.getvalue() + lambda_package_zip.close() + + return lambda_package_zip_data + + +############################################################################### +# Python 3.6 +############################################################################### + + +def get_python36_lambda_base_zip(aws_client_factory, credentials, libraries): s3_client = aws_client_factory.get_aws_client( "s3", credentials @@ -69,7 +208,7 @@ def get_python27_lambda_base_zip(aws_client_factory, credentials, libraries): libraries_object = generate_libraries_dict(libraries) final_s3_package_zip_path = get_final_zip_package_path( - "python2.7", + "python3.6", libraries_object ) @@ -90,7 +229,7 @@ def get_python27_lambda_base_zip(aws_client_factory, credentials, libraries): # Kick off CodeBuild for the libraries to get a zip artifact of # all of the libraries. - build_id = start_python27_codebuild( + build_id = start_python36_codebuild( aws_client_factory, credentials, libraries_object @@ -139,7 +278,7 @@ def start_python36_codebuild(aws_client_factory, credentials, libraries_object): "phases": { "build": { "commands": [ - "pip install --target . -r requirements.txt" + "pip3 install --target . -r requirements.txt" ] }, }, @@ -196,6 +335,97 @@ def start_python36_codebuild(aws_client_factory, credentials, libraries_object): return build_id +def get_python36_base_code(app_config, code): + code = code + "\n\n" + app_config.get("LAMDBA_BASE_CODES")["python3.6"] + return code + + +def build_python36_lambda(app_config, aws_client_factory, credentials, code, libraries): + code = get_python36_base_code( + app_config, + code + ) + + base_zip_data = copy.deepcopy(EMPTY_ZIP_DATA) + if len(libraries) > 0: + base_zip_data = get_python36_lambda_base_zip( + aws_client_factory, + credentials, + libraries + ) + + # Create a virtual file handler for the Lambda zip package + lambda_package_zip = BytesIO(base_zip_data) + + with ZipFile(lambda_package_zip, "a", ZIP_DEFLATED) as zip_file_handler: + info = zipfile.ZipInfo( + "lambda" + ) + info.external_attr = 0o777 << 16 + + # Write lambda.py into new .zip + zip_file_handler.writestr( + info, + str(code) + ) + + lambda_package_zip_data = lambda_package_zip.getvalue() + lambda_package_zip.close() + + return lambda_package_zip_data + + +############################################################################### +# Python 2.7 +############################################################################### + + +def get_python27_lambda_base_zip(aws_client_factory, credentials, libraries): + s3_client = aws_client_factory.get_aws_client( + "s3", + credentials + ) + + libraries_object = generate_libraries_dict(libraries) + + final_s3_package_zip_path = get_final_zip_package_path( + "python2.7", + libraries_object + ) + + object_exists = s3_object_exists( + aws_client_factory, + credentials, + credentials["lambda_packages_bucket"], + final_s3_package_zip_path + ) + + if object_exists: + return read_from_s3( + aws_client_factory, + credentials, + credentials["lambda_packages_bucket"], + final_s3_package_zip_path + ) + + # Kick off CodeBuild for the libraries to get a zip artifact of + # all of the libraries. + build_id = start_python27_codebuild( + aws_client_factory, + credentials, + libraries_object + ) + + # This continually polls for the CodeBuild build to finish + # Once it does it returns the raw artifact zip data. + return get_codebuild_artifact_zip_data( + aws_client_factory, + credentials, + build_id, + final_s3_package_zip_path + ) + + def start_python27_codebuild(aws_client_factory, credentials, libraries_object): """ Returns a build ID to be polled at a later time @@ -286,46 +516,6 @@ def start_python27_codebuild(aws_client_factory, credentials, libraries_object): return build_id -def get_python36_base_code(app_config, code): - code = code + "\n\n" + app_config.get("LAMDBA_BASE_CODES")["python3.6"] - return code - - -def build_python36_lambda(app_config, aws_client_factory, credentials, code, libraries): - code = get_python36_base_code( - app_config, - code - ) - - base_zip_data = copy.deepcopy(EMPTY_ZIP_DATA) - if len(libraries) > 0: - base_zip_data = get_python36_lambda_base_zip( - aws_client_factory, - credentials, - libraries - ) - - # Create a virtual file handler for the Lambda zip package - lambda_package_zip = BytesIO(base_zip_data) - - with ZipFile(lambda_package_zip, "a", ZIP_DEFLATED) as zip_file_handler: - info = zipfile.ZipInfo( - "lambda" - ) - info.external_attr = 0o777 << 16 - - # Write lambda.py into new .zip - zip_file_handler.writestr( - info, - str(code) - ) - - lambda_package_zip_data = lambda_package_zip.getvalue() - lambda_package_zip.close() - - return lambda_package_zip_data - - def get_python27_base_code(app_config, code): code = code + "\n\n" + app_config.get("LAMDBA_BASE_CODES")["python2.7"] return code diff --git a/front-end/src/constants/project-editor-constants.ts b/front-end/src/constants/project-editor-constants.ts index d445a8b5d..495fdd176 100644 --- a/front-end/src/constants/project-editor-constants.ts +++ b/front-end/src/constants/project-editor-constants.ts @@ -215,7 +215,11 @@ def main(block_input, backpack) return "Hello World!" end `, - [SupportedLanguage.PYTHON_3]: ` + [SupportedLanguage.PYTHON_36]: ` +def main(block_input, backpack): + return "Hello World!" +`, + [SupportedLanguage.PYTHON_38]: ` def main(block_input, backpack): return "Hello World!" `, diff --git a/front-end/src/store/modules/panes/edit-block-pane.ts b/front-end/src/store/modules/panes/edit-block-pane.ts index a303aefbe..3240d607d 100644 --- a/front-end/src/store/modules/panes/edit-block-pane.ts +++ b/front-end/src/store/modules/panes/edit-block-pane.ts @@ -677,8 +677,13 @@ const EditBlockPaneModule: Module = { // Check if the current block is python and if the next language is python too const isCurrentBlockPython = - selectedBlock.language === SupportedLanguage.PYTHON_2 || selectedBlock.language === SupportedLanguage.PYTHON_3; - const isNextBlockPython = language === SupportedLanguage.PYTHON_2 || language === SupportedLanguage.PYTHON_3; + selectedBlock.language === SupportedLanguage.PYTHON_2 || + selectedBlock.language === SupportedLanguage.PYTHON_36 || + selectedBlock.language === SupportedLanguage.PYTHON_38; + const isNextBlockPython = + language === SupportedLanguage.PYTHON_2 || + language === SupportedLanguage.PYTHON_36 || + language === SupportedLanguage.PYTHON_38; // If we are just swapping Python versions, then leave code + libraries alone. if (isCurrentBlockPython && isNextBlockPython) { diff --git a/front-end/src/types/graph.ts b/front-end/src/types/graph.ts index b404eecfb..471fc4dd0 100644 --- a/front-end/src/types/graph.ts +++ b/front-end/src/types/graph.ts @@ -22,7 +22,8 @@ export interface RefineryProject { export enum SupportedLanguage { RUBY2_6_4 = 'ruby2.6.4', - PYTHON_3 = 'python3.6', + PYTHON_38 = 'python3.8', + PYTHON_36 = 'python3.6', PYTHON_2 = 'python2.7', NODEJS_8 = 'nodejs8.10', NODEJS_10 = 'nodejs10.16.3', diff --git a/front-end/src/types/project-editor-types.ts b/front-end/src/types/project-editor-types.ts index 4e9630cc6..543afa793 100644 --- a/front-end/src/types/project-editor-types.ts +++ b/front-end/src/types/project-editor-types.ts @@ -93,7 +93,8 @@ export const languageToAceLangMap: MonacoLanguageLookup = { [SupportedLanguage.NODEJS_10]: 'javascript', [SupportedLanguage.NODEJS_1020]: 'javascript', [SupportedLanguage.PYTHON_2]: 'python', - [SupportedLanguage.PYTHON_3]: 'python', + [SupportedLanguage.PYTHON_36]: 'python', + [SupportedLanguage.PYTHON_38]: 'python', [SupportedLanguage.GO1_12]: 'go', [SupportedLanguage.PHP7]: 'php', [SupportedLanguage.RUBY2_6_4]: 'ruby', @@ -110,7 +111,8 @@ export const LanguageToBaseRepoURLMap: LanguageToBaseRepoURL = { [SupportedLanguage.NODEJS_10]: 'https://www.npmjs.com', [SupportedLanguage.NODEJS_1020]: 'https://www.npmjs.com', [SupportedLanguage.PYTHON_2]: 'https://pypi.org', - [SupportedLanguage.PYTHON_3]: 'https://pypi.org', + [SupportedLanguage.PYTHON_36]: 'https://pypi.org', + [SupportedLanguage.PYTHON_38]: 'https://pypi.org', [SupportedLanguage.GO1_12]: null, [SupportedLanguage.PHP7]: 'https://packagist.org', [SupportedLanguage.RUBY2_6_4]: 'https://rubygems.org' @@ -122,7 +124,8 @@ export const LanguageToLibraryRepoURLMap: LanguageToLibraryRepoURL = { [SupportedLanguage.NODEJS_8]: LanguageToBaseRepoURLMap[SupportedLanguage.NODEJS_8] + '/package/', [SupportedLanguage.NODEJS_10]: LanguageToBaseRepoURLMap[SupportedLanguage.NODEJS_10] + '/package/', [SupportedLanguage.NODEJS_1020]: LanguageToBaseRepoURLMap[SupportedLanguage.NODEJS_1020] + '/package/', - [SupportedLanguage.PYTHON_3]: LanguageToBaseRepoURLMap[SupportedLanguage.PYTHON_3] + '/project/', + [SupportedLanguage.PYTHON_38]: LanguageToBaseRepoURLMap[SupportedLanguage.PYTHON_38] + '/project/', + [SupportedLanguage.PYTHON_36]: LanguageToBaseRepoURLMap[SupportedLanguage.PYTHON_36] + '/project/', [SupportedLanguage.PYTHON_2]: LanguageToBaseRepoURLMap[SupportedLanguage.PYTHON_2] + '/project/', [SupportedLanguage.GO1_12]: null, [SupportedLanguage.PHP7]: LanguageToBaseRepoURLMap[SupportedLanguage.PHP7] + '/packages/psr/', diff --git a/front-end/src/utils/project-debug-utils.ts b/front-end/src/utils/project-debug-utils.ts index b889ad62d..b98589d67 100644 --- a/front-end/src/utils/project-debug-utils.ts +++ b/front-end/src/utils/project-debug-utils.ts @@ -35,7 +35,8 @@ export const languageToRunScriptLookup: LanguageToStringLookup = { [SupportedLanguage.NODEJS_8]: 'node run_code.js', [SupportedLanguage.NODEJS_10]: 'node run_code.js', [SupportedLanguage.NODEJS_1020]: 'node run_code.js', - [SupportedLanguage.PYTHON_3]: 'python run_code.py', + [SupportedLanguage.PYTHON_38]: 'python run_code.py', + [SupportedLanguage.PYTHON_36]: 'python run_code.py', [SupportedLanguage.PYTHON_2]: 'python run_code.py', [SupportedLanguage.GO1_12]: 'go run run_code.go', [SupportedLanguage.PHP7]: 'php -f run_code.php', @@ -46,7 +47,8 @@ export const languageToFileExtension: LanguageToStringLookup = { [SupportedLanguage.NODEJS_10]: 'js', [SupportedLanguage.NODEJS_1020]: 'js', [SupportedLanguage.NODEJS_8]: 'js', - [SupportedLanguage.PYTHON_3]: 'py', + [SupportedLanguage.PYTHON_38]: 'py', + [SupportedLanguage.PYTHON_36]: 'py', [SupportedLanguage.PYTHON_2]: 'py', [SupportedLanguage.GO1_12]: 'go', [SupportedLanguage.PHP7]: 'php', @@ -65,7 +67,8 @@ export const languageToPrependedCode: LanguageToStringLookup = { [SupportedLanguage.NODEJS_8]: '// This file was partially generated by Refinery', [SupportedLanguage.NODEJS_10]: '// This file was partially generated by Refinery', [SupportedLanguage.NODEJS_1020]: '// This file was partially generated by Refinery', - [SupportedLanguage.PYTHON_3]: pythonPrependedCode, + [SupportedLanguage.PYTHON_38]: pythonPrependedCode, + [SupportedLanguage.PYTHON_36]: pythonPrependedCode, [SupportedLanguage.PYTHON_2]: pythonPrependedCode, [SupportedLanguage.GO1_12]: '// This file was partially generated by Refinery', [SupportedLanguage.PHP7]: '// This file was partially generated by Refinery', @@ -124,7 +127,8 @@ export const languageToDependencies: Record< [SupportedLanguage.NODEJS_8]: getFormattedNodeDependencies, [SupportedLanguage.NODEJS_10]: getFormattedNodeDependencies, [SupportedLanguage.NODEJS_1020]: getFormattedNodeDependencies, - [SupportedLanguage.PYTHON_3]: getFormattedPythonDependencies, + [SupportedLanguage.PYTHON_38]: getFormattedPythonDependencies, + [SupportedLanguage.PYTHON_36]: getFormattedPythonDependencies, [SupportedLanguage.PYTHON_2]: getFormattedPythonDependencies, [SupportedLanguage.GO1_12]: depsNotSupported, [SupportedLanguage.PHP7]: depsNotSupported, @@ -177,7 +181,8 @@ export const languageToAppendedCode: LanguageToStringLookup = { [SupportedLanguage.NODEJS_8]: nodeAppendedCode, [SupportedLanguage.NODEJS_10]: nodeAppendedCode, [SupportedLanguage.NODEJS_1020]: nodeAppendedCode, - [SupportedLanguage.PYTHON_3]: pythonAppendedCode, + [SupportedLanguage.PYTHON_38]: pythonAppendedCode, + [SupportedLanguage.PYTHON_36]: pythonAppendedCode, [SupportedLanguage.PYTHON_2]: pythonAppendedCode, [SupportedLanguage.GO1_12]: '\n// Not supported yet. Read block_config.yaml then call main().\nAlso email support@refinery.io and we will add this. :)', From 8315fe9d95af75bbbd401b9f66ea943d0390b0ce Mon Sep 17 00:00:00 2001 From: iakinsey Date: Mon, 2 Nov 2020 16:57:17 -0800 Subject: [PATCH 2/2] Add runtime changes --- custom-runtime/languages/build_all.sh | 3 +++ custom-runtime/languages/python3.8/.gitignore | 2 ++ custom-runtime/languages/python3.8/build.sh | 12 ++++++++++++ custom-runtime/languages/python3.8/runtime | 3 +++ 4 files changed, 20 insertions(+) create mode 100644 custom-runtime/languages/python3.8/.gitignore create mode 100755 custom-runtime/languages/python3.8/build.sh create mode 100755 custom-runtime/languages/python3.8/runtime diff --git a/custom-runtime/languages/build_all.sh b/custom-runtime/languages/build_all.sh index 58c1c2e3a..e91308196 100755 --- a/custom-runtime/languages/build_all.sh +++ b/custom-runtime/languages/build_all.sh @@ -24,6 +24,9 @@ cd ../ cd python3.6/ ./build.sh cd ../ +cd python3.8/ +./build.sh +cd ../ cd ruby2.6.4/ ./build.sh cd ../ diff --git a/custom-runtime/languages/python3.8/.gitignore b/custom-runtime/languages/python3.8/.gitignore new file mode 100644 index 000000000..d31e89e5f --- /dev/null +++ b/custom-runtime/languages/python3.8/.gitignore @@ -0,0 +1,2 @@ +layer-contents/* +custom-runtime.zip diff --git a/custom-runtime/languages/python3.8/build.sh b/custom-runtime/languages/python3.8/build.sh new file mode 100755 index 000000000..620fc1d95 --- /dev/null +++ b/custom-runtime/languages/python3.8/build.sh @@ -0,0 +1,12 @@ +#!/bin/bash +echo "Building Python 3.8 Refinery custom runtime layer package..." +mkdir -p ./layer-contents +rm -rf ./layer-contents/* +cp runtime ./layer-contents/ +cp -r ../../base-src/* ./layer-contents/ +cp runtime ./layer-contents/ +cd ./layer-contents/ +zip -qr custom-runtime.zip * +mv custom-runtime.zip ../ +cd .. +rm -rf ./layer-contents/* diff --git a/custom-runtime/languages/python3.8/runtime b/custom-runtime/languages/python3.8/runtime new file mode 100755 index 000000000..ab1b9a153 --- /dev/null +++ b/custom-runtime/languages/python3.8/runtime @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# Python 3.8 is included in all Lambda execution environments, so we just run the script with that. +python3 "$@"