Skip to content

Commit 75a0539

Browse files
committed
Adding Python3.6 support for local and runtime environments
1 parent 7ebee04 commit 75a0539

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,6 @@ docs/_build/
5757

5858
# PyBuilder
5959
target/
60+
61+
# Jetbrains/PyCharm project files
62+
.idea/

README.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ python-λ
1212

1313
Python-lambda is a toolset for developing and deploying *serverless* Python code in AWS Lambda.
1414

15+
NOTE: CHANGES FROM BASE REPOSITORY
16+
============================
17+
18+
* Adding Python 3.6 support for the local environment & the lambda runtime
19+
20+
1521
A call for contributors
1622
=======================
1723
With python-lambda and `pytube <https://github.com/nficano/pytube/>`_ both continuing to gain momentum, I'm calling for contributors to help build out new features, review pull requests, fix bugs, and maintain overall code quality. If you're interested, please email me at nficano[at]gmail.com.
@@ -28,7 +34,7 @@ The *Python-Lambda* library takes away the guess work of developing your Python-
2834
Requirements
2935
============
3036

31-
* Python 2.7 (At the time of writing this, AWS Lambda only supports Python 2.7).
37+
* Python 2.7 & 3.6 (At the time of writing this, AWS Lambda only supports Python 2.7/3.6).
3238
* Pip (~8.1.1)
3339
* Virtualenv (~15.0.0)
3440
* Virtualenvwrapper (~4.7.1)

aws_lambda/aws_lambda.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def create_function(cfg, path_to_zip_file):
344344
"""Register and upload a function to AWS Lambda."""
345345

346346
print('Creating your new Lambda function')
347-
byte_stream = read(path_to_zip_file)
347+
byte_stream = read(path_to_zip_file, binary_file=True)
348348
aws_access_key_id = cfg.get('aws_access_key_id')
349349
aws_secret_access_key = cfg.get('aws_secret_access_key')
350350

@@ -389,7 +389,7 @@ def update_function(cfg, path_to_zip_file):
389389
"""Updates the code of an existing Lambda function"""
390390

391391
print('Updating your Lambda function')
392-
byte_stream = read(path_to_zip_file)
392+
byte_stream = read(path_to_zip_file, binary_file=True)
393393
aws_access_key_id = cfg.get('aws_access_key_id')
394394
aws_secret_access_key = cfg.get('aws_secret_access_key')
395395

aws_lambda/helpers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# -*- coding: utf-8 -*-
2-
import datetime as dt
32
import os
43
import zipfile
4+
import datetime as dt
55

66

77
def mkdir(path):
88
if not os.path.exists(path):
99
os.makedirs(path)
1010

1111

12-
def read(path, loader=None):
13-
with open(path) as fh:
12+
def read(path, loader=None, binary_file=False):
13+
open_mode = 'rb' if binary_file else 'r'
14+
with open(path, mode=open_mode) as fh:
1415
if not loader:
1516
return fh.read()
1617
return loader(fh.read())

aws_lambda/project_templates/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ function_name: my_lambda_function
44
handler: service.handler
55
# role: lambda_basic_execution
66
description: My first lambda function
7+
runtime: python2.7
78

89
# if access key and secret are left blank, boto will use the credentials
910
# defined in the [default] section of ~/.aws/credentials.
@@ -14,6 +15,7 @@ aws_secret_access_key:
1415
# timeout: 15
1516
# memory_size: 512
1617
#
18+
1719
# Experimental Environment variables
1820
environment_variables:
1921
env_1: foo

0 commit comments

Comments
 (0)