Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support conda environments #94

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions zappa/zappa.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from lambda_packages import lambda_packages
from os.path import expanduser
from tqdm import tqdm
from platform import machine

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -245,11 +246,26 @@ def create_lambda_zip(self, prefix='lambda_package', handler_file=None,
print("Packaging project as zip...")

if not venv:
try:
venv = os.environ['VIRTUAL_ENV']
except KeyError as e: # pragma: no cover
print("Zappa requires an active virtual environment.")
virtual_env = os.environ.get('VIRTUAL_ENV', None)
conda_env = os.environ.get('CONDA_ENV_PATH', None)
if virtual_env is None and conda_env is None:
print("Zappa requires an active virtual or conda environment.")
quit()
elif virtual_env is not None and conda_env is not None:
print('Ambiguous environment: both virtual environments and conda environments are active.')
quit()
else:
venv = virtual_env if virtual_env is not None else conda_env
if conda_env is not None:
if (('linux' not in sys.platform)
or (machine() in ['armv6l', 'armv7l', 'ppc64le'])
or (8 * tuple.__itemsize__ != 64)):
warnings.warn('The local architecture is different than that of AWS lambda (linux-64).\nMake sure the binaries in your conda environment are compatible with AWS lambda')
if sys.version_info[:2] != (2,7):
warnings.warn('The local python version is different than that of AWS lambda (2.7.x).\nMake sure the binaries in your conda environment are compatible with AWS lambda')
if use_precompiled_packages:
warnings.warn('Using conda while use_precompiled_packages is set to true is not recommended: it may lead to overwriting conda packages')


cwd = os.getcwd()
zip_fname = prefix + '-' + str(int(time.time())) + '.zip'
Expand Down