Created
May 10, 2020 23:25
-
-
Save thomelane/d1b2eeac9ad10476c13bc5044c381b13 to your computer and use it in GitHub Desktop.
Runtime install of PyPI package inside AWS Lambda function
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 tempfile | |
from pathlib import Path | |
import subprocess | |
import sys | |
tmp_path = Path(tempfile.gettempdir()) | |
packages = ['crhelper'] | |
for package in packages: | |
subprocess.check_call([ | |
sys.executable, "-m", "pip", "install", "--target={}".format(tmp_path), package | |
]) | |
sys.path.append(str(tmp_path)) | |
import crhelper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment