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

Migrate to python bootstrap conventions #128

Merged
merged 32 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2d105dc
Start migration to python bootstrap conventions
benoit74 Feb 6, 2024
c0c0a97
Remove useless fixture mark - never had any effect
benoit74 Feb 6, 2024
13f69d7
Minimal stubs for libzim
benoit74 Feb 6, 2024
2a18db4
Automatic fixes by ruff and black
benoit74 Feb 6, 2024
b6f25e5
Automatic ruff fixes with unsafe rules
benoit74 Feb 6, 2024
3f50609
Add all needed noqa statements - to be removed in the future, one by one
benoit74 Feb 6, 2024
2baf95f
Add all needed pyright:ignore statements - to be removed in the futur…
benoit74 Feb 6, 2024
c9cf343
Add 3.12 support and standardize CI
benoit74 Feb 6, 2024
5a0feca
Migrate from iso-639 to iso639-lang library, former one is not mainta…
benoit74 Feb 6, 2024
f3d6e09
Run all tests and install fix_ogvjs_dist script
benoit74 Feb 8, 2024
07755c3
Fix nocover pragmas
benoit74 Feb 8, 2024
e1c87af
Fix changelog
benoit74 Feb 8, 2024
dcded70
Fix many qa issues and one typing issue
benoit74 Feb 9, 2024
842252e
--runinstalled is not necessary anymore with bootstrap convention, we…
benoit74 Feb 9, 2024
4e5c216
Add back a lost # pragma: no cover
benoit74 Feb 9, 2024
dccaa66
Rewrite fix_ogvjs_dist and its tests to remove tests redundancies + e…
benoit74 Feb 9, 2024
a2f4650
Increase test coverage of zim/metadata.py
benoit74 Feb 9, 2024
b588a79
Increase test coverage of download.py
benoit74 Feb 9, 2024
c399f6f
Increase test coverage of filesystem.py
benoit74 Feb 9, 2024
fbe613f
Increase test coverage of image/optimization.py
benoit74 Feb 9, 2024
6c62022
Increase test coverage of logging.py
benoit74 Feb 9, 2024
75c7241
Increase test coverage of zim/_libkiwix.py + remove useless if branch
benoit74 Feb 9, 2024
40cadd4
Increase test coverage of zim/archive.py
benoit74 Feb 9, 2024
f9f0b9c
Increase test coverage of zim/filesystem.py
benoit74 Feb 9, 2024
e018d5d
Remove pytest.raise match condition because message changed in Python…
benoit74 Feb 9, 2024
0568e64
Fix options typing + add handling for incorrect outtmpl type
benoit74 Feb 12, 2024
b6db708
Skip test temporarily
benoit74 Feb 12, 2024
f342cc2
Restore Python dependencies ranges + widen the libzim range
benoit74 Feb 12, 2024
04964e1
Use type instead of __class__
benoit74 Feb 12, 2024
222bd80
Update README contribution guidelines + user projects
benoit74 Feb 12, 2024
c46d33f
Use /usr/bin/env in every subprocess command
benoit74 Feb 12, 2024
ad4b241
Re-activate test
benoit74 Feb 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/Publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build and upload to PyPI

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-22.04
permissions:
id-token: write # mandatory for PyPI trusted publishing

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version-file: pyproject.toml
architecture: x64

- name: Build packages
run: |
pip install -U pip build
python -m build --sdist --wheel

- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.8
34 changes: 34 additions & 0 deletions .github/workflows/QA.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: QA

on:
pull_request:
push:
branches:
- main

jobs:
check-qa:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version-file: pyproject.toml
architecture: x64

- name: Install dependencies (and project)
run: |
pip install -U pip
pip install -e .[lint,scripts,test,check]

- name: Check black formatting
run: inv lint-black

- name: Check ruff
run: inv lint-ruff

- name: Check pyright
run: inv check-pyright
60 changes: 60 additions & 0 deletions .github/workflows/Tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Tests

on:
pull_request:
push:
branches:
- main

jobs:
run-tests:
strategy:
matrix:
os: [ubuntu-22.04]
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- name: install ffmpeg and gifsicle
run: sudo apt update && sudo apt install ffmpeg gifsicle

- name: add required locales for tests
run: sudo locale-gen fr_FR.UTF-8 pt_BR.UTF-8 && sudo update-locale

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64

- name: Install dependencies (and project)
run: |
pip install -U pip
pip install -e .[test,scripts]

- name: Run the tests
run: inv coverage --args "--runslow -vvv"

- name: Upload coverage report to codecov
if: matrix.python == '3.12'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

build_python:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version-file: pyproject.toml
architecture: x64

- name: Ensure we can build Python targets
run: |
pip install -U pip build
python3 -m build --sdist --wheel
54 changes: 0 additions & 54 deletions .github/workflows/ci.yml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/release.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,7 @@ $RECYCLE.BIN/
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/python,macos,windows,linux

# ignore all vscode, this is not standard configuration in this place
.vscode
src/libzim-stubs
43 changes: 24 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/pycqa/isort
rev: "5.12.0"
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
- repo: https://github.com/psf/black
rev: "23.1.0"
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: "6.0.0"
hooks:
- id: flake8
args: ["--max-line-length", "88", "--extend-ignore=E203"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/psf/black
rev: "24.1.1"
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: ruff
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.350
hooks:
- id: pyright
name: pyright (system)
description: 'pyright static type checker'
entry: pyright
language: system
'types_or': [python, pyi]
require_serial: true
minimum_pre_commit_version: '2.9.2'
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (as of version 1.5.0).

## [Unreleased]

### Changed

- Using openZIM Python bootstrap conventions (including hatch-openzim plugin) #120
- Suuport for Python 3.12, drop Python 3.7 #118
- Replace "iso-369" iso639-lang by "iso639-lang" library

## [3.2.0] - 2023-12-16

### Added
Expand Down
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,29 @@ sudo apt install libmagic1 wget ffmpeg \

# Contribution

This project adheres to openZIM's [Contribution Guidelines](https://github.com/openzim/overview/wiki/Contributing)

```shell
pip -r requirements.txt
pip install tox pre-commit
pip install hatch
pip install ".[dev]"
pre-commit install
# For tests
tox
invoke coverage
```

# Users

Non-exhaustive list of scrapers using it (check status when updating API):

* [openzim/youtube](https://github.com/openzim/youtube)
* [openzim/freecodecamp](https://github.com/openzim/freecodecamp)
* [openzim/gutenberg](https://github.com/openzim/gutenberg)
* [openzim/ifixit](https://github.com/openzim/ifixit)
* [openzim/kolibri](https://github.com/openzim/kolibri)
* [openzim/nautilus](https://github.com/openzim/nautilus)

# releasing

* Update your dependencies: `pip install -U setuptools wheel twine`
* Make sure CHANGELOG.md is up-to-date
* Bump version on `src/zimscraperlib/VERSION`
* Build packages `python ./setup.py sdist bdist_wheel`
* Upload to PyPI `twine upload dist/zimscraperlib-2.0.0*`.
* Commit your Changelog + version bump changes
* Tag version on git `git tag -a v2.0.0`
* [openzim/nautilus](https://github.com/openzim/nautilus)
* [openzim/openedx](https://github.com/openzim/openedx)
* [openzim/sotoki](https://github.com/openzim/sotoki)
* [openzim/ted](https://github.com/openzim/ted)
* [openzim/warc2zim](https://github.com/openzim/warc2zim)
* [openzim/wikihow](https://github.com/openzim/wikihow)
* [openzim/youtube](https://github.com/openzim/youtube)
Loading