Merge pull request #286 from openzim/upgrade_deps

Upgrade to Python 3.12, upgrade Python dependencies and add hatch-openzim plugin
This commit is contained in:
benoit74 2024-03-04 11:23:42 +01:00 committed by GitHub
commit c2dc8c5ccc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 37 deletions

View File

@ -7,15 +7,15 @@ repos:
- id: trailing-whitespace - id: trailing-whitespace
- id: end-of-file-fixer - id: end-of-file-fixer
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: "23.12.1" rev: "24.2.0"
hooks: hooks:
- id: black - id: black
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3 rev: v0.3.0
hooks: hooks:
- id: ruff - id: ruff
- repo: https://github.com/RobertCraigie/pyright-python - repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.347 rev: v1.1.352
hooks: hooks:
- id: pyright - id: pyright
name: pyright (system) name: pyright (system)

View File

@ -1,13 +1,16 @@
FROM webrecorder/browsertrix-crawler:0.12.4 FROM webrecorder/browsertrix-crawler:0.12.4
LABEL org.opencontainers.image.source https://github.com/openzim/zimit 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 \ RUN apt-get update \
&& apt-get install -qqy --no-install-recommends \ && apt-get install -qqy --no-install-recommends \
libmagic1 \ libmagic1 \
python3.11-venv \ python3.12-venv \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
# python setup (in venv not to conflict with browsertrix) # 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) # placeholder (default output location)
&& mkdir -p /output \ && mkdir -p /output \
# disable chrome upgrade # disable chrome upgrade

View File

@ -1,29 +1,22 @@
[build-system] [build-system]
requires = ["hatchling"] requires = ["hatchling", "hatch-openzim==0.2.0"]
build-backend = "hatchling.build" build-backend = "hatchling.build"
[project] [project]
name = "zimit" name = "zimit"
authors = [ requires-python = ">=3.12,<3.13"
{ name = "Kiwix", email = "dev@kiwix.org" },
]
keywords = ["some"]
requires-python = ">=3.11,<3.12"
description = "Make ZIM file from any website through crawling" description = "Make ZIM file from any website through crawling"
readme = "README.md" 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 = [ dependencies = [
"requests==2.31.0", "requests==2.31.0",
"inotify==0.2.10", "inotify==0.2.10",
"tld==0.13", "tld==0.13",
"warc2zim @ git+https://github.com/openzim/warc2zim@warc2zim2", "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] [tool.hatch.metadata]
allow-direct-references = true # to be removed once we use a released warc2zim version allow-direct-references = true # to be removed once we use a released warc2zim version
@ -33,29 +26,25 @@ scripts = [
"invoke==2.2.0", "invoke==2.2.0",
] ]
lint = [ lint = [
"black==23.12.1", "black==24.2.0",
"ruff==0.1.3", "ruff==0.3.0",
] ]
check = [ check = [
"pyright==1.1.347", "pyright==1.1.352",
] ]
test = [ test = [
"pytest==7.4.4", "pytest==8.0.2",
"coverage==7.4.0", "coverage==7.4.3",
] ]
dev = [ dev = [
"pre-commit==3.6.0", "pre-commit==3.6.2",
"debugpy==1.8.0", "debugpy==1.8.1",
"zimit[scripts]", "zimit[scripts]",
"zimit[lint]", "zimit[lint]",
"zimit[test]", "zimit[test]",
"zimit[check]", "zimit[check]",
] ]
[project.urls]
Homepage = "https://github.com/openzim/zimit"
Donate = "https://www.kiwix.org/en/support-us/"
[project.scripts] [project.scripts]
zimit = "zimit:zimit.zimit" zimit = "zimit:zimit.zimit"
@ -105,12 +94,14 @@ all = "inv checkall --args '{args}'"
[tool.black] [tool.black]
line-length = 88 line-length = 88
target-version = ['py311'] target-version = ['py312']
[tool.ruff] [tool.ruff]
target-version = "py311" target-version = "py312"
line-length = 88 line-length = 88
src = ["src"] src = ["src"]
[tool.ruff.lint]
select = [ select = [
"A", # flake8-builtins "A", # flake8-builtins
# "ANN", # flake8-annotations # "ANN", # flake8-annotations
@ -187,17 +178,17 @@ unfixable = [
"F401", "F401",
] ]
[tool.ruff.isort] [tool.ruff.lint.isort]
known-first-party = ["zimit"] known-first-party = ["zimit"]
[tool.ruff.flake8-bugbear] [tool.ruff.lint.flake8-bugbear]
# add exceptions to B008 for fastapi. # add exceptions to B008 for fastapi.
extend-immutable-calls = ["fastapi.Depends", "fastapi.Query"] extend-immutable-calls = ["fastapi.Depends", "fastapi.Query"]
[tool.ruff.flake8-tidy-imports] [tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all" 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 can use magic values, assertions, and relative imports
"tests**/**/*" = ["PLR2004", "S101", "TID252"] "tests**/**/*" = ["PLR2004", "S101", "TID252"]
@ -229,5 +220,5 @@ exclude_lines = [
include = ["src", "tests", "tasks.py"] include = ["src", "tests", "tasks.py"]
exclude = [".env/**", ".venv/**"] exclude = [".env/**", ".venv/**"]
extraPaths = ["src"] extraPaths = ["src"]
pythonVersion = "3.11" pythonVersion = "3.12"
typeCheckingMode="basic" typeCheckingMode="basic"

View File

@ -92,7 +92,7 @@ def fix_black(ctx: Context, args: str = "."):
def fix_ruff(ctx: Context, args: str = "."): def fix_ruff(ctx: Context, args: str = "."):
"""fix all ruff rules""" """fix all ruff rules"""
args = args or "." # needed for hatch script 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( @task(