jarpy / lambkin

CLI tool for generating and managing simple functions in AWS Lambda
Apache License 2.0
74 stars 12 forks source link

lambkin does not zips module from /venv/lib64 #9

Closed MukeshSingh28 closed 7 years ago

MukeshSingh28 commented 7 years ago

Hello Guys,

My cryptography module gets install in /venv/lib64/python2.7/site-packages , as observed lambkin only zips module from /venv/lib/python2.7/site-packages hence the lambda function fails to execute, due to missing package files. But if I manually zip all modules from both the lib folder, the function works fine. Any help on this ? as I find lambkin very easy tool for building lambda function locally and want to continue using it :)

jarpy commented 7 years ago

Thanks for the positive feedback, Mukesh! :)

This sounds like a pretty easy fix. Do you have an example to reproduce the problem? No problem if you don't, or can't share it, but if you can, I can be sure that the fix works for you before I push it.

MukeshSingh28 commented 7 years ago

Though I could not specify exact details, but following will help you to reproduce error: Case 1 -- Platform : Mac OSX 10.11.6 Python 2.7.12 Python module failing to zip in lambda : cryptography comment : Though this module is present in /venv/lib/python2.7/site-packages , but lambkin does not publish this module to lambda function, and rather publishes all other module, when I download code from AWS console and check it.

Case 2--- Platform : Amazon AMI x86_64 architecture python 2.7.12 Python module failing to zip in lambda : cryptography comment : This module is present in /venv/lib64/python2.7/site-packages, but lambkin here fails to publish all site packages from this file path but successfully publishes module from /venv/lib/python2.7/site-packages

jarpy commented 7 years ago

Just taking a look at this. Sorry for the delay.

The lib64 directory doesn't exist on my Ubuntu systems, so I tried it out on an Amazon Linux instance. On that instance, lib64 is a symlink to lib, so the contents are identical.

Is that what you see on your Amazon Linux system?

[ec2-user@ip-10-56-56-31 ~]$ lambkin create test
test created as test/test.py

[ec2-user@ip-10-56-56-31 ~]$ cd test/

[ec2-user@ip-10-56-56-31 test]$ echo 'cryptography' > requirements.txt

[ec2-user@ip-10-56-56-31 test]$ lambkin build
[...]

[ec2-user@ip-10-56-56-31 test]$ ls -l venv/
total 20
drwxrwxr-x 2 ec2-user ec2-user 4096 Nov  3 01:38 bin
drwxrwxr-x 2 ec2-user ec2-user 4096 Nov  3 01:37 include
drwxrwxr-x 3 ec2-user ec2-user 4096 Nov  3 01:37 lib
lrwxrwxrwx 1 ec2-user ec2-user    3 Nov  3 01:37 lib64 -> lib
drwxrwxr-x 2 ec2-user ec2-user 4096 Nov  3 01:37 local
-rw-rw-r-- 1 ec2-user ec2-user   60 Nov  3 01:37 pip-selfcheck.json

[ec2-user@ip-10-56-56-31 test]$ diff -r venv/lib/ venv/lib64/ && echo identical
identical
jarpy commented 7 years ago

In case I'm not understanding correctly, here's an experimental patch that gives the behaviour you wanted.

https://github.com/jarpy/lambkin/commit/b095e6861e947ce559db36e32af92791e31d9962

You can try it out with a pip command like:

pip install --user --upgrade git+https://github.com/jarpy/lambkin@lib64

Please let me know if any of this helps.

MukeshSingh28 commented 7 years ago

Hello @jarpy ,

The patched worked for me, will continue using lambkin , thanks for the fix :)

btw, in my linux AMI, lib64 is not the symlink for lib. AMI ID – ami-dc361ebf in the Asia Pacific (Sydney) region.

jarpy commented 7 years ago

OK, that's great! I'm a bit confused now. 😕

Anyway, the patch works for you and does no harm, so it's definitely an improvement. I'll merge it to master and release a new version of Lambkin on PyPI.

Thanks for the report, and "Hi" from Melbourne. 👋