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

Deploying with cryptography package (in pywebpush) in Python 3.7 #1106

Closed
PapoyEdits opened this issue Apr 9, 2019 · 5 comments
Closed

Deploying with cryptography package (in pywebpush) in Python 3.7 #1106

PapoyEdits opened this issue Apr 9, 2019 · 5 comments

Comments

@PapoyEdits
Copy link

PapoyEdits commented Apr 9, 2019

So I've encountered an issue when trying to deploy while using the pywebpush package. When I deploy I receive this error:

Could not install dependencies:
cryptography==2.6.1
You will have to build these yourself and vendor them in
the chalice vendor folder.

And when trying to execute the Lambda it complains that it couldn't import the cryptography module. To note, when running it with chalice local everything works as expected, it's only on the deploy that things start to go wrong.

After looking into it a bit, I've discovered that the cryptography package in particular causes problems, though according to the docs it should have been fixed after 2.0.0 was released. I then discovered that later releases of it started causing issues again: #764
So I then looked into the docs regarding how to manually add it to the vendor folder, though I encountered another problem with that. According to the documentation, one is supposed to go into a Amazon Linux EC2 instance and follow the instructions. However, apparently they don't support Python 3.7.

So I'm a bit confused with how I should approach this.

  • First off, is it enough to do the whole wheel process for only the cryptography package or will it be necessary to do it on the entire pywebpush?
  • When using Python 3.7, how do you setup an EC2 to build the wheel?

Edit:
So I've solved one part of the issue, I managed to set up an Amazon Linux 2 EC2 instance (instead of regular Amazon Linux), which supports Python 3.7. As such I was able to build the wheel for cryptography 2.1.4 (according to #764 that was the last functioning version). However, when using this I encountered an error as pywebpush relies on, at the very least, cryptography 2.5.0. Specifically, they added an X962 encoding which doesn't work.

I will try to build a wheel for various versions of pywebpush and cryptography, though things seem grim at the moment.

@jamesls
Copy link
Member

jamesls commented Apr 10, 2019

Can you share the steps you tried? This should just work. I'm not seeing any issues when I try to package both pywebpush and the specific version of cryptography in your description. Here's what I tried:

$ chalice new-project pywebpush
$ cd pywebpush
$ python --version
Python 3.7.0
$ echo pywebpush > requirements.txt
$ chalice package out
Creating deployment package.

# Verify we packaged correctly
$ unzip -l out/deployment.zip | egrep '(cryptography|pyweb)'
     816  04-10-2019 09:17   cryptography/__about__.py
      527  04-10-2019 09:17   cryptography/__init__.py
     1234  04-10-2019 09:17   cryptography/exceptions.py
     5220  04-10-2019 09:17   cryptography/fernet.py
     4962  04-10-2019 09:17   cryptography/utils.py
      483  04-10-2019 09:17   cryptography/hazmat/__init__.py
... omitted ...
  15926  04-10-2019 09:17   pywebpush/__init__.py
     1960  04-10-2019 09:17   pywebpush/__main__.py
    15015  04-10-2019 09:17   pywebpush/tests/test_webpush.py
     7128  04-10-2019 09:17   pywebpush-1.9.2.dist-info/DESCRIPTION.rst
       67  04-10-2019 0
... omitted ...

Can you confirm you're using the latest version of chalice?

@PapoyEdits
Copy link
Author

That's really strange then, I tried the exact same steps as you did, I created a new project and everything but I still get the

Could not install dependencies:
cryptography==2.6.1
You will have to build these yourself and vendor them in
the chalice vendor folder.

This is my version of Chalice and AWS-CLI:

chalice --version
chalice 1.8.0, python 3.7.2, windows 10

aws --version
aws-cli/1.16.140 Python/3.7.2 Windows/10 botocore/1.12.130

I've tried building various versions of the pywebpush and cryptography in the Amazon Linux 2 instance, to no avail.

@PapoyEdits
Copy link
Author

Is there any alternate way of ensuring that the dependency is added? pyywebpush is a perfect fit for our use case and it would suck to have to remove it/find something else.

@PapoyEdits
Copy link
Author

@jamesls Sorry for badgering you, but I would really appreciate your assistance (am I supposed to @ you when posting a follow up comment?). Does the platform you sit on when packaging it matter? I'm sitting on Windows 10, do you need to do it on linux instead? I've tried using Python 3.7.0 instead of 3.7.2, but that made no difference

@PapoyEdits
Copy link
Author

Ok, so I'm not entirely sure about what I did differently this time, but after building the cryptography wheel in the Amazon Linux 2 instance and unpacking it to the vendor folder, with the dependencies listed for cryptography (cffi, pycparser, six, asn1crypto) + pywebpush, it somehow worked. I apologise for my badgering, and I'll close this issue.

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

2 participants