apex / up

Deploy infinitely scalable serverless apps, apis, and sites in seconds to AWS.
https://up.docs.apex.sh
MIT License
8.78k stars 373 forks source link

Better Python integration #757

Open tj opened 5 years ago

tj commented 5 years ago

I'm not too familiar with the ecosystem, it seems a little confusing to get it installing deps in the CWD without creating issues elsewhere. Need to research what the idiomatic approach is and adjust the default hooks accordingly—these may also vary for python2.7 and python3, I'm not positive.

Seems like homebrew's installation is also non-standard, which makes it more confusing :D

adamJLev commented 5 years ago

Most of this stuff works very similar to how node deps works, you just need to run pipenv first to setup a "virtual python environment" using a specified Python version. Heroku handles this by checking for a runtime.txt which contains python version .e.g 3.7

A very basic way to get this to work better is to also support pipenv, which is nowadays the best practice in python-land.

E.g.

pipenv --python 3.7
pipenv install

Just like now its checking for requirements.txt and running pip, it could check for Pipfile.lock and run the commands above

https://docs.pipenv.org/en/latest/basics/

catcombo commented 5 years ago

For example, I prefer to use poetry instead of pipenv. Someone may say conda. I think there are two options:

  1. Use pip to install dependencies from requirements.txt and force user to update this file before deploy their code. pip is available in all versions of Python out of box. pipenv and poetry has a command to export dependencies to requirements.txt.
  2. Give an option to user to specify package management tool they use in the project. So the up will discover appropriate command to run to install dependencies.
adamehirsch commented 4 years ago

Just verifying an assumption -- I've got an app written in python that's using python 3.6 features. It appears that the node10 Lambda runtimes appear to no longer ship with any python interpreter (I get "message": "sh: python: command not found" when attempting to invoke it after deploying with up) and the AWS node8 runtime appears to have an older python (3.4, maybe?) included.

Given that, I'm assuming that at this moment, there's not a good path for me deploying with up, and I should bide my time or try another framework? (I still have a couple of lambdas deployed with apex, still... ;)

Consider the above a scenario for which I'd love to use up someday, regardless.

tj commented 4 years ago

@adamehirsch yea that's correct unfortunately, they removed the binaries. If they ever make Lambda Layers more flexible, then I could easily add support for the other languages, but as-is they're not.

Even something similar like exposing the existing runtimes they support as Layer ARNs, I mentioned this stuff to them a year or so ago, but they don't seem interested. They make it really hard to add a "proxy" layer which handles the event while also allowing the user to choose their runtime.