Currently, the version of aws-requests-auth published on PyPI is a source tarball, but this poses issues if you're building a lambda that has binary dependencies, such as, say PyYAML or the cryptography library.
To give you an example, say you do your development of a Mac or Windows box: you might install all your libraries into a directory to be zipped up like so:
The use of --only-binary :all: is unfortunately required if you're also using --platform to guarantee that any binary dependencies downloaded are for the correct target platform. Unfortunately, this means that pip won't bother downloading source tarballs if that's all that's available. Instead, you get an error like the following:
ERROR: Could not find a version that satisfies the requirement aws-requests-auth (from -r ../requirements.txt (line 1)) (from versions: none)
ERROR: No matching distribution found for aws-requests-auth (from -r ../requirements.txt (line 1))
The likes of requests, boto3, &c., don't have this particular issue because they're packaged as wheels.
The additional flags are unavoidable, unfortunately, and there seems to be no way to tell pip that source distributions are OK as a fallback.
The fix is simple enough. Add this to setup.cfg:
[bdist_wheel]
universal = 1
That will mean the wheel will work with both Python 2 and Python 3 and indicates that the wheel will also work on any platform. Also, in setup.py, replace from distutils.core import setup with from setuptools import setup. This also fixes a bug as distutils doesn't actually support the install_requires distribution option, so it means the dependency on requests will now work properly.
Finally, rather than just doing python3 setup.py sdist bdist_wheel, ensure the wheel package is installed and do python3 setup.py sdist bdist_wheel instead.
You should end up with something like this:
$ ls dist
aws-requests-auth-0.4.2.tar.gz
aws_requests_auth-0.4.2-py2.py3-none-any.whl
Currently, the version of aws-requests-auth published on PyPI is a source tarball, but this poses issues if you're building a lambda that has binary dependencies, such as, say PyYAML or the cryptography library.
To give you an example, say you do your development of a Mac or Windows box: you might install all your libraries into a directory to be zipped up like so:
The use of
--only-binary :all:
is unfortunately required if you're also using--platform
to guarantee that any binary dependencies downloaded are for the correct target platform. Unfortunately, this means that pip won't bother downloading source tarballs if that's all that's available. Instead, you get an error like the following:The likes of requests, boto3, &c., don't have this particular issue because they're packaged as wheels.
The additional flags are unavoidable, unfortunately, and there seems to be no way to tell pip that source distributions are OK as a fallback.
The fix is simple enough. Add this to
setup.cfg
:That will mean the wheel will work with both Python 2 and Python 3 and indicates that the wheel will also work on any platform. Also, in
setup.py
, replacefrom distutils.core import setup
withfrom setuptools import setup
. This also fixes a bug as distutils doesn't actually support theinstall_requires
distribution option, so it means the dependency on requests will now work properly.Finally, rather than just doing
python3 setup.py sdist bdist_wheel
, ensure thewheel
package is installed and dopython3 setup.py sdist bdist_wheel
instead.You should end up with something like this: