Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump utils to 91.1.0 #169

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ wheels/
*.egg-info/
.installed.cfg
*.egg
pyproject.toml

## A placeholder version of this file is still committed to avoid having to generate it for local
## development. The committed file will get overwritten as part of building the Docker image.
Expand Down
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This file was automatically copied from [email protected]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
Expand All @@ -7,12 +9,12 @@ repos:
- id: check-yaml
- id: debug-statements
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.3.7'
rev: 'v0.8.2'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 24.4.0
rev: 24.10.0
hooks:
- id: black
name: black (python)
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ generate-version-file:

.PHONY: bootstrap
bootstrap: generate-version-file
pip install -r requirements_for_test.txt
python -c "from notifications_utils.version_tools import copy_pyproject_toml; copy_pyproject_toml()"
uv pip install -r requirements_for_test.txt

.PHONY: freeze-requirements
freeze-requirements: ## create static requirements.txt
pip install --upgrade pip-tools
pip-compile requirements.in
uv pip compile requirements.in -o requirements.txt
python -c "from notifications_utils.version_tools import copy_config; copy_config()"
uv pip compile requirements_for_test.in -o requirements_for_test.txt

.PHONY: bump-utils
bump-utils: # Bump notifications-utils package to latest version
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ Because the container caches things like Python packages, you will need to run t

