From fd4016e51c776920b8ee889133157d78a2384690 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Sun, 19 Jan 2020 22:03:25 -0500 Subject: [PATCH 1/8] Update requirements, make sure this can build --- Dockerfile | 6 +++--- README.md | 9 +++++++++ requirements-test.txt | 3 +++ requirements.txt | 12 ++++++------ setup.py | 9 +++++++-- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index a6e6ad8..f96887d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,13 @@ # ===== FROM ubuntu:xenial as buildstep -LABEL maintainer="Hans Lellelid " +LABEL maintainer="Richard Bullington-McGuire " COPY resources/docker/sources.list /etc/apt/sources.list RUN apt-get update RUN apt-get install -y software-properties-common -RUN add-apt-repository -y ppa:jonathonf/python-3.6 +RUN add-apt-repository -y ppa:deadsnakes/ppa RUN apt-get update RUN apt-get install -y python3.6 python3.6-dev curl build-essential git @@ -31,7 +31,7 @@ RUN python3.6 setup.py bdist_wheel -d /build/wheels # ===== FROM ubuntu:xenial as deploystep -LABEL maintainer="Hans Lellelid " +LABEL maintainer="Richard Bullington-McGuire " COPY resources/docker/sources.list /etc/apt/sources.list diff --git a/README.md b/README.md index a850862..2be6188 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,12 @@ It is designed to run as a container and should be configured with environment v - `BEANSTALKD_HOST`: The hostname (probably a container link) to a beanstalkd server. - `BEANSTALKD_PORT`: The port for beanstalkd server (default 11300) - `STRAVA_VERIFY_TOKEN`: The token to use when verifying the Strava challenge response (must match token used to register subscription). + +# Legal + +This software is a community-driven effort, and as such the contributions are owned by the individual contributors: + +Copyright 2018 Hans Lillelid
+Copyright 2020 Richard Bullington-McGuire
+ +This software is licensed under the [Apache 2.0 license](LICENSE). diff --git a/requirements-test.txt b/requirements-test.txt index c503b66..3b5e2ba 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,2 +1,5 @@ +black==19.10b0 +flake8==3.7.9 +pur==5.3.0 pytest==3.3.2 pytest-mock==1.6.3 diff --git a/requirements.txt b/requirements.txt index 92d66a4..3336231 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ envparse==0.2.0 -falcon==1.3.0 -greenstalk==0.5.0 -gunicorn==19.7.1 +falcon==2.0.0 +greenstalk==1.0.1 +gunicorn==20.0.4 python-mimeparse==1.6.0 -six==1.11.0 --e git+https://github.com/freezingsaddles/freezing-model@0.2.2#egg=freezing-model-0.2.2 -arrow==0.12.1 +six==1.14.0 +-e git+https://github.com/freezingsaddles/freezing-model@0.5.2#egg=freezing-model +arrow==0.15.5 diff --git a/setup.py b/setup.py index 04ad753..995e2d2 100644 --- a/setup.py +++ b/setup.py @@ -3,10 +3,15 @@ import re import warnings -from pip.req import parse_requirements +# Ugh, pip 10 is backward incompatible, but there is a workaround: +# Thanks Stack Overflow https://stackoverflow.com/a/49867265 +try: # for pip >= 10 + from pip._internal.req import parse_requirements +except ImportError: # for pip <= 9.0.3 + from pip.req import parse_requirements from setuptools import setup, find_packages -version = '0.1.0' +version = '0.2.0' long_description = """ freezing-nq is the freezing saddles component for receiving strava webhook events and enquing them for processing. From a878c73f83bd1898d284e6b953e7b2493a693fbe Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Tue, 2 Jan 2024 00:03:57 -0500 Subject: [PATCH 2/8] Get this building with Ubuntu 22.04 Python 3.10 compatibility --- Dockerfile | 17 ++++------- requirements.txt | 4 +-- resources/docker/sources.list | 5 ---- setup.py | 55 +++++++++++++++++------------------ 4 files changed, 34 insertions(+), 47 deletions(-) delete mode 100644 resources/docker/sources.list diff --git a/Dockerfile b/Dockerfile index f96887d..563b50b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,17 @@ # BUILD # ===== -FROM ubuntu:xenial as buildstep +FROM ubuntu:22.04 as buildstep LABEL maintainer="Richard Bullington-McGuire " -COPY resources/docker/sources.list /etc/apt/sources.list RUN apt-get update RUN apt-get install -y software-properties-common -RUN add-apt-repository -y ppa:deadsnakes/ppa RUN apt-get update -RUN apt-get install -y python3.6 python3.6-dev curl build-essential git +RUN apt-get install -y python3 python3-dev python3-pip curl build-essential git RUN mkdir -p /build/wheels -RUN curl https://bootstrap.pypa.io/get-pip.py | python3.6 RUN pip3 install --upgrade pip setuptools wheel @@ -24,24 +21,20 @@ RUN pip3 wheel -r /tmp/requirements.txt --wheel-dir=/build/wheels ADD . /app WORKDIR /app -RUN python3.6 setup.py bdist_wheel -d /build/wheels +RUN python3 setup.py bdist_wheel -d /build/wheels # DEPLOY # ===== -FROM ubuntu:xenial as deploystep +FROM ubuntu:22.04 as deploystep LABEL maintainer="Richard Bullington-McGuire " -COPY resources/docker/sources.list /etc/apt/sources.list - RUN apt-get update \ && apt-get install -y software-properties-common curl \ - && add-apt-repository -y ppa:jonathonf/python-3.6 \ && apt-get update \ - && apt-get install -y python3.6 vim-tiny --no-install-recommends \ + && apt-get install -y python3 python3-pip vim-tiny --no-install-recommends \ && apt-get clean \ - && curl https://bootstrap.pypa.io/get-pip.py | python3.6 \ && pip3 install --upgrade pip setuptools wheel \ && rm -rf /var/lib/apt/lists/* diff --git a/requirements.txt b/requirements.txt index 3336231..5533e5c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ +arrow==0.15.5 envparse==0.2.0 falcon==2.0.0 +freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.7.10.tar.gz greenstalk==1.0.1 gunicorn==20.0.4 python-mimeparse==1.6.0 six==1.14.0 --e git+https://github.com/freezingsaddles/freezing-model@0.5.2#egg=freezing-model -arrow==0.15.5 diff --git a/resources/docker/sources.list b/resources/docker/sources.list deleted file mode 100644 index 86f4b5d..0000000 --- a/resources/docker/sources.list +++ /dev/null @@ -1,5 +0,0 @@ -deb http://archive.ubuntu.com/ubuntu/ xenial main universe -deb http://archive.ubuntu.com/ubuntu/ xenial-updates main universe - -deb http://security.ubuntu.com/ubuntu xenial-security main -deb http://security.ubuntu.com/ubuntu xenial-security universe diff --git a/setup.py b/setup.py index 995e2d2..f639ba0 100644 --- a/setup.py +++ b/setup.py @@ -3,43 +3,42 @@ import re import warnings -# Ugh, pip 10 is backward incompatible, but there is a workaround: -# Thanks Stack Overflow https://stackoverflow.com/a/49867265 -try: # for pip >= 10 - from pip._internal.req import parse_requirements -except ImportError: # for pip <= 9.0.3 - from pip.req import parse_requirements -from setuptools import setup, find_packages +from setuptools import setup -version = '0.2.0' +version = "0.3.0" long_description = """ -freezing-nq is the freezing saddles component for receiving strava webhook events and enquing them for processing. +freezing-nq is the Freezing Saddles component for receiving +strava webhook events and enquing them for processing. """ -# parse_requirements() returns generator of pip.req.InstallRequirement objects -install_reqs = parse_requirements(os.path.join(os.path.dirname(__file__), 'requirements.txt'), session=False) - -# reqs is a list of requirement -# e.g. ['django==1.5.1', 'mezzanine==1.4.6'] -reqs = [str(ir.req) for ir in install_reqs] +install_reqs = [ + "envparse==0.2.0", + "falcon==2.0.0", + "greenstalk==1.0.1", + "gunicorn==20.0.4", + "python-mimeparse==1.6.0", + "six==1.14.0", + "freezing-model", + "arrow==0.15.5", +] setup( - name='freezing-nq', + name="freezing-nq", version=version, - author='Hans Lellelid', - author_email='hans@xmpl.org', - url='http://github.com/freezingsaddles/freezing-nq', - license='Apache', - description='Freezing Saddles activity receive and enqueue worker', + author="Hans Lellelid", + author_email="hans@xmpl.org", + url="http://github.com/freezingsaddles/freezing-nq", + license="Apache", + description="Freezing Saddles activity receive and enqueue worker", long_description=long_description, - packages=['freezing.nq', 'freezing.nq.api'], - install_requires=reqs, + packages=["freezing.nq", "freezing.nq.api"], + install_requires=install_reqs, classifiers=[ - 'Development Status :: 4 - Beta', - 'License :: OSI Approved :: Apache Software License', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3', + "Development Status :: 4 - Beta", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", ], - zip_safe=True + zip_safe=True, ) From 8af737ea3ca0956dbcbfba7bcd2ef9aa0374448e Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Sun, 7 Jan 2024 20:33:21 -0500 Subject: [PATCH 3/8] Optimize build, deps, bump tag for release --- Dockerfile | 23 +++++++---------------- requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 563b50b..850a2e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,15 @@ # BUILD # ===== - FROM ubuntu:22.04 as buildstep LABEL maintainer="Richard Bullington-McGuire " -RUN apt-get update - -RUN apt-get install -y software-properties-common -RUN apt-get update - -RUN apt-get install -y python3 python3-dev python3-pip curl build-essential git +RUN apt-get update \ + && apt-get install -y software-properties-common \ + && apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-dev python3-pip curl build-essential git tzdata RUN mkdir -p /build/wheels - RUN pip3 install --upgrade pip setuptools wheel - ADD requirements.txt /tmp/requirements.txt RUN pip3 wheel -r /tmp/requirements.txt --wheel-dir=/build/wheels @@ -23,25 +18,21 @@ WORKDIR /app RUN python3 setup.py bdist_wheel -d /build/wheels - # DEPLOY # ===== - FROM ubuntu:22.04 as deploystep LABEL maintainer="Richard Bullington-McGuire " RUN apt-get update \ - && apt-get install -y software-properties-common curl \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-common curl tzdata \ && apt-get update \ - && apt-get install -y python3 python3-pip vim-tiny --no-install-recommends \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip --no-install-recommends \ && apt-get clean \ - && pip3 install --upgrade pip setuptools wheel \ && rm -rf /var/lib/apt/lists/* +RUN pip3 install --upgrade pip setuptools wheel COPY --from=buildstep /build/wheels /tmp/wheels - RUN pip3 install /tmp/wheels/* EXPOSE 8000 - ENTRYPOINT gunicorn --bind 0.0.0.0:8000 'freezing.nq.app:make_app()' diff --git a/requirements.txt b/requirements.txt index 5533e5c..b4b7cf3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ arrow==0.15.5 envparse==0.2.0 falcon==2.0.0 -freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.7.10.tar.gz +freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.7.17.tar.gz greenstalk==1.0.1 gunicorn==20.0.4 python-mimeparse==1.6.0 diff --git a/setup.py b/setup.py index f639ba0..fbebae9 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup -version = "0.3.0" +version = "0.3.1" long_description = """ freezing-nq is the Freezing Saddles component for receiving From 1edc1e588a60cfebc22afd37d1f94905940521d4 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Sun, 7 Jan 2024 20:49:08 -0500 Subject: [PATCH 4/8] Use version of freezing model with SQLALCHEMY_URL optional --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b4b7cf3..31862e4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ arrow==0.15.5 envparse==0.2.0 falcon==2.0.0 -freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.7.17.tar.gz +freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.7.18.tar.gz greenstalk==1.0.1 gunicorn==20.0.4 python-mimeparse==1.6.0 From 0246b0046c755924348985b6975ec9de6ca80d5d Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Sun, 7 Jan 2024 22:00:17 -0500 Subject: [PATCH 5/8] Include custom GeoAlchemy --- requirements.txt | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 31862e4..4d9b7b4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +GeoAlchemy @ https://github.com/hozn/GeoAlchemy/archive/0.7.3dev1.tar.gz arrow==0.15.5 envparse==0.2.0 falcon==2.0.0 diff --git a/setup.py b/setup.py index fbebae9..3418bbd 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup -version = "0.3.1" +version = "0.3.2" long_description = """ freezing-nq is the Freezing Saddles component for receiving From 20cf1e5b7204945b3232964224ab78b836b2e71c Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Sun, 7 Jan 2024 23:02:53 -0500 Subject: [PATCH 6/8] Bump versions --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4d9b7b4..4dee61f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ GeoAlchemy @ https://github.com/hozn/GeoAlchemy/archive/0.7.3dev1.tar.gz arrow==0.15.5 envparse==0.2.0 falcon==2.0.0 -freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.7.18.tar.gz +freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.7.19.tar.gz greenstalk==1.0.1 gunicorn==20.0.4 python-mimeparse==1.6.0 diff --git a/setup.py b/setup.py index 3418bbd..a6a9353 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup -version = "0.3.2" +version = "0.3.3" long_description = """ freezing-nq is the Freezing Saddles component for receiving From 48f8a618d292018fd276f60a4a29ce36f0271dce Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Sun, 7 Jan 2024 23:17:17 -0500 Subject: [PATCH 7/8] Ditch strict param in model init --- freezing/nq/api/webhook.py | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/freezing/nq/api/webhook.py b/freezing/nq/api/webhook.py index 5f5c4e1..1e9dc0a 100644 --- a/freezing/nq/api/webhook.py +++ b/freezing/nq/api/webhook.py @@ -24,7 +24,7 @@ def on_get(self, req: falcon.Request, resp: falcon.Response): strava_request = {k: req.get_param(k) for k in ('hub.challenge', 'hub.mode', 'hub.verify_token')} - schema = SubscriptionCallbackSchema(strict=True) + schema = SubscriptionCallbackSchema() callback: SubscriptionCallback = schema.load(strava_request).data assert config.STRAVA_VERIFY_TOKEN == callback.hub_verify_token @@ -49,7 +49,7 @@ def on_post(self, req: falcon.Request, resp: falcon.Response): See: http://strava.github.io/api/partner/v3/events/ """ - schema = SubscriptionUpdateSchema(strict=True) + schema = SubscriptionUpdateSchema() result: SubscriptionUpdate = schema.load(req.media).data # We only care about activities diff --git a/setup.py b/setup.py index a6a9353..26c5377 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup -version = "0.3.3" +version = "0.3.4" long_description = """ freezing-nq is the Freezing Saddles component for receiving From e23a1e128b4cb970a9ffb3e921ea0432c8008c7c Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Sun, 7 Jan 2024 23:36:01 -0500 Subject: [PATCH 8/8] Seat of pants marshmallow updates --- freezing/nq/api/webhook.py | 4 ++-- requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/freezing/nq/api/webhook.py b/freezing/nq/api/webhook.py index 1e9dc0a..cdf9f64 100644 --- a/freezing/nq/api/webhook.py +++ b/freezing/nq/api/webhook.py @@ -50,7 +50,7 @@ def on_post(self, req: falcon.Request, resp: falcon.Response): """ schema = SubscriptionUpdateSchema() - result: SubscriptionUpdate = schema.load(req.media).data + result: SubscriptionUpdate = schema.load(req.media) # We only care about activities if result.object_type is not ObjectType.activity: @@ -63,7 +63,7 @@ def on_post(self, req: falcon.Request, resp: falcon.Response): message.operation = result.aspect_type message.updates = result.updates - json_data = ActivityUpdateSchema().dump(message).data + json_data = ActivityUpdateSchema().dump(message) log.info("Publishing activity-update: {}".format(message)) self.publisher.publish_message(json_data, diff --git a/requirements.txt b/requirements.txt index 4dee61f..b006e02 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ GeoAlchemy @ https://github.com/hozn/GeoAlchemy/archive/0.7.3dev1.tar.gz arrow==0.15.5 envparse==0.2.0 falcon==2.0.0 -freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.7.19.tar.gz +freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.7.20.tar.gz greenstalk==1.0.1 gunicorn==20.0.4 python-mimeparse==1.6.0 diff --git a/setup.py b/setup.py index 26c5377..478301a 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup -version = "0.3.4" +version = "0.3.6" long_description = """ freezing-nq is the Freezing Saddles component for receiving