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

zappa package with slim_handler=true doesn't include Werkzeug package (introduced v0.46.0) #1547

Open
sheats opened this issue Jun 25, 2018 · 8 comments

Comments

@sheats
Copy link

sheats commented Jun 25, 2018

Context

I thought I was running into issue #64 but turns out I found a regression introduced in v0.46 related to how the handler_venv is packaged and uploaded when using slim_handler.

I created a small repo to show the problem: https://github.com/sheats/zappa_issue
If you keep zappa==0.46.0 (or 0.46.1) in requirements.txt and deploy the function the only thing that prints in the logs is:

Unable to import module 'handler': No module named 'werkzeug'

If you change requirements.txt to zappa==0.45.1 and update the function the problem goes away.

When I unzipped the handler venv zip after running zappa package I only see the following:

drwx------   9 user  staff    288 Jun 25 06:27 .
drwxr-xr-x  16 user  staff    512 Jun 25 06:27 ..
-rwxr-xr-x   1 user  staff      0 Jun 25  2018 __init__.py
-rw-------@  1 user  staff  85824 Dec 31  1979 _sqlite3.so
-rw-r--r--   1 user  staff    605 Sep 13  2016 django_zappa_app.py
-rw-------   1 user  staff  23461 Dec 31  1979 handler.py
-rw-------   1 user  staff    143 Dec 31  1979 package_info.json
drwxr-xr-x  14 user  staff    448 Jun 25 06:27 zappa
-rw-r--r--   1 user  staff    467 Jun 25  2018 zappa_settings.py

Expected Behavior

I expect the logs to show other errors or normal successful logs.

Actual Behavior

handler.py tries to import werkzeug on line 17 but fails because Werkzeug wasn't included in the handler_venv zipped package.

Possible Fix

Don't know the code well enough to come up with a fix strategy yet.

Steps to Reproduce

git clone [email protected]:sheats/zappa_issue.git
make reproduce && make tail

Your Environment

Everything is in the repo I referenced.

@mherrarte
Copy link

Same here! I just downgraded to 0.45.1

@giovannicimolin
Copy link

Same here, downgrading to 0.45.1 solves the problem.

@5bodnar
Copy link

5bodnar commented Jun 30, 2018

Had the same issue and can confirm that downgrading to 0.45.1 solves it.

@jneves
Copy link
Collaborator

jneves commented Jul 3, 2018

@sheats @giovannicimolin @5bodnar can any of you try with the current zappa master branch?

@sheats
Copy link
Author

sheats commented Jul 7, 2018

@jneves I've been out of town all week but finally got a chance to try it.

I hit the following issue though... have any recommendations to avoid this? Seems like the zappa code is treating the .egg-link file as a directory. These are the changes I made to use the zappa master branch.

>-r /code/requirements.txt (line 5))
Installing collected packages: zappa
  Found existing installation: zappa 0.46.0
    Uninstalling zappa-0.46.0:
      Successfully uninstalled zappa-0.46.0
  Running setup.py develop for zappa
Successfully installed zappa
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
zappashell> zappa deploy
Important! A new version of Zappa is available!
Upgrade with: pip install zappa --upgrade
Visit the project page on GitHub to see the latest changes: https://github.com/Miserlou/Zappa
Calling deploy for stage master..
Downloading and installing dependencies..
 - sqlite==python36: Using precompiled lambda package
Packaging project as gzipped tarball.
Oh no! An error occurred! :(

==============

Traceback (most recent call last):
  File "/var/venv/src/zappa/zappa/cli.py", line 2693, in handle
    sys.exit(cli.handle())
  File "/var/venv/src/zappa/zappa/cli.py", line 504, in handle
    self.dispatch_command(self.command, stage)
  File "/var/venv/src/zappa/zappa/cli.py", line 541, in dispatch_command
    self.deploy(self.vargs['zip'])
  File "/var/venv/src/zappa/zappa/cli.py", line 710, in deploy
    self.create_package()
  File "/var/venv/src/zappa/zappa/cli.py", line 2171, in create_package
    venv=self.zappa.create_handler_venv(),
  File "/var/venv/src/zappa/zappa/core.py", line 403, in create_handler_venv
    copytree(os.path.join(current_site_packages_dir, z), os.path.join(venv_site_packages_dir, z))
  File "/var/venv/src/zappa/zappa/utilities.py", line 37, in copytree
    lst = os.listdir(src)
NotADirectoryError: [Errno 20] Not a directory: '/var/venv/lib/python3.6/site-packages/zappa.egg-link'

@jneves
Copy link
Collaborator

jneves commented Jul 8, 2018

@sheats can you try the workaround on #1549 ?

@sheats
Copy link
Author

sheats commented Jul 8, 2018

@jneves thanks, that helped. Your fix appears to fix the No module named 'werkzeug' error in my repo.

@jneves
Copy link
Collaborator

jneves commented Jul 8, 2018 via email

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

5 participants