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

Chalice deploy cannot install dependencies #803

Closed
corte opened this issue Apr 19, 2018 · 4 comments
Closed

Chalice deploy cannot install dependencies #803

corte opened this issue Apr 19, 2018 · 4 comments

Comments

@corte
Copy link

corte commented Apr 19, 2018

I tried to follow the packaging instructions in https://github.com/aws/chalice/blob/master/docs/source/topics/packaging.rst
but still get errors while running chalice deploy with dependency cryptography (version 2.2.2).

Error message:

Creating deployment package.

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

While downloading package cryptography I noticed that pycparser is not wheeled so I tried to run pip wheel pycparser and added the wheel file in the cryptography-2.2.2.dist-info folder, but didn't help.
my vendor folder:

vendor
├───cryptography
│       asn1crypto-0.24.0-py2.py3-none-any.whl
│       cffi-1.11.5-cp36-cp36m-win32.whl
│       cryptography-2.2.2-cp36-cp36m-win32.whl
│       idna-2.6-py2.py3-none-any.whl
│       pycparser-2.18-py2.py3-none-any.whl
│       pycparser-2.18.tar.gz
│       six-1.11.0-py2.py3-none-any.whl
│
├───cryptography-2.2.2.dist-info
│       asn1crypto-0.24.0-py2.py3-none-any.whl
│       cffi-1.11.5-cp36-cp36m-win32.whl
│       cryptography-2.2.2-cp36-cp36m-win32.whl
│       idna-2.6-py2.py3-none-any.whl
│       pycparser-2.18-py2.py3-none-any.whl
│       six-1.11.0-py2.py3-none-any.whl
│
├───pycparser
│       pycparser-2.18-py2.py3-none-any.whl
│       pycparser-2.18.tar.gz
│
├───pyjwt
│       PyJWT-1.6.1-py2.py3-none-any.whl
│
└───requests
        certifi-2018.4.16-py2.py3-none-any.whl
        chardet-3.0.4-py2.py3-none-any.whl
        idna-2.6-py2.py3-none-any.whl
        requests-2.18.4-py2.py3-none-any.whl
        urllib3-1.22-py2.py3-none-any.whl

my requests.txt file:

pymysql
chalice
boto3
pyjwt==1.6.1
requests==2.18.4
cryptography==2.2.2 

What am I doing wrong?

@dstufft
Copy link

dstufft commented Apr 23, 2018

It looks like there is possibly some confusion here. I think what you need to do right now is to delete everything that's currently in your vendor/ directory, and then download the manylinux cffi wheel and unzip it into the vendor/ folder.

Let me know if that resolves this for you!

@corte
Copy link
Author

corte commented Apr 23, 2018

Why specifically cffi, if I'm having troubles with cryptography?
Well, I tried with both cffi and cryptography and still get an error:
pip download cffi
opened *.whl file and extracted folders cffi and cffi-1.11.5.dist-info into vendor folder.
Same error Could not install dependencies: cryptography==2.2.2.

Then:
pip download cryptography=2.2.2
Extracted file cryptography-2.2.2-cp36-cp36m-win32.whl into vendor folder and now have two folders there cryptography and cryptography-2.2.2.dist-info.
Same error Could not install dependencies: cryptography==2.2.2.
And I tried deleting the whole vendor folder and at every step I tried running chalice deploy, but still same error.

@stealthycoin
Copy link
Contributor

stealthycoin commented Apr 25, 2018

A few things:

  • You are saying you extracted cryptography-2.2.2-cp36-cp36m-win32.whl which is a windows specific whl file. This will not work on lambda. The tutorial for having to manually vendor C libraries yourself details logging into an EC2 instance that is compatible with the lambda runtime, that way when it compiles a whl file it will contain compatible binaries.
  • The file list you showed for extracting the vendor directory is not correct. Whl files do not have more whl file inside of them. For example if I download and unzip the cryptography whl into the vendor directory I get this structure.
