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
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?
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.
@daneah it can be addressed by splitting codebase into two repos - CLI and core.
@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.
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.
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.
Most helpful comment
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.pyfile so we can iterate through all your@app.routedeclarations and parsing your app source code using theastandsymtablemodule 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.