kappa icon indicating copy to clipboard operation
kappa copied to clipboard

Include python dependencies

Open anthonysgevans opened this issue 8 years ago • 7 comments

Hi All,

Two feature suggestions...

Pull in python dependencies Is there any appetite to have a command line option that pulls in python dependencies during the the deploy command?

Separate source and build directories Executing pip install -r requirements.txt -t /path/to/source/ creates a lot of noise in the source directory. It would be great if we could create a separate build directory to create the lambda zip package.

I've got some time to spend on this if people think it could be useful.

Cheers,

Anthony.

anthonysgevans avatar Jul 20 '16 08:07 anthonysgevans

I would be interested in this - I've just started using kappa this week to set up a build environment.

I ended up using the (undocumented) 'dependencies' configuration option to include a separate directory, and installing the requirements to that as part of the build outside of kappa. It would definitely be cleaner to have an option to install the given packages and append to the packaging path inside kappa.

Might be worth considering how we should handle dependencies like "kappa" or "boto3" - I ended up with two requirements.txt, one for local build/test/deployment, which included a smaller set for the actual upload to lambda.

michaelkaye avatar Jul 20 '16 10:07 michaelkaye

I have no idea what this feature request means. If you want to provide some code to implement this feature, cool, otherwise that will be a no from me :)

josegonzalez avatar Jul 20 '16 16:07 josegonzalez

👍 for the ideas.

It would be nice if kappa was able to run pip install -r _src/requirements.txt to install dependencies into build directory when creating the bundle. Manually executing this command into _src/ adds a lot of noise into the project structure. This is the reason why I have to use exclusive gitignore rules like: !_src/lambda.py, !_src/requirements.txt etc...

In my opinion the following kappa project structure should be present:

./
  _src/
        lambda.py
        requirements.txt
        setup.cfg
  _tests
  _build
  kappa.yaml
  requirements.txt    #with kappa and boto

On kappa deploy:

  1. pip install -r requirements.txt -t ./_build
  2. Creating bundle...

It would be also nice to have a subcommand like kappa init that is able to initialize a project directory like vagrant does.

What do u think?

justcallmegreg avatar Jul 21 '16 11:07 justcallmegreg

It would be also nice to have a subcommand like kappa init that is able to initialize a project directory like vagrant does.

This would be great. I've written a new-project playbook with ansible to do this for the time being but kappa init would be much better.

On kappa deploy:

  1. pip install -r requirements.txt -t ./_build

We could use the runtime defined in kappa.yml to know when to pull in python requirements (and not JS).

anthonysgevans avatar Jul 21 '16 11:07 anthonysgevans

FYI, I've published the skeleton project I used to init my kappa repos with. Here it is.

(I'm also working on pre-commit hooks especially for developing AWS lambdas)

justcallmegreg avatar Jul 22 '16 06:07 justcallmegreg

I worked around this problem by creating a script which: 0. Have source: _build/ in kappa.yml

  1. creates a _build directory
  2. cp _src/* _build
  3. Run the pip install -t command
  4. Runs kappa

It would be nice if kappa can do something similar.

stonemary avatar Dec 14 '16 23:12 stonemary

Looking at https://github.com/garnaat/kappa/blob/develop/kappa/function.py#L69 seems that dependencies could be installed somewhere else and then listed in the kappa.yml file.

I didn't try that yet, but can someone confirm if my understanding is correct?

luizs81 avatar May 09 '17 15:05 luizs81