vendor
└── cryptography
    ├── __about__.py
    ├── __init__.py
    ├── exceptions.py
    ├── fernet.py
    ├── hazmat
    │   ├── __init__.py
    │   ├── backends
    │   │   ├── __init__.py
    │   │   ├── interfaces.py
    │   │   └── openssl
    │   │       ├── __init__.py
    │   │       ├── aead.py
    │   │       ├── backend.py
    │   │       ├── ciphers.py
    │   │       ├── cmac.py
    │   │       ├── decode_asn1.py
    │   │       ├── dh.py
    │   │       ├── dsa.py
    │   │       ├── ec.py
    │   │       ├── encode_asn1.py
    │   │       ├── hashes.py
    │   │       ├── hmac.py
    │   │       ├── rsa.py
    │   │       ├── utils.py
    │   │       ├── x25519.py
    │   │       └── x509.py
    │   ├── bindings
    │   │   ├── __init__.py
    │   │   ├── _constant_time.abi3.so
    │   │   ├── _openssl.abi3.so
    │   │   ├── _padding.abi3.so
    │   │   └── openssl
    │   │       ├── __init__.py
    │   │       ├── _conditional.py
    │   │       └── binding.py
    │   └── primitives
    │       ├── __init__.py
    │       ├── asymmetric
    │       │   ├── __init__.py
    │       │   ├── dh.py
    │       │   ├── dsa.py
    │       │   ├── ec.py
    │       │   ├── padding.py
    │       │   ├── rsa.py
    │       │   ├── utils.py
    │       │   └── x25519.py
    │       ├── ciphers
    │       │   ├── __init__.py
    │       │   ├── aead.py
    │       │   ├── algorithms.py
    │       │   ├── base.py
    │       │   └── modes.py
    │       ├── cmac.py
    │       ├── constant_time.py
    │       ├── hashes.py
    │       ├── hmac.py
    │       ├── kdf
    │       │   ├── __init__.py
    │       │   ├── concatkdf.py
    │       │   ├── hkdf.py
    │       │   ├── kbkdf.py
    │       │   ├── pbkdf2.py
    │       │   ├── scrypt.py
    │       │   └── x963kdf.py
    │       ├── keywrap.py
    │       ├── mac.py
    │       ├── padding.py
    │       ├── serialization.py
    │       └── twofactor
    │           ├── __init__.py
    │           ├── hotp.py
    │           ├── totp.py
    │           └── utils.py
    ├── utils.py
    └── x509
        ├── __init__.py
        ├── base.py
        ├── certificate_transparency.py
        ├── extensions.py
        ├── general_name.py
        ├── name.py
        └── oid.py

12 directories, 71 files

This directory now contains the source code and compiled shared object files.

  • Looking at your dependencies though, the only issue I see is Chalice itself, which should not be in the dependencies. The requirements.txt is for runtime dependencies only. Chalice should be added to a requirements-dev.txt since it is only a development requirement not a runtime requirement. As you can see in the example below it injects its runtime into the bundle.

Using the most recent 1.2.2 version of Chalice:

$ mktmpenv
.
.
.
$ pip install chalice
.
.
.
$ python --version
Python 3.6.4
$ chalice --version
chalice 1.2.2
$ chalice new-project test-package
$ cd new-project
$ echo pymysql >> requirements.txt
$ echo boto3 >> requirements.txt
$ echo pyjwt==1.6.1 >> requirements.txt
$ echo requests==2.18.4 >> requirements.txt
$ echo cryptography==2.2.2  >> requirements.txt
$ cat requirements.txt
pymysql
boto3
pyjwt==1.6.1
requests==2.18.4
cryptography==2.2.2
$ chalice package out
Creating deployment package.
$ unzip -Z1 out/deployment.zip | cut -d '/' -f 1 - | uniq
_cffi_backend.cpython-36m-x86_64-linux-gnu.so
six.py
.libs_cffi_backend
asn1crypto
asn1crypto-0.24.0.dist-info
boto3
boto3-1.7.8.dist-info
botocore
botocore-1.10.8.dist-info
certifi
certifi-2018.4.16.dist-info
cffi
cffi-1.11.5.dist-info
chardet
chardet-3.0.4.dist-info
cryptography
cryptography-2.2.2.dist-info
dateutil
docutils
docutils-0.14.data
docutils-0.14.dist-info
idna
idna-2.6.dist-info
jmespath
jmespath-0.9.3.data
jmespath-0.9.3.dist-info
jwt
pycparser
pycparser-2.18.dist-info
PyJWT-1.6.1.dist-info
pymysql
PyMySQL-0.8.0.dist-info
python_dateutil-2.7.2.dist-info
requests
requests-2.18.4.dist-info
s3transfer
s3transfer-0.1.13.dist-info
six-1.11.0.dist-info
urllib3
urllib3-1.22.dist-info
chalice
app.py

No errors and it looks like all the transitive dependencies were successfully included in the bundle.

@no-response no-response bot closed this as completed May 7, 2018
@no-response
Copy link

no-response bot commented May 7, 2018

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants