Skip to content

Commit

Permalink
Change to "uv"
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxWinterstein committed Nov 25, 2024
1 parent 102c929 commit b2ed88e
Show file tree
Hide file tree
Showing 16 changed files with 879 additions and 234 deletions.
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
uv sync --all-extras --inexact
. .venv/bin/activate
32 changes: 16 additions & 16 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -r requirements.txt
pip install -e .
- name: Test with pytest
run: |
pytest
# Install a specific version of uv.
version: "0.5.4"

- name: Set up Python
run: uv python install

- name: Install the project
run: uv sync --all-extras --dev

- name: Run tests
# For example, using `pytest`
run: uv run pytest .
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,3 @@ dmypy.json

# Cython debug symbols
cython_debug/

29 changes: 14 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@
# skip: [system]

repos:
- repo: https://github.com/psf/black
rev: 24.10.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
hooks:
- id: black
language_version: python3
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/pycqa/isort
rev: 5.13.2
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.6.3"
hooks:
- id: isort
- id: ruff
args: [--exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
rev: "v3.0.3"
hooks:
- id: prettier
args: ["--ignore-path=.prettierignore"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-toml
- id: check-json
34 changes: 23 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
# inspired by https://medium.com/@harpalsahota/dockerizing-python-poetry-applications-1aa3acb76287
FROM python:3.9
FROM python:3.12

RUN mkdir /app /data
# renovate: datasource=github-releases depName=uv packageName=astral-sh/uv
ENV UV_VERSION="0.5.3"
RUN pip install uv==$UV_VERSION

# Change the working directory to the `app` directory
WORKDIR /app

ENV PYTHONPATH=${PYTHONPATH}:${PWD}
ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1
RUN pip install cryptography==3.3.2
# Copy the lockfile and `pyproject.toml` into the image
ADD uv.lock /app/uv.lock
ADD pyproject.toml /app/pyproject.toml

# Install dependencies
RUN uv sync --frozen --no-install-project --no-dev

# Copy the project into the image
ADD . /app

# Sync the project
RUN uv sync --frozen --no-dev

# copy requirements first to create better cache layers
COPY requirements.txt /app/
RUN pip install -r requirements.txt
# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"

COPY . /app/
RUN python setup.py install
# Poor mans test if at least the imports work
RUN python toogoodtogo_ha_mqtt_bridge/main.py --version

# Run
ENV DYNACONF_DATA_DIR=/data
CMD ["python", "toogoodtogo_ha_mqtt_bridge/main.py"]
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ sets the polling interval in cron notation. For more Infomation have a look here

#### `tgtg.intense_fetch` (optional)

Is meant query your favourites for a short amount of time with a higher frequency.
Ideal for those boxes you always miss!
With the `interval`, the time between the queries can be controlled.
With the setting `period_of_time` the duration of the intense fetch can be defined.
The smallest interval is 10 seconds, and the maximum duration of the intense_fetch is 60 minutes.
Is meant query your favourites for a short amount of time with a higher frequency.
Ideal for those boxes you always miss!
With the `interval`, the time between the queries can be controlled.
With the setting `period_of_time` the duration of the intense fetch can be defined.
The smallest interval is 10 seconds, and the maximum duration of the intense_fetch is 60 minutes.
**Attention:** This is meant for expierenced users as you might get blocked for a certain amount of time by toogoodtogo.

#### `enable_auto_intense_fetch` (optional)
Expand Down
1 change: 1 addition & 0 deletions pkgx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dependencies: uv prettier pre-commit
138 changes: 134 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,135 @@
[tool.black]
line-length = 110
[project]
name = "toogoodtogo-ha-mqtt-bridge"
version = "0.0.1"
description = "This is a template repository for Python projects that use uv for their dependency management."
authors = [{ name = "Max Winterstein", email = "[email protected]" }]
readme = "README.md"
keywords = ['python']
requires-python = "==3.12.*"
classifiers = [
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"arrow==1.2.3",
"certifi==2022.12.7",
"charset-normalizer==2.0.12",
"coloredlogs==15.0.1",
"croniter==1.3.8",
"dynaconf==3.1.12",
"freezegun==1.2.2",
"google-play-scraper==1.2.3",
"humanfriendly==10.0",
"idna==3.3",
"packaging==23.0",
"paho-mqtt==1.6.1",
"python-dateutil==2.8.2",
"random-user-agent==1.0.1",
"requests==2.28.0",
"schedule==1.1.0",
"six==1.16.0",
"tenacity==8.2.2",
"tgtg==0.13.2",
"urllib3==1.26.9",
"setuptools",
"click"
]

[tool.isort]
profile = "black"
[project.urls]
Homepage = "https://MaxWinterstein.github.io/toogoodtogo-ha-mqtt-bridge/"
Repository = "https://github.com/MaxWinterstein/toogoodtogo-ha-mqtt-bridge"
Documentation = "https://MaxWinterstein.github.io/toogoodtogo-ha-mqtt-bridge/"

[tool.uv]
dev-dependencies = [
"pytest>=7.2.0",
"pre-commit>=2.20.0",
"deptry>=0.20.0",
"mypy>=0.991",

"ruff>=0.6.9",

]

[build-system]
requires = ["setuptools >= 61.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
py-modules = ["toogoodtogo_ha_mqtt_bridge"]

[tool.mypy]
files = ["toogoodtogo_ha_mqtt_bridge"]
disallow_untyped_defs = true
disallow_any_unimported = true
no_implicit_optional = true
check_untyped_defs = true
warn_return_any = true
warn_unused_ignores = true
show_error_codes = true

[tool.pytest.ini_options]
testpaths = ["tests"]

[tool.ruff]
target-version = "py39"
line-length = 120
fix = true

[tool.ruff.lint]
select = [
# flake8-2020
"YTT",
# flake8-bandit
"S",
# flake8-bugbear
"B",
# flake8-builtins
"A",
# flake8-comprehensions
"C4",
# flake8-debugger
"T10",
# flake8-simplify
"SIM",
# isort
"I",
# mccabe
"C90",
# pycodestyle
"E", "W",
# pyflakes
"F",
# pygrep-hooks
"PGH",
# pyupgrade
"UP",
# ruff
"RUF",
# tryceratops
"TRY",
]
ignore = [
# LineTooLong
"E501",
# DoNotAssignLambda
"E731",
# i like my unnecessary True if ... else False
"SIM210",
]

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S101"]

[tool.ruff.format]
preview = true

[tool.deptry.per_rule_ignores]
DEP004 = ["pytest"]
15 changes: 0 additions & 15 deletions requirements.in

This file was deleted.

49 changes: 0 additions & 49 deletions requirements.txt

This file was deleted.

11 changes: 0 additions & 11 deletions setup.py

This file was deleted.

Loading

0 comments on commit b2ed88e

Please sign in to comment.