diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 51398ac..460442d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,7 +19,5 @@ jobs: uses: psf/black@24.1.1 - name: isort Lint uses: isort/isort-action@v1 - with: - requirements-files: "requirements.txt requirements-test.txt" - name: flake8 Lint uses: py-actions/flake8@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f5e6af0..fa5f420 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,8 +16,6 @@ jobs: python-version: "3.10" - name: Install requirements run: | - pip install -r requirements.txt - pip install -r requirements-test.txt - pip install . + pip install --use-deprecated=legacy-resolver . '.[dev]' - name: Run pytest run: pytest diff --git a/.gitignore b/.gitignore index e8f4fec..5d3285f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,14 @@ -# Byte-compiled / optimized / DLL files *$py.class -*.py[cod] -__pycache__/ - -# C extensions -*.so - -# Distribution / packaging *.egg *.egg-info/ +*.py[cod] +*.so .Python .eggs/ .installed.cfg .venv +.venv/ +__pycache__/ build/ develop-eggs/ dist/ @@ -25,4 +21,5 @@ parts/ sdist/ src/ var/ +venv/ wheels/ diff --git a/Dockerfile b/Dockerfile index 850a2e6..23ad864 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,9 @@ RUN apt-get update \ 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 +ADD pyproject.toml /tmp +WORKDIR /tmp +RUN pip3 wheel --wheel-dir=/build/wheels . ADD . /app WORKDIR /app @@ -32,7 +33,9 @@ RUN apt-get update \ RUN pip3 install --upgrade pip setuptools wheel COPY --from=buildstep /build/wheels /tmp/wheels -RUN pip3 install /tmp/wheels/* +# Thanks https://stackoverflow.com/a/74634740/424301 for the tip on +# using --use-deprecated=legacy-resolver +RUN pip3 install --use-deprecated=legacy-resolver /tmp/wheels/* EXPOSE 8000 ENTRYPOINT gunicorn --bind 0.0.0.0:8000 'freezing.nq.app:make_app()' diff --git a/freezing/nq/publish.py b/freezing/nq/publish.py index e4cd5a3..2d74932 100644 --- a/freezing/nq/publish.py +++ b/freezing/nq/publish.py @@ -31,7 +31,7 @@ def publish_message(self, message: Any, dest: DefinedTubes): :param message: A message object that can be serialized with json.dumps() """ - queue = greenstalk.Client(host=self.host, port=self.port, use=dest.value) + queue = greenstalk.Client((self.host, self.port), use=dest.value) try: queue.put(self.serialize_message(message)) except Exception as ex: diff --git a/pyproject.toml b/pyproject.toml index 5d7bf33..e5f30e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,77 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "freezing-nq" +version = "0.4.3" +description = "Freezing Saddles activity receive and enqueue worker" +readme = "README.md" +authors = [ + {name = "Hans Lellelid", email = "hans@xmpl.org"}, + {name = "Richard Bullington-McGuire", email = "richard.bullington.mcguire@gmail.com"}, +] +maintainers = [ + {name = "Richard Bullington-McGuire", email="richard.bullington.mcguire@gmail.com"}, +] +license = {text = "Apache License (2.0)"} +dependencies = [ + "arrow==1.3.0", + "envparse==0.2.0", + "falcon==4.0.2", + "freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.11.2.tar.gz", + "greenstalk==2.0.2", + "gunicorn==22.0.0", + "python-mimeparse==1.6.0", + "six==1.16.0", +] +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: Apache Software License", + "Topic :: Games", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.10", + "Natural Language :: English", +] + +[project.optional-dependencies] +dev = [ + "bandit", + "black", + "fawltydeps", + "flake8", + "flake8-pyproject", + "flake8-bugbear", + "flake8-builtins", + "flake8-comprehensions", + "flake8-docstrings", + "flake8-eradicate", + "flake8-print", + "flake8-return", + "flake8-simplify", + "flake8-sorted-keys", + "flake8-todo", + "flake8-raise", + "isort", + "mypy", + "pytest", + "pytest-mock", +] + [tool.isort] profile = "black" + +[tool.flake8] +# Thanks https://www.reddit.com/r/learnpython/comments/rr6y69/comment/hqeqt68/?utm_source=share&utm_medium=web2x&context=3 +ignore = [ + "E203", + "E501", + "W503", + "W503", +] +max-line-length = 88 +max-complexity = 39 +extend-ignore = "E203" +inline-quotes = "double" diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index e290ffd..0000000 --- a/requirements-test.txt +++ /dev/null @@ -1,6 +0,0 @@ -black==24.3.0 -flake8==7.0.0 -isort==5.13.2 -pur==7.3.1 -pytest==8.3.3 -pytest-mock==1.6.3 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index b6b4df3..0000000 --- a/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -arrow==0.15.5 -envparse==0.2.0 -falcon==4.0.2 -freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.10.3.tar.gz -greenstalk==1.0.1 -gunicorn==22.0.0 -python-mimeparse==1.6.0 -six==1.16.0 diff --git a/tests/test_api.py b/tests/test_api.py index ed2b0ab..6a70e45 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -61,20 +61,3 @@ def test_post_webhook(client, publisher: ActivityPublisher): publisher.publish_message.assert_called_with( called_with, dest=DefinedTubes.activity_update ) - - -# def test_post_webhook_noop(client, publisher:ActivityPublisher): -# -# d = dict( -# subscription_id=111, -# owner_id=222, -# object_type='activity', -# object_id=999, -# aspect_type='update', -# updates={}, -# event_time=1358919359, -# ) -# -# client.simulate_post('/webhook', body=json.dumps(d), headers={'content-type': 'application/json'}) -# -# publisher.publish_message.assert_not_called()