Skip to content

Commit 640f00b

Browse files
author
Leo Hemsted
committed
install celery with sqs support
you need to `pip install celery[sqs]` to get the additional dependencies that celery needs to use SQS queues - there are two libs - boto3 and pycurl. pycurl is a bunch of python handles around curl, so needs to be installed from source so it can link to your curl/ssl libs. On paas and in docker this works fine (needed to add `libcurl4-openssl-dev` to the docker container), but on macos it can't find openssl. We need to pass a couple of flags in: * set the environment variable PYCURL_SSL_LIBRARY=openssl * pass in the global options `build_ext` and `-I{openssl_headers_path}`. As shown here: pycurl/pycurl#530 (comment) Env var is no biggie, but using any install-option flags disables wheels for the whole pip install run. (See pypa/pip#2677 and pypa/pip#4118 for more context on the install-options flags). A whole bunch of our dependencies don't install nicely from source (but do from wheel), so this commit installs pycurl separately as an initial step, with the requisite flags, and then installs the rest of the requirements as before. I've updated the makefile and bootstrap.sh files to reflect this, but if you run `pip install -r requirements.txt` from scratch you will run into issues.
1 parent 6ca2b82 commit 640f00b

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ production: ## Set environment to production
6767
.PHONY: dependencies
6868
dependencies: venv ## Install build dependencies
6969
mkdir -p ${PIP_ACCEL_CACHE}
70+
. venv/bin/activate && make install-pycurl
7071
. venv/bin/activate && PIP_ACCEL_CACHE=${PIP_ACCEL_CACHE} pip-accel install -r requirements_for_test.txt
7172

7273
.PHONY: generate-version-file
@@ -97,6 +98,7 @@ test: venv generate-version-file ## Run tests
9798
freeze-requirements:
9899
rm -rf venv-freeze
99100
virtualenv -p python3 venv-freeze
101+
$(call install-pycurl, $$(pwd)/venv-freeze/bin/pip)
100102
$$(pwd)/venv-freeze/bin/pip install -r requirements-app.txt
101103
echo '# pyup: ignore file' > requirements.txt
102104
echo '# This file is autogenerated. Do not edit it manually.' >> requirements.txt
@@ -105,6 +107,15 @@ freeze-requirements:
105107
$$(pwd)/venv-freeze/bin/pip freeze -r <(sed '/^--/d' requirements-app.txt) | sed -n '/The following requirements were added by pip freeze/,$$p' >> requirements.txt
106108
rm -rf venv-freeze
107109

110+
define install-pycurl
111+
# install pycurl separately to avoid flags disabling wheels for other packages
112+
PYCURL_SSL_LIBRARY=openssl ${1} install pycurl --global-option="build_ext" --global-option="-I/usr/local/opt/openssl/include"
113+
endef
114+
115+
.PHONY: install-pycurl
116+
install-pycurl:
117+
$(call install-pycurl, pip)
118+
108119
.PHONY: test-requirements
109120
test-requirements:
110121
@diff requirements-app.txt requirements.txt | grep '<' \

docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ RUN \
2222
libffi-dev \
2323
python-dev \
2424
jq \
25+
libcurl4-openssl-dev \
2526
&& echo "Clean up" \
2627
&& rm -rf /var/lib/apt/lists/* /tmp/*
2728

requirements-app.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# with package version changes made in requirements-app.txt
33

44
cffi==1.11.5
5-
celery==4.2.1
5+
celery[sqs]==4.2.1
66
docopt==0.6.2
77
Flask-Bcrypt==0.7.1
88
flask-marshmallow==0.9.0

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# with package version changes made in requirements-app.txt
55

66
cffi==1.11.5
7-
celery==4.2.1
7+
celery[sqs]==4.2.1
88
docopt==0.6.2
99
Flask-Bcrypt==0.7.1
1010
flask-marshmallow==0.9.0
@@ -37,7 +37,7 @@ amqp==2.3.2
3737
bcrypt==3.1.4
3838
billiard==3.5.0.4
3939
bleach==2.1.3
40-
boto3==1.6.16
40+
boto3==1.9.16
4141
certifi==2018.8.24
4242
chardet==3.0.4
4343
Click==7.0
@@ -60,6 +60,7 @@ orderedset==2.0.1
6060
phonenumbers==8.9.4
6161
pyasn1==0.4.4
6262
pycparser==2.19
63+
pycurl==7.43.0.2
6364
PyPDF2==1.26.0
6465
python-dateutil==2.7.3
6566
python-editor==1.0.3

scripts/bootstrap.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ fi
2828
# we need the version file to exist otherwise the app will blow up
2929
make generate-version-file
3030

31+
make install-pycurl
3132
# Install Python development dependencies
3233
pip3 install -r requirements_for_test.txt
3334

0 commit comments

Comments
 (0)