Skip to content

Commit

Permalink
Merge pull request #202 from openzim/upgrade_deps
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 committed May 22, 2024
2 parents d930c98 + 4ec1e1d commit 84dba38
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 170 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/psf/black
rev: "23.7.0"
rev: "24.4.2"
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.282
rev: v0.4.4
hooks:
- id: ruff
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.331
rev: v1.1.363
hooks:
- id: pyright
name: pyright (system)
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- New `long_description` CLI argument to set the ZIM long description
- New `disable_metadata_check` CLI argument to disable the metadata checks which are automated since zimscraperlib 3.x

### Changed

- Changed default publisher metadata to 'openZIM'
- Validate ZIM metadata (tags, title, description, long_description) as early as possible
- Migrate to zimscraperlib 3.3.2
- Upgrade Python dependencies, including migration to Python 3.12

## [2.2.0] - 2023-11-17

Expand All @@ -23,7 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed local path media (profile, banner) not working (#178)
- Unset `metadata_from` in `youtube2zim-playlists` (#185)
- Do not move local banner and profile images, copy them instead #179
- Do not move local banner and profile images, copy them instead #179

## [2.1.18] - 2022-11-09

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-bookworm
FROM python:3.12-bookworm
LABEL org.opencontainers.image.source https://github.com/openzim/youtube

# Install necessary packages
Expand All @@ -20,7 +20,7 @@ RUN mkdir -p /output
WORKDIR /output

# Copy pyproject.toml and its dependencies
COPY pyproject.toml README.md get_js_deps.sh hatch_build.py /src/
COPY pyproject.toml README.md openzim.toml /src/
COPY src/youtube2zim/__about__.py /src/src/youtube2zim/__about__.py

# Install Python dependencies
Expand Down
66 changes: 0 additions & 66 deletions get_js_deps.sh

This file was deleted.

43 changes: 0 additions & 43 deletions hatch_build.py

This file was deleted.

44 changes: 44 additions & 0 deletions openzim.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[files.assets.config]
target_dir="src/youtube2zim/templates/assets"
execute_after=[
"fix_ogvjs_dist .",
]

[files.assets.actions."video.js"]
action="extract_all"
source="https://github.com/videojs/video.js/releases/download/v8.6.1/video-js-8.6.1.zip"
target_dir="videojs"
remove = ["alt","examples",]

[files.assets.actions."chosen.jquery.js"]
action="extract_all"
source="https://github.com/harvesthq/chosen/releases/download/v1.8.7/chosen_v1.8.7.zip"
target_dir="chosen"
remove = ["docsupport","chosen.proto.*","*.html","*.md"]

[files.assets.actions."jquery.min.js"]
action="get_file"
source="https://code.jquery.com/jquery-1.12.4.min.js"
target_file="jquery.min.js"

[files.assets.actions."ogv.js"]
action="extract_items"
source="https://github.com/brion/ogv.js/releases/download/1.8.9/ogvjs-1.8.9.zip"
zip_paths=["ogvjs-1.8.9"]
target_paths=["ogvjs"]
remove = ["ogvjs/COPYING","ogvjs/*.txt","ogvjs/*.md",]

[files.assets.actions."videojs-ogvjs.js"]
action="get_file"
source="https://dev.kiwix.org/videojs-ogvjs/videojs-ogvjs.min.js"
target_file="videojs-ogvjs.js"

[files.assets.actions."webp-hero.polyfills.js"]
action="get_file"
source="https://unpkg.com/webp-hero@0.0.2/dist-cjs/polyfills.js"
target_file="polyfills.js"

[files.assets.actions."webp-hero.bundle.js"]
action="get_file"
source="https://unpkg.com/webp-hero@0.0.2/dist-cjs/webp-hero.bundle.js"
target_file="webp-hero.bundle.js"
71 changes: 34 additions & 37 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,54 +1,49 @@
[build-system]
requires = ["hatchling"]
requires = ["hatchling", "hatch-openzim==0.2.1"]
build-backend = "hatchling.build"

[project]
name = "youtube2zim"
authors = [{ name = "Kiwix", email = "dev@kiwix.org" }]
keywords = ["kiwix", "zim", "offline", "youtube"]
requires-python = ">=3.10,<3.11"
requires-python = ">=3.12,<3.13"
description = "Make ZIM file from a Youtube channel, user or playlist(s)"
readme = "README.md"
license = { text = "GPL-3.0-or-later" }
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
]
dependencies = [
"python-slugify==3.0.3",
"yt-dlp", # youtube-dl should be updated as frequently as possible
"python-dateutil==2.8.0",
"jinja2>=2.11,<3.0",
"MarkupSafe==2.0.1", # jinja2 dependency (https://github.com/pallets/markupsafe/issues/284)
"zimscraperlib>=2.0.0,<2.1.0",
"python-dateutil==2.9.0.post0",
"jinja2==3.1.4",
"zimscraperlib==3.3.2",
"requests==2.32.0",
"kiwixstorage==0.8.3",
"pif==0.8.2",
]
dynamic = ["version"]
dynamic = ["authors", "classifiers", "keywords", "license", "version", "urls"]

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.metadata.hooks.openzim-metadata]
kind = "scraper"
additional-keywords = ["youtube"]

[tool.hatch.build.hooks.openzim-build]
dependencies = [ "zimscraperlib==3.3.2"] # required for fix_ogv_dist

[project.optional-dependencies]
scripts = ["invoke==2.2.0"]
lint = ["black==23.9.1", "ruff==0.0.292"]
check = ["pyright==1.1.331"]
test = ["pytest==7.4.2", "coverage==7.3.2"]
lint = ["black==24.4.2", "ruff==0.4.4"]
check = ["pyright==1.1.363"]
test = ["pytest==8.1.1", "coverage==7.4.4"]
dev = [
"pre-commit==3.4.0",
"debugpy==1.8.0",
"pre-commit==3.7.1",
"debugpy==1.8.1",
"youtube2zim[scripts]",
"youtube2zim[lint]",
"youtube2zim[test]",
"youtube2zim[check]",
# hatchling is a dev dependency only needed for hook development on developer machine
"hatchling==1.18.0",
"humanfriendly==10.0"
]

[project.urls]
Homepage = "https://github.com/openzim/youtube"
Donate = "https://www.kiwix.org/en/support-us/"

[project.scripts]
youtube2zim = "youtube2zim.__main__:main"
youtube2zim-playlists = "youtube2zim.playlists.__main__:main"
Expand All @@ -59,12 +54,11 @@ path = "src/youtube2zim/__about__.py"
[tool.hatch.build]
exclude = ["/.github"]

[tool.hatch.build.hooks.custom]
path = "hatch_build.py"
dependencies = ["zimscraperlib>=2.0.0,<2.1.0"]

[tool.hatch.build.targets.wheel]
packages = ["src/youtube2zim"]
artifacts = [
"src/youtube2zim/templates/assets/**",
]

[tool.hatch.envs.default]
features = ["dev"]
Expand All @@ -81,7 +75,7 @@ html = "inv coverage --html --args '{args}'"

[tool.hatch.envs.lint]
template = "lint"
python = "py311"
python = "py312"
skip-install = false
features = ["scripts", "lint"]

Expand All @@ -102,13 +96,15 @@ all = "inv checkall --args '{args}'"

[tool.black]
line-length = 88
target-version = ['py311']
target-version = ['py312']
exclude = "(src/youtube2zim/templates/.*|.hatch/.*)"

[tool.ruff]
target-version = "py311"
target-version = "py312"
line-length = 88
src = ["src"]

[tool.ruff.lint]
select = [
"A", # flake8-builtins
# "ANN", # flake8-annotations
Expand Down Expand Up @@ -193,13 +189,13 @@ unfixable = [
"F401",
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["youtube2zim"]

[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"]

Expand All @@ -225,5 +221,6 @@ exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"]
include = ["src", "tests", "tasks.py"]
exclude = [".env/**", ".venv/**", "src/youtube2zim/templates", ".hatch"]
extraPaths = ["src"]
pythonVersion = "3.10"
pythonVersion = "3.12"
typeCheckingMode = "basic"
disableBytesTypePromotions = true
Loading

0 comments on commit 84dba38

Please sign in to comment.