From a44c1a7c7ff2f520370086a111bdeb0ce2689465 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Fri, 1 Mar 2024 13:46:05 +0000 Subject: [PATCH 1/3] Upgrade dependencies --- .pre-commit-config.yaml | 6 +++--- pyproject.toml | 24 +++++++++++++----------- tasks.py | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 42d7ca3..b93b4a9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,15 +7,15 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/psf/black - rev: "23.12.1" + rev: "24.2.0" hooks: - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.3 + rev: v0.3.0 hooks: - id: ruff - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.347 + rev: v1.1.352 hooks: - id: pyright name: pyright (system) diff --git a/pyproject.toml b/pyproject.toml index ad7db1f..177acf1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,19 +33,19 @@ scripts = [ "invoke==2.2.0", ] lint = [ - "black==23.12.1", - "ruff==0.1.3", + "black==24.2.0", + "ruff==0.3.0", ] check = [ - "pyright==1.1.347", + "pyright==1.1.352", ] test = [ - "pytest==7.4.4", - "coverage==7.4.0", + "pytest==8.0.2", + "coverage==7.4.3", ] dev = [ - "pre-commit==3.6.0", - "debugpy==1.8.0", + "pre-commit==3.6.2", + "debugpy==1.8.1", "zimit[scripts]", "zimit[lint]", "zimit[test]", @@ -111,6 +111,8 @@ target-version = ['py311'] target-version = "py311" line-length = 88 src = ["src"] + +[tool.ruff.lint] select = [ "A", # flake8-builtins # "ANN", # flake8-annotations @@ -187,17 +189,17 @@ unfixable = [ "F401", ] -[tool.ruff.isort] +[tool.ruff.lint.isort] known-first-party = ["zimit"] -[tool.ruff.flake8-bugbear] +[tool.ruff.lint.flake8-bugbear] # add exceptions to B008 for fastapi. extend-immutable-calls = ["fastapi.Depends", "fastapi.Query"] -[tool.ruff.flake8-tidy-imports] +[tool.ruff.lint.flake8-tidy-imports] ban-relative-imports = "all" -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] # Tests can use magic values, assertions, and relative imports "tests**/**/*" = ["PLR2004", "S101", "TID252"] diff --git a/tasks.py b/tasks.py index 90854e8..a95c71a 100644 --- a/tasks.py +++ b/tasks.py @@ -92,7 +92,7 @@ def fix_black(ctx: Context, args: str = "."): def fix_ruff(ctx: Context, args: str = "."): """fix all ruff rules""" args = args or "." # needed for hatch script - ctx.run(f"ruff --fix {args}", pty=use_pty) + ctx.run(f"ruff check --fix {args}", pty=use_pty) @task( From 89aea6b41ed95cbfd9a6c301073027ea88d5380c Mon Sep 17 00:00:00 2001 From: benoit74 Date: Fri, 1 Mar 2024 13:47:13 +0000 Subject: [PATCH 2/3] Adopt hatch-openzim plugin --- pyproject.toml | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 177acf1..ac7113f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,29 +1,22 @@ [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-openzim==0.2.0"] build-backend = "hatchling.build" [project] name = "zimit" -authors = [ - { name = "Kiwix", email = "dev@kiwix.org" }, -] -keywords = ["some"] requires-python = ">=3.11,<3.12" description = "Make ZIM file from any website through crawling" readme = "README.md" -license = {text = "GPL-3.0-or-later"} -classifiers = [ - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.11", - "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", -] dependencies = [ "requests==2.31.0", "inotify==0.2.10", "tld==0.13", "warc2zim @ git+https://github.com/openzim/warc2zim@warc2zim2", ] -dynamic = ["version"] +dynamic = ["authors", "classifiers", "keywords", "license", "version", "urls"] + +[tool.hatch.metadata.hooks.openzim-metadata] +kind = "scraper" [tool.hatch.metadata] allow-direct-references = true # to be removed once we use a released warc2zim version @@ -52,10 +45,6 @@ dev = [ "zimit[check]", ] -[project.urls] -Homepage = "https://github.com/openzim/zimit" -Donate = "https://www.kiwix.org/en/support-us/" - [project.scripts] zimit = "zimit:zimit.zimit" From 857ae5674de6ce80a18a86332927be10cdd2804d Mon Sep 17 00:00:00 2001 From: benoit74 Date: Fri, 1 Mar 2024 13:47:27 +0000 Subject: [PATCH 3/3] Upgrade to Python 3.12 --- Dockerfile | 7 +++++-- pyproject.toml | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3435fbf..7126f44 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,16 @@ FROM webrecorder/browsertrix-crawler:0.12.4 LABEL org.opencontainers.image.source https://github.com/openzim/zimit +# add deadsnakes ppa for Python 3.12 on Ubuntu Jammy +RUN add-apt-repository ppa:deadsnakes/ppa -y + RUN apt-get update \ && apt-get install -qqy --no-install-recommends \ libmagic1 \ - python3.11-venv \ + python3.12-venv \ && rm -rf /var/lib/apt/lists/* \ # python setup (in venv not to conflict with browsertrix) - && python3.11 -m venv /app/zimit \ + && python3.12 -m venv /app/zimit \ # placeholder (default output location) && mkdir -p /output \ # disable chrome upgrade diff --git a/pyproject.toml b/pyproject.toml index ac7113f..4648ac4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "zimit" -requires-python = ">=3.11,<3.12" +requires-python = ">=3.12,<3.13" description = "Make ZIM file from any website through crawling" readme = "README.md" dependencies = [ @@ -94,10 +94,10 @@ all = "inv checkall --args '{args}'" [tool.black] line-length = 88 -target-version = ['py311'] +target-version = ['py312'] [tool.ruff] -target-version = "py311" +target-version = "py312" line-length = 88 src = ["src"] @@ -220,5 +220,5 @@ exclude_lines = [ include = ["src", "tests", "tasks.py"] exclude = [".env/**", ".venv/**"] extraPaths = ["src"] -pythonVersion = "3.11" +pythonVersion = "3.12" typeCheckingMode="basic"