Created
August 3, 2019 15:47
-
-
Save kisst/540bccb677922346d0e53ca73bca9c0a to your computer and use it in GitHub Desktop.
Medium ...
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
import lambdalayer.mymodule | |
def lambda_handler(event, context) | |
mymodule.offloadedcode(event, context) |
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
# to be able to reload existing imports | |
import importlib | |
# add my pip location | |
sys.path.insert(0, '/tmp/upload') | |
# now import the core | |
import botocore | |
# reload it | |
importlib.reload(botocore) | |
# and now ready to import boto3 | |
import boto3 |
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
def install_with_pip(packages): | |
""" | |
Install pip package into /tmp folder | |
""" | |
print(" -- Installing pip packages") | |
logfile = open("/tmp/pip-install.log", "wb") | |
for package in packages: | |
print(" ---- Installing {}".format(package)) | |
subprocess.check_call([ | |
sys.executable, '-m', 'pip', 'install', | |
'--upgrade', '-t', PKG_DIR, package], stdout=logfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment