genesluder / python-apns

A library for interacting with APNs using HTTP/2 and token-based authentication.
MIT License
90 stars 50 forks source link

Cannot import #1

Closed mikkelam closed 7 years ago

mikkelam commented 7 years ago

I believe there is an issue with not being able to import this when pip installed, maybe because the name contains '.'

Obeyed commented 7 years ago

It is possible to import modules with a dot in the name (http://stackoverflow.com/a/1828249/3169491), but it does not seem as a very good solution. I think it would be better to rename the module :sweat_smile:

genesluder commented 7 years ago

This was actually due to an issue with the packing of the module, assuming you were using Python 2.x. There's a new version up on PyPI that should work.

There are a ton of modules out there named apns and using a namespace and keeping the module name descriptive seems clearer than coming up with a random module name :)

Obeyed commented 7 years ago

Cool, btw could you remove the cryptography library. It is not used anywhere, and it can't be installed with pip3 :) thanks!

genesluder commented 7 years ago

Even though its not used directly, PyJWT requires it to generate the auth token (Apple's requirement is an ECDSA algorithm) : https://pyjwt.readthedocs.io/en/latest/installation.html#cryptographic-dependencies-optional

You'll get a NotImplementedError if you try to send a push without cryptography installed.

I remember having issues getting cryptography installed with pip3 on my Mac, but I eventually got it working. (If you happen to be on a Mac- I believe I ended up having to install OpenSSL via homebrew.)

Obeyed commented 7 years ago

Ah, I see. That's great man. Thanks. So, I had to install build-essential, libssl-dev, andlibffi-devbefore it worked. This is also explained in https://cryptography.io/en/latest/installation/#building-cryptography-on-linux .