To run the app you will need appropriate AWS credentials. See the [Wiki](https://github.com/alphagov/notifications-manuals/wiki/aws-accounts#set-up-local-development) for more details.

### uv

We use [uv](https://github.com/astral-sh/uv) for Python dependency management. Follow the [install instructions](https://github.com/astral-sh/uv?tab=readme-ov-file#installation) or run:

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

### `environment.sh`

In the root directory of the application, run:
Expand Down
2 changes: 1 addition & 1 deletion app/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def list_routes():
"""List URLs of all application routes."""
for rule in sorted(current_app.url_map.iter_rules(), key=lambda r: r.rule):
print("{:10} {}".format(", ".join(rule.methods - set(["OPTIONS", "HEAD"])), rule.rule))
print("{:10} {}".format(", ".join(rule.methods - {"OPTIONS", "HEAD"}), rule.rule))


def setup_commands(application):
Expand Down
4 changes: 2 additions & 2 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from kombu import Exchange, Queue


class QueueNames(object):
class QueueNames:
LETTERS = "letter-tasks"
ANTIVIRUS = "antivirus-tasks"


class Config(object):
class Config:
STATSD_ENABLED = True
STATSD_HOST = os.getenv("STATSD_HOST")
STATSD_PORT = 8125
Expand Down
10 changes: 8 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FROM python:3.11-slim-bookworm as base
ENV CLAMAV_MIRROR_URL https://s3.eu-west-1.amazonaws.com/notifications.service.gov.uk-clamav-database-mirror/clam
ENV PYTHONUNBUFFERED=1
ENV DEBIAN_FRONTEND=noninteractive
ENV UV_CACHE_DIR='/tmp/uv-cache/'
ENV UV_COMPILE_BYTECODE=1


# Use clamav database from private mirror. Disable with: --build-arg CLAMAV_USE_MIRROR=false for local builds
ARG CLAMAV_USE_MIRROR=true
Expand Down Expand Up @@ -52,9 +55,11 @@ RUN echo "Install OS dependencies for python app requirements" && \

COPY requirements.txt .

RUN pip install uv

RUN echo "Installing python requirements" && \
python3 -m venv /opt/venv && \
/opt/venv/bin/pip install -r requirements.txt
uv pip sync --python /opt/venv/bin/python requirements.txt

COPY . .
RUN make generate-version-file # This file gets copied across
Expand Down Expand Up @@ -100,7 +105,8 @@ USER notify
RUN mkdir -p app

# Install dev/test requirements
COPY --chown=notify:notify requirements.txt requirements_for_test.txt ./
RUN pip install uv
COPY --chown=notify:notify requirements_for_test.txt ./
RUN make bootstrap

COPY --chown=notify:notify . .
36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This file was automatically copied from [email protected]

[tool.black]
line-length = 120

[tool.ruff]
line-length = 120

target-version = "py311"

lint.select = [
"E", # pycodestyle
"W", # pycodestyle
"F", # pyflakes
"I", # isort
"B", # flake8-bugbear
"C90", # mccabe cyclomatic complexity
"G", # flake8-logging-format
"T20", # flake8-print
"UP", # pyupgrade
"C4", # flake8-comprehensions
"ISC", # flake8-implicit-str-concat
"RSE", # flake8-raise
"PIE", # flake8-pie
]
lint.ignore = []
exclude = [
"migrations/versions/",
"venv*",
"__pycache__",
"node_modules",
"cache",
"migrations",
"build",
"sample_cap_xml_documents.py",
]
4 changes: 1 addition & 3 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
clamd==1.0.2
Flask==2.3.2
celery[sqs]==5.2.6
Flask-HTTPAuth==4.8.0
gunicorn==20.1.0

# Run `make bump-utils` to update to the latest version
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@77.1.1
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@91.1.0

# gds-metrics requires prometheseus 0.2.0, override that requirement as later versions bring significant performance gains
prometheus-client==0.15.0
Expand Down
58 changes: 29 additions & 29 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile requirements.in
#
# This file was autogenerated by uv via the following command:
# uv pip compile requirements.in -o requirements.txt
amqp==5.0.9
# via kombu
async-timeout==4.0.2
# via redis
awscrt==0.20.11
# via botocore
billiard==3.6.4.0
# via celery
blinker==1.6.2
# via
# flask
# gds-metrics
# sentry-sdk
boto3==1.28.7
boto3==1.34.150
# via
# kombu
# notifications-utils
botocore==1.31.7
botocore==1.34.150
# via
# boto3
# s3transfer
cachetools==4.2.4
cachetools==5.4.0
# via notifications-utils
celery[sqs]==5.2.6
celery==5.2.6
# via
# -r requirements.in
# sentry-sdk
Expand All @@ -50,9 +48,12 @@ click-plugins==1.1.1
# via celery
click-repl==0.2.0
# via celery
flask==2.3.2
dnspython==2.6.1
# via eventlet
eventlet==0.36.1
# via gunicorn
flask==3.0.3
# via
# -r requirements.in
# flask-httpauth
# flask-redis
# gds-metrics
Expand All @@ -64,39 +65,39 @@ flask-redis==0.4.0
# via notifications-utils
gds-metrics @ git+https://github.com/alphagov/gds_metrics_python.git@6f1840a57b6fb1ee40b7e84f2f18ec229de8aa72
# via -r requirements.in
govuk-bank-holidays==0.10
govuk-bank-holidays==0.14
# via notifications-utils
greenlet==3.0.3
# via eventlet
gunicorn==20.1.0
# via
# -r requirements.in
# notifications-utils
# via notifications-utils
idna==3.3
# via requests
itsdangerous==2.1.2
# via
# flask
# notifications-utils
jinja2==3.1.3
jinja2==3.1.4
# via
# flask
# notifications-utils
jmespath==0.10.0
# via
# boto3
# botocore
kombu[sqs]==5.2.3
kombu==5.2.3
# via celery
markupsafe==2.1.2
# via
# jinja2
# werkzeug
mistune==0.8.4
# via notifications-utils
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@77.1.1
notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@d4d07fd31dc65cbcfba3850cea3b05ee8d3e2e62
# via -r requirements.in
ordered-set==4.1.0
# via notifications-utils
phonenumbers==8.13.26
phonenumbers==8.13.50
# via notifications-utils
prometheus-client==0.15.0
# via
Expand All @@ -110,9 +111,9 @@ pypdf==3.17.1
# via notifications-utils
python-dateutil==2.8.2
# via botocore
python-json-logger==2.0.2
python-json-logger==2.0.7
# via notifications-utils
pytz==2021.3
pytz==2024.1
# via
# celery
# notifications-utils
Expand All @@ -124,19 +125,21 @@ requests==2.32.2
# via
# govuk-bank-holidays
# notifications-utils
s3transfer==0.6.1
s3transfer==0.10.2
# via boto3
segno==1.6.0
# via notifications-utils
sentry-sdk[celery,flask]==1.21.1
sentry-sdk==1.21.1
# via -r requirements.in
setuptools==75.6.0
# via gunicorn
six==1.16.0
# via
# click-repl
# python-dateutil
smartypants==2.0.1
# via notifications-utils
statsd==3.3.0
statsd==4.0.1
# via notifications-utils
urllib3==1.26.19
# via
Expand All @@ -151,8 +154,5 @@ vine==5.0.0
# kombu
wcwidth==0.2.5
# via prompt-toolkit
werkzeug==2.3.3
werkzeug==3.0.3
# via flask

# The following packages are considered to be unsafe in a requirements file:
# setuptools
4 changes: 4 additions & 0 deletions requirements_for_test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-r requirements.in
-r requirements_for_test_common.in

jinja2-cli[yaml]==0.8.2
Loading