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

CLI not compatible with Python 3+ #25

Closed
chpiatt opened this issue Jul 11, 2016 · 6 comments
Closed

CLI not compatible with Python 3+ #25

chpiatt opened this issue Jul 11, 2016 · 6 comments

Comments

@chpiatt
Copy link

chpiatt commented Jul 11, 2016

Getting a syntax error when I try to run the CLI commands. The print statement in the CLI init.py file doesn't have parentheses:

    print event['timestamp'], event['logShortId'], event['message'].strip()
         ^
SyntaxError: invalid syntax
@daneah
Copy link

daneah commented Jul 11, 2016

I was initially going to open such an issue but wondered if this compatibility was passed on for now since AWS Lambda only supports Python 2.7 anyway. I'd love for the CLI to support Python 3 as well, but could it lead some to write incompatible code inadvertently?

@jamesls
Copy link
Member

jamesls commented Jul 11, 2016

The intent is for chalice to support the same versions of python that AWS Lambda supports, which is currently python 2.7. So while possible to make it work, it could be confusing to work on your app in python3, but only to have it fail when deploying to lambda.

The more technical reason why supporting python3 is challenging in chalice is because chalice introspects your source code in order to configure things automatically for you, including importing your app.py file so we can iterate through all your @app.route declarations and parsing your app source code using the ast and symtable module for policy generation. So even if the chalice code base worked in python2/python3, the minute we try to import your app, and your app happens to have a "print 'foo'" statement in it, it'll fail.

@denismakogon
Copy link

@daneah it can be addressed by splitting codebase into two repos - CLI and core.

@bbock
Copy link

bbock commented Jul 28, 2016

@jamesls sounds absolutely reasonable. Mentioning it in the Readme would be helpful, as I just stumbled across it and had to find this bug report to understand whats going on.

@jamesls jamesls closed this as completed in 225765e Aug 1, 2016
@jamesls
Copy link
Member

jamesls commented Aug 1, 2016

I added a note in the README about supported python versions.

The plan is to support whatever versions AWS Lambda supports. So, for example, if lambda supports python3, and you want to use the python3 runtime, you'd simply create a virtualenv with python3. The chalice code would ideally be able to run on both python2 and python3.

@nealmcb
Copy link

nealmcb commented Mar 22, 2017

It is hard to believe that Amazon's premier entry in the hot "serverless" space still only supports the dying technology of Python 2. For those that haven't looked in recent years, support for Python 2 is due to end in 2020. Ubuntu doesn't even install it by default. A summary of the situation (with a nice graphical timeline showing nearly all other enviroments already ported to Python 3) is at http://www.python3statement.org/

Please reopen this bug until Chalice at least provides better support for projects that are trying to ensure Python 3 compatibility, i.e. having code that can be imported into a python 3 code base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants