Skip to content

Commit 6a1f5a9

Browse files
authored
chore: modernize stack (#26)
1 parent cf1fa52 commit 6a1f5a9

File tree

9 files changed

+114
-172
lines changed

9 files changed

+114
-172
lines changed

.github/workflows/ci.yaml

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ jobs:
1313
runs-on: ubuntu-latest
1414
name: Do the tests pass?
1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1717
- name: Set up Python
18-
uses: actions/setup-python@v2
18+
uses: actions/setup-python@v5
1919
with:
20-
python-version: 3.11
20+
python-version: '3.12'
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v3
2123
- name: Install dependencies and run tests
2224
run: |
23-
pip install -r requirements.txt
24-
pip install pytest pytest-cov
25-
pytest tests/ --cov=src --cov-report=xml
25+
uv venv
26+
uv pip install -r requirements.txt
27+
uv pip install pytest pytest-cov
28+
uv run pytest tests/ --cov=src --cov-report=xml
2629
- name: Upload coverage reports to Codecov
2730
uses: codecov/codecov-action@v4.0.1
2831
with:
@@ -36,28 +39,24 @@ jobs:
3639
runs-on: ubuntu-latest
3740
name: Do the code respects Python standards?
3841
steps:
39-
- uses: actions/checkout@v2
42+
- uses: actions/checkout@v4
4043
- name: Set up Python
41-
uses: actions/setup-python@v2
44+
uses: actions/setup-python@v5
4245
with:
43-
python-version: 3.11
44-
- name: Install dependencies and run linters
46+
python-version: '3.12'
47+
- name: Install uv
48+
uses: astral-sh/setup-uv@v3
49+
- name: Run pre-commit (Ruff and hooks)
4550
run: |
46-
pip install -r requirements_lint.txt
47-
pip install -r requirements.txt
48-
black . --line-length=120 --check --verbose
49-
flake8
50-
pip install --upgrade wrapt
51-
pylint src/ tests/ --rcfile=setup.cfg --fail-under=9 --generated-members=cv2.*
52-
mypy -p src -p tests --ignore-missing-imports --disallow-incomplete-defs
51+
uvx pre-commit run --all-files --show-diff-on-failure
5352
continue-on-error: true
5453

5554
release:
5655
needs: [ test, good-practices ]
5756
runs-on: ubuntu-latest
5857
if: github.ref == 'refs/heads/main'
5958
steps:
60-
- uses: actions/checkout@v2
59+
- uses: actions/checkout@v4
6160
with:
6261
fetch-depth: 0
6362
- name: Bump version and push tag
@@ -71,14 +70,16 @@ jobs:
7170
MINOR_STRING_TOKEN: 'feat:'
7271
PATCH_STRING_TOKEN: 'fix:'
7372
- name: Set up Python
74-
uses: actions/setup-python@v2
73+
uses: actions/setup-python@v5
7574
with:
76-
python-version: '3.11.5'
75+
python-version: '3.12'
76+
- name: Install uv
77+
uses: astral-sh/setup-uv@v3
7778
- name: Build and publish
7879
env:
7980
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
8081
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
8182
run: |
82-
pip install setuptools wheel twine
83-
python setup.py sdist bdist_wheel
84-
twine upload dist/*
83+
uv pip install build twine
84+
uv run python -m build
85+
uv run twine upload dist/*

.pre-commit-config.yaml

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,22 @@
1+
default_language_version:
2+
python: python3.12
3+
4+
exclude: ^env/
5+
16
repos:
27
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.0.1
8+
rev: v4.6.0
49
hooks:
510
- id: check-added-large-files
611
args: ['--maxkb=1550']
712
- id: check-yaml
13+
- id: end-of-file-fixer
814
- id: trailing-whitespace
915

10-
- repo: https://github.com/psf/black
11-
rev: 22.10.0
12-
hooks:
13-
- id: black
14-
args: [--line-length=120, --verbose]
15-
16-
- repo: https://github.com/pycqa/flake8
17-
rev: 4.0.0
18-
hooks:
19-
- id: flake8
20-
21-
- repo: https://github.com/pylint-dev/pylint
22-
rev: v3.1.0
23-
hooks:
24-
- id: pylint
25-
name: pylint
26-
entry: pylint
27-
language: system
28-
args: ['src/', 'tests/', '--rcfile=setup.cfg', '--fail-under=8', '--generated-members=cv2.*']
29-
types: [python]
30-
exclude: '^setup\.py$'
31-
32-
- repo: https://github.com/pre-commit/mirrors-mypy
33-
rev: v1.6.0
16+
- repo: https://github.com/astral-sh/ruff-pre-commit
17+
rev: v0.14.0
3418
hooks:
35-
- id: mypy
36-
args: [--ignore-missing-imports, --disallow-incomplete-defs]
37-
files: ^src/|^tests/
19+
- id: ruff-check
20+
args:
21+
- --fix
22+
- id: ruff-format

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Circular Barcode | Horizontal Barcode
77

88
![PyPI - Version](https://img.shields.io/pypi/v/movie-barcodes)
99
![PyPI - License](https://img.shields.io/pypi/l/movie-barcodes)
10-
![Python](https://img.shields.io/badge/python-3.11-blue)
10+
![Python](https://img.shields.io/badge/python-3.12-blue)
1111
![Status](https://img.shields.io/pypi/status/movie-barcodes.svg)
1212
![Codecov](https://codecov.io/gh/Wazzabeee/movie-barcodes/branch/main/graph/badge.svg)
1313
![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)
@@ -79,20 +79,22 @@ $ git clone https://github.com/Wazzabeee/movie-barcodes
7979
# Go into the repository
8080
$ cd movie-barcodes
8181

82-
# Install requirements
83-
$ pip install -r requirements.txt
84-
$ pip install -r requirements_lint.txt
82+
# (Recommended) Use uv for environment and tools
83+
$ curl -LsSf https://astral.sh/uv/install.sh | sh # or see uv docs for your OS
8584

86-
# Install precommit
87-
$ pip install pre-commit
88-
$ pre-commit install
85+
# Create a virtual environment and install dependencies
86+
$ uv venv
87+
$ uv pip install -r requirements.txt
88+
89+
# Install pre-commit hooks
90+
$ uvx pre-commit install
8991

9092
# Run tests
91-
$ pip install pytest
92-
$ pytest tests/
93+
$ uv pip install pytest pytest-cov
94+
$ uv run pytest tests/
9395

9496
# Run package locally
95-
$ python -m src.main -i "path_to_video.mp4"
97+
$ uv run python -m src.main -i "path_to_video.mp4"
9698
```
9799
98100
# Todo
@@ -146,5 +148,3 @@ movie-barcodes -i "royal_tenenbaums.mp4" --width 1920 --height 1080 -t "horizont
146148
Circular Barcode | Horizontal Barcode
147149
:-------------------------:|:-------------------------:
148150
![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/royal_tenenbaum_smoothed_circular.png) | ![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/royaltenenbaums_smoothed_horizontal.png)
149-
150-

pyproject.toml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[build-system]
2+
requires = ["setuptools>=68", "wheel", "setuptools-scm>=8"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "movie-barcodes"
7+
description = "Compress every frame of a movie in a single color barcode. Transform entire movies into stunning single-barcode visualizations. Capture the essence of cinematic storytelling through dominant color extraction from each frame."
8+
readme = { file = "README.md", content-type = "text/markdown" }
9+
requires-python = ">=3.12"
10+
license = { file = "LICENSE" }
11+
authors = [
12+
{ name = "Clément Delteil", email = "clement45.delteil45@gmail.com" }
13+
]
14+
keywords = [
15+
"visualization", "python", "opencv", "color extraction", "data science",
16+
"machine learning", "movies", "computer vision", "multiprocessing",
17+
"parallel computing", "barcode", "image processing", "multithreading",
18+
"data visualization", "video processing", "color barcode"
19+
]
20+
classifiers = [
21+
"Development Status :: 3 - Alpha",
22+
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
23+
"Natural Language :: English",
24+
"Operating System :: OS Independent",
25+
"Programming Language :: Python",
26+
"Programming Language :: Python :: 3",
27+
"Programming Language :: Python :: 3.12",
28+
]
29+
dependencies = [
30+
"colorama==0.4.6",
31+
"joblib==1.3.2",
32+
"numpy==1.26.0",
33+
"opencv-python==4.8.1.78",
34+
"Pillow==10.3.0",
35+
"scikit-learn==1.5.0",
36+
"scipy==1.11.2",
37+
"threadpoolctl==3.2.0",
38+
"tqdm==4.66.3",
39+
]
40+
41+
dynamic = ["version"]
42+
43+
[project.urls]
44+
Homepage = "https://github.com/Wazzabeee/movie-barcodes"
45+
Repository = "https://github.com/Wazzabeee/movie-barcodes"
46+
47+
[project.scripts]
48+
movie-barcodes = "src.main:main"
49+
50+
[tool.setuptools_scm]
51+
version_scheme = "guess-next-dev"
52+
local_scheme = "node-and-date"
53+
54+
[tool.ruff]
55+
line-length = 120
56+
# Match repo's default Python for linting/formatting
57+
target-version = "py312"
58+
exclude = [
59+
"env/",
60+
]
61+
62+
[tool.ruff.lint]
63+
# Keep compatibility with Black-style slicing
64+
extend-ignore = ["E203"]

requirements.txt

-171 Bytes
Binary file not shown.

requirements_lint.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

setup.cfg

Lines changed: 0 additions & 22 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 78 deletions
This file was deleted.

tests/test_video_processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def grab_side_effect():
155155
mock_video_instance.read.side_effect = read_side_effect
156156
mock_video_instance.grab.side_effect = grab_side_effect
157157

158-
expected_colors = [f"frame_data_{i*10}" for i in range(self.target_frames)]
158+
expected_colors = [f"frame_data_{i * 10}" for i in range(self.target_frames)]
159159

160160
actual_colors = video_processing.extract_colors(
161161
self.video_path,

0 commit comments

Comments
 (0)