-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: modernize package config (#1)
* Refactor: modernize package config * Add step verifying main entrypoint * Bump version to v0.2.0 Code or functionality has not changed, but lets bump version just in case there are problems with the project modernization refactoring. * Switch to dynamic setuptools versioning * Embed program version into --help output
- Loading branch information
Showing
21 changed files
with
523 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Python app | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.9", "3.10", "3.11"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: FedericoCarboni/setup-ffmpeg@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install environment | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install -r requirements-dev.txt | ||
- name: Run linter | ||
run: | | ||
make lint | ||
- name: Run tests | ||
run: | | ||
make test | ||
- name: Verify main entrypoint script works | ||
run: | | ||
python -m venv app-venv && ./app-venv/bin/pip install . | ||
./app-venv/bin/audiobook-split-ffmpeg --help | ||
./app-venv/bin/audiobook-split-ffmpeg --infile tests/beep.m4a --outdir _out --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
VENV_DIR := .venv | ||
|
||
sync-venv: requirements-dev.txt | ||
python3 -m venv ${VENV_DIR} | ||
./${VENV_DIR}/bin/pip install --upgrade pip | ||
./${VENV_DIR}/bin/pip install -r requirements-dev.txt | ||
@echo "---" | ||
@echo "NOTE: Please run 'source ./${VENV_DIR}/bin/activate' to use the env" | ||
@echo " or run 'Python: Select Interpreter' from VSCode command palette" | ||
|
||
pin-requirements: requirements.txt requirements-dev.txt | ||
@echo "---------------------------------------------" | ||
@echo "Done.\n" | ||
@echo "Remember to commit changes to pyproject.toml," | ||
@echo " requirements.txt, and requirements-dev.txt" | ||
@echo "---------------------------------------------" | ||
|
||
requirements.txt: pyproject.toml | ||
pip-compile \ | ||
--generate-hashes \ | ||
--strip-extras \ | ||
--output-file=requirements.txt \ | ||
pyproject.toml | ||
|
||
requirements-dev.txt: requirements.txt | ||
pip-compile \ | ||
--strip-extras \ | ||
--constraint requirements.txt \ | ||
--output-file=requirements-dev.txt \ | ||
--extra dev \ | ||
pyproject.toml | ||
|
||
# This is basically 'python3 -m build' | ||
build: | ||
pyproject-build | ||
|
||
lint: | ||
ruff check --output-format=full --statistics --exit-zero | ||
|
||
test: | ||
pytest --cov=audiobook_split_ffmpeg tests/ | ||
|
||
.PHONY: sync-venv pin-requirements build lint test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,51 @@ | ||
[build-system] | ||
requires = [ | ||
"setuptools>=42", | ||
"wheel", | ||
requires = ['setuptools>=61'] | ||
build-backend = 'setuptools.build_meta' | ||
|
||
[project] | ||
name = 'audiobook-split-ffmpeg' | ||
authors = [ | ||
{name='Markus H (MawKKe)', email='markus@mawkke.fi'} | ||
] | ||
description = 'Split audiobook file into per-chapter files using chapter metadata and ffmpeg' | ||
dynamic = ["version"] | ||
license = {text = 'Apache License 2.0'} | ||
readme = 'README.md' | ||
requires-python = '>=3.8' | ||
dependencies = [] | ||
|
||
[tool.setuptools.dynamic] | ||
version = {attr = "audiobook_split_ffmpeg.__version__"} | ||
|
||
[project.optional-dependencies] | ||
dev = [ | ||
'ruff>=0.3', | ||
'pytest>=7', | ||
'pytest-cov>=4.1', | ||
] | ||
|
||
build-backend = "setuptools.build_meta" | ||
[project.urls] | ||
homepage = 'https://github.com/MawKKe/audiobook-split-ffmpeg' | ||
Issues = 'https://github.com/MawKKe/audiobook-split-ffmpeg/issues' | ||
|
||
[project.scripts] | ||
audiobook-split-ffmpeg = 'audiobook_split_ffmpeg.cli:main' | ||
|
||
[tool.pytest.ini_options] | ||
pythonpath = [ | ||
".", "src", | ||
] | ||
|
||
[tool.ruff] | ||
line-length = 100 | ||
|
||
[tool.ruff.format] | ||
# Use single quotes rather than double quotes. | ||
quote-style = 'single' | ||
skip-magic-trailing-comma = false | ||
|
||
[tool.ruff.lint] | ||
select = ['E4', 'E7', 'E9', 'F', 'C901'] | ||
|
||
[tool.ruff.lint.mccabe] | ||
max-complexity = 10 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
pytest==6.2.5 | ||
pytest-cov==2.12.1 | ||
pytest-flake8==1.0.7 | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.12 | ||
# by the following command: | ||
# | ||
# pip-compile --constraint=requirements.txt --extra=dev --output-file=requirements-dev.txt --strip-extras pyproject.toml | ||
# | ||
coverage==7.4.3 | ||
# via pytest-cov | ||
iniconfig==2.0.0 | ||
# via pytest | ||
packaging==23.2 | ||
# via pytest | ||
pluggy==1.4.0 | ||
# via pytest | ||
pytest==8.1.1 | ||
# via | ||
# audiobook-split-ffmpeg (pyproject.toml) | ||
# pytest-cov | ||
pytest-cov==4.1.0 | ||
# via audiobook-split-ffmpeg (pyproject.toml) | ||
ruff==0.3.2 | ||
# via audiobook-split-ffmpeg (pyproject.toml) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.12 | ||
# by the following command: | ||
# | ||
# pip-compile --generate-hashes --output-file=requirements.txt --strip-extras pyproject.toml | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.