mirror of
https://github.com/JockeTF/fimfarchive.git
synced 2024-11-21 21:07:59 +01:00
Migrate to pyproject with uv
This commit is contained in:
parent
a396a13379
commit
f7ea42caa6
8 changed files with 80 additions and 163 deletions
25
.github/workflows/main.yml
vendored
25
.github/workflows/main.yml
vendored
|
@ -17,18 +17,27 @@ jobs:
|
||||||
- '3.12'
|
- '3.12'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone Repository
|
- name: Clone repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Python ${{ matrix.python-version }}
|
- name: Use Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
- name: Install Tox
|
- name: Configure uv
|
||||||
run: |
|
uses: astral-sh/setup-uv@v2
|
||||||
python -m pip install --upgrade pip
|
with:
|
||||||
pip install tox tox-gh-actions
|
enable-cache: true
|
||||||
|
|
||||||
- name: Invoke Tox
|
- name: Sync dependencies
|
||||||
run: tox
|
run: uv sync --all-extras --dev
|
||||||
|
|
||||||
|
- name: Check styling
|
||||||
|
run: uv run flake8 --ignore=E123,E231,W291,W293 fimfarchive tests
|
||||||
|
|
||||||
|
- name: Check types
|
||||||
|
run: uv run mypy
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: uv run pytest
|
||||||
|
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -16,8 +16,11 @@ Thumbs.db
|
||||||
# Python cache.
|
# Python cache.
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
||||||
|
# Lock files.
|
||||||
|
uv.lock
|
||||||
|
|
||||||
# Virtual environment.
|
# Virtual environment.
|
||||||
venv/
|
.venv/
|
||||||
|
|
||||||
# Vim settings.
|
# Vim settings.
|
||||||
.vim/
|
.vim/
|
||||||
|
|
16
README.md
16
README.md
|
@ -65,24 +65,22 @@ Start by creating a clone of the Fimfarchive repository.
|
||||||
git clone https://github.com/JockeTF/fimfarchive.git
|
git clone https://github.com/JockeTF/fimfarchive.git
|
||||||
```
|
```
|
||||||
|
|
||||||
Enter the cloned repository and create a virtual environment called `venv`
|
Enter the cloned repository and install the development dependencies.
|
||||||
within it. Make sure to activate the virtual environment before proceeding to
|
|
||||||
install the development dependencies.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python3 -m pip install -r requirements.txt
|
uv sync
|
||||||
```
|
```
|
||||||
|
|
||||||
Optionally also install `lz4` to lower the memory footprint of open archives.
|
Optionally also install `lz4` to lower the memory footprint of open archives.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python3 -m pip install lz4
|
uv sync --extra lz4
|
||||||
```
|
```
|
||||||
|
|
||||||
All done! Run the test suite to make sure everything works as expected.
|
All done! Run the test suite to make sure everything works as expected.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pytest
|
uv run pytest
|
||||||
```
|
```
|
||||||
|
|
||||||
[virtual environment]: https://docs.python.org/3/tutorial/venv.html
|
[virtual environment]: https://docs.python.org/3/tutorial/venv.html
|
||||||
|
@ -91,11 +89,11 @@ pytest
|
||||||
# Running
|
# Running
|
||||||
|
|
||||||
Fimfarchive has a command line interface which is invoked as a Python module.
|
Fimfarchive has a command line interface which is invoked as a Python module.
|
||||||
It can't do much except prepare new Fimfarchie releases. For archive browsing
|
It can't do much except prepare new Fimfarchive releases. For archive browsing
|
||||||
you will need to use third-party tools, or make your own.
|
you will need to use third-party tools, or make your own.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ python3 -m fimfarchive
|
$ uv run python -m fimfarchive
|
||||||
Usage: COMMAND [PARAMETERS]
|
Usage: COMMAND [PARAMETERS]
|
||||||
|
|
||||||
Fimfarchive, ensuring that history is preseved.
|
Fimfarchive, ensuring that history is preseved.
|
||||||
|
@ -109,7 +107,7 @@ The command line interface features multiple subcommands, each with its own
|
||||||
brief help text. The subcommand is specified as the second program argument.
|
brief help text. The subcommand is specified as the second program argument.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ python3 -m fimfarchive update --help
|
$ uv run python -m fimfarchive update --help
|
||||||
usage: [-h] [--alpha] --archive PATH [--refetch]
|
usage: [-h] [--alpha] --archive PATH [--refetch]
|
||||||
|
|
||||||
Updates stories for Fimfarchive.
|
Updates stories for Fimfarchive.
|
||||||
|
|
|
@ -5,7 +5,7 @@ Writers for Fimfarchive.
|
||||||
|
|
||||||
#
|
#
|
||||||
# Fimfarchive, preserves stories from Fimfiction.
|
# Fimfarchive, preserves stories from Fimfiction.
|
||||||
# Copyright (C) 2019 Joakim Soderlund
|
# Copyright (C) 2024 Joakim Soderlund
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -38,7 +38,7 @@ from fimfarchive.stories import Story
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'Writer',
|
'Writer',
|
||||||
'DirectoryWriter',
|
'DirectoryWriter',
|
||||||
'FimfarchiveWriter'
|
'FimfarchiveWriter',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
50
pyproject.toml
Normal file
50
pyproject.toml
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
[project]
|
||||||
|
name = "fimfarchive"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Preserves stories from Fimfiction"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = "~=3.8"
|
||||||
|
dependencies = [
|
||||||
|
"arrow~=1.3",
|
||||||
|
"bbcode~=1.1",
|
||||||
|
"blinker~=1.8",
|
||||||
|
"importlib-resources~=6.4",
|
||||||
|
"jinja2~=3.1",
|
||||||
|
"jmespath~=1.0",
|
||||||
|
"jsonapi-client",
|
||||||
|
"requests~=2.32",
|
||||||
|
"tqdm~=4.66",
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.optional-dependencies]
|
||||||
|
lz4 = ["lz4~=4.3"]
|
||||||
|
|
||||||
|
[tool.uv]
|
||||||
|
compile-bytecode = true
|
||||||
|
dev-dependencies = [
|
||||||
|
"flake8~=5.0",
|
||||||
|
"mypy~=1.11",
|
||||||
|
"pytest~=8.3",
|
||||||
|
"requests-mock~=1.12",
|
||||||
|
"types-jmespath~=1.0",
|
||||||
|
"types-requests~=2.32",
|
||||||
|
"types-tqdm~=4.66",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.uv.sources.jsonapi-client]
|
||||||
|
git = "https://github.com/JockeTF/jsonapi-client.git"
|
||||||
|
|
||||||
|
[tool.mypy]
|
||||||
|
files = ["fimfarchive", "tests"]
|
||||||
|
ignore_missing_imports = true
|
||||||
|
|
||||||
|
[tool.pyright]
|
||||||
|
venvPath = "."
|
||||||
|
venv = ".venv"
|
||||||
|
|
||||||
|
[tool.pytest.ini_options]
|
||||||
|
testpaths = ["tests"]
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["hatchling"]
|
||||||
|
build-backend = "hatchling.build"
|
|
@ -1,16 +0,0 @@
|
||||||
arrow
|
|
||||||
bbcode
|
|
||||||
blinker
|
|
||||||
flake8
|
|
||||||
importlib_resources
|
|
||||||
jinja2
|
|
||||||
jmespath
|
|
||||||
jsonapi-client@git+https://github.com/JockeTF/jsonapi-client.git
|
|
||||||
mypy
|
|
||||||
pytest
|
|
||||||
requests
|
|
||||||
requests-mock
|
|
||||||
tqdm
|
|
||||||
types-jmespath
|
|
||||||
types-requests
|
|
||||||
types-tqdm
|
|
98
setup.py
98
setup.py
|
@ -1,98 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
Setuptools for Fimfarchive.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Fimfarchive, preserves stories from Fimfiction
|
|
||||||
# Copyright (C) 2015 Joakim Soderlund
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
from typing import Iterable, List, Tuple
|
|
||||||
|
|
||||||
from setuptools import setup
|
|
||||||
|
|
||||||
from fimfarchive import __author__, __license__, __version__
|
|
||||||
|
|
||||||
|
|
||||||
PACKAGE = 'fimfarchive'
|
|
||||||
GITHUB = 'https://github.com/JockeTF/fimfarchive'
|
|
||||||
|
|
||||||
|
|
||||||
def to_name(path: str) -> str:
|
|
||||||
"""
|
|
||||||
Converts path to a package name.
|
|
||||||
"""
|
|
||||||
return path.replace(os.path.sep, '.')
|
|
||||||
|
|
||||||
|
|
||||||
def iter_package_paths() -> Iterable[str]:
|
|
||||||
"""
|
|
||||||
Yields all package paths to install.
|
|
||||||
"""
|
|
||||||
for dirpath, dirnames, filenames in os.walk(PACKAGE):
|
|
||||||
if '__init__.py' in filenames:
|
|
||||||
yield dirpath
|
|
||||||
|
|
||||||
|
|
||||||
def iter_package_names() -> Iterable[str]:
|
|
||||||
"""
|
|
||||||
Yields all package names to install.
|
|
||||||
"""
|
|
||||||
for dirpath in iter_package_paths():
|
|
||||||
yield to_name(dirpath)
|
|
||||||
|
|
||||||
|
|
||||||
def iter_package_data() -> Iterable[Tuple[str, List[str]]]:
|
|
||||||
"""
|
|
||||||
Yields all package data to install.
|
|
||||||
"""
|
|
||||||
for dirpath in iter_package_paths():
|
|
||||||
filenames = [
|
|
||||||
filename for filename in os.listdir(dirpath)
|
|
||||||
if os.path.isfile(os.path.join(dirpath, filename))
|
|
||||||
and not filename.endswith('.py')
|
|
||||||
]
|
|
||||||
|
|
||||||
if filenames:
|
|
||||||
yield to_name(dirpath), filenames
|
|
||||||
|
|
||||||
|
|
||||||
setup(
|
|
||||||
name="fimfarchive",
|
|
||||||
version=__version__,
|
|
||||||
license=__license__,
|
|
||||||
author=__author__,
|
|
||||||
author_email='fimfarchive@gmail.com',
|
|
||||||
url='http://www.fimfarchive.net/',
|
|
||||||
download_url=f'{GITHUB}/archive/{__version__}.tar.gz',
|
|
||||||
packages=list(iter_package_names()),
|
|
||||||
package_data=dict(iter_package_data()),
|
|
||||||
install_requires=(
|
|
||||||
'arrow',
|
|
||||||
'bbcode',
|
|
||||||
'blinker',
|
|
||||||
'importlib_resources',
|
|
||||||
'jinja2',
|
|
||||||
'jmespath',
|
|
||||||
'jsonapi-client',
|
|
||||||
'requests',
|
|
||||||
'tqdm',
|
|
||||||
),
|
|
||||||
)
|
|
29
tox.ini
29
tox.ini
|
@ -1,29 +0,0 @@
|
||||||
[tox]
|
|
||||||
envlist =
|
|
||||||
py38
|
|
||||||
py39
|
|
||||||
py310
|
|
||||||
py311
|
|
||||||
py312
|
|
||||||
|
|
||||||
[gh-actions]
|
|
||||||
python =
|
|
||||||
3.8: py38
|
|
||||||
3.9: py39
|
|
||||||
3.10: py310
|
|
||||||
3.11: py311
|
|
||||||
3.12: py312
|
|
||||||
|
|
||||||
[testenv]
|
|
||||||
deps = -rrequirements.txt
|
|
||||||
commands =
|
|
||||||
py.test
|
|
||||||
flake8 fimfarchive tests
|
|
||||||
mypy --ignore-missing-imports fimfarchive tests
|
|
||||||
|
|
||||||
[pytest]
|
|
||||||
addopts =
|
|
||||||
tests
|
|
||||||
|
|
||||||
[flake8]
|
|
||||||
exclude = fimfarchive/__init__.py
|
|
Loading…
Reference in a new issue