Skip to content

Commit

Permalink
Merge pull request #24 from freezingsaddles/use-pyproject-for-setuptools
Browse files Browse the repository at this point in the history
Use pyproject.toml
  • Loading branch information
obscurerichard authored Dec 31, 2024
2 parents 5ca80c7 + 728be3e commit 7ab1c1b
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 48 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,5 @@ jobs:
uses: psf/[email protected]
- name: isort Lint
uses: isort/isort-action@v1
with:
requirements-files: "requirements.txt requirements-test.txt"
- name: flake8 Lint
uses: py-actions/flake8@v2
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 5 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
Expand All @@ -25,4 +21,5 @@ parts/
sdist/
src/
var/
venv/
wheels/
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()'

Check warning on line 41 in Dockerfile

View workflow job for this annotation

GitHub Actions / build / docker

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for ENTRYPOINT to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
2 changes: 1 addition & 1 deletion freezing/nq/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
75 changes: 75 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"},
{name = "Richard Bullington-McGuire", email = "[email protected]"},
]
maintainers = [
{name = "Richard Bullington-McGuire", email="[email protected]"},
]
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"
6 changes: 0 additions & 6 deletions requirements-test.txt

This file was deleted.

8 changes: 0 additions & 8 deletions requirements.txt

This file was deleted.

17 changes: 0 additions & 17 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 7ab1c1b

Please sign in to comment.