Skip to content

Commit

Permalink
migrate to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
NextFire committed Oct 6, 2024
1 parent 55205dc commit b7a0ffe
Show file tree
Hide file tree
Showing 9 changed files with 873 additions and 1,628 deletions.
27 changes: 1 addition & 26 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,2 @@
.venv
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
# README.md
31 changes: 9 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,25 @@ jobs:
if: startsWith(github.ref, 'refs/tags/') != true
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
- uses: astral-sh/setup-uv@v3
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/pyproject.toml', '**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: poetry install
run: |
pip install poetry
poetry install
- run: poetry run pyright sachi/
- run: poetry run ruff check sachi/
enable-cache: true
- run: uv run --frozen pyright sachi/
- run: uv run --frozen ruff check sachi/
if: always()

release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: |
pip install poetry
poetry publish --build
enable-cache: true
- run: uv build
- run: uv publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.POETRY_PYPI_TOKEN_PYPI }}
UV_PUBLISH_USERNAME: ${{ secrets.POETRY_PYPI_TOKEN_PYPI }}
- run: |
gh release create ${{ github.ref_name }} dist/* \
--generate-notes \
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"label": "Textual Development Console",
"type": "process",
"command": "poetry",
"command": "uv",
"args": ["run", "textual", "console"],
"isBackground": true,
"presentation": {
Expand Down
28 changes: 18 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
FROM python:3.12
FROM ghcr.io/astral-sh/uv:python3.12-bookworm

ENV DEBIAN_FRONTEND=noninteractive
ENV POETRY_VIRTUALENVS_IN_PROJECT=1

RUN apt update && \
apt install -y --no-install-recommends neovim mediainfo && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV EDITOR=nvim

ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy

WORKDIR /app

COPY pyproject.toml poetry.lock ./
RUN pip install poetry && \
poetry install --without dev --no-root && \
rm -rf ~/.cache/
RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --no-install-project

COPY sachi sachi
COPY README.md .
RUN poetry install --only-root

ENV EDITOR=nvim
ENTRYPOINT [ "poetry", "run", "sachi" ]
RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev

ENV PATH="/app/.venv/bin:$PATH"

ENTRYPOINT [ "sachi" ]
VOLUME [ "/root/.config/sachi" ]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Sachi is a TV Series and Movie TUI renamer made with [Textual](https://github.co

## Getting Started

**Requirements:** Python 3.12 and [mediainfo](https://mediaarea.net/en/MediaInfo)
**Requirements:** [uv](https://github.com/astral-sh/uv) and [mediainfo](https://mediaarea.net/en/MediaInfo)

<p>
<a href="https://pypi.org/project/sachi" alt="Python version compatibility">
Expand All @@ -16,7 +16,7 @@ Sachi is a TV Series and Movie TUI renamer made with [Textual](https://github.co
</p>

```sh
pipx run sachi --help
uvx sachi --help
```

Or, with Docker:
Expand Down
17 changes: 0 additions & 17 deletions bump.sh

This file was deleted.

1,521 changes: 0 additions & 1,521 deletions poetry.lock

This file was deleted.

50 changes: 21 additions & 29 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
[tool.poetry]
[project]
name = "sachi"
version = "0.2.2-dev"
description = "Terminal media files renamer (FileBot alternative)"
authors = ["NextFire <[email protected]>"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/NextFire/sachi"
requires-python = ">=3.12,<3.13"
dependencies = [
"typer==0.12.5",
"textual==0.82.0",
"tomlkit==0.13.2",
"pydantic==2.9.2",
"aiohttp[speedups]==3.10.9",
"yarl==1.13.1",
"backoff==2.2.1",
"jinja2==3.1.4",
"pymediainfo==6.1.0",
"guessit==3.8.0",
"setuptools==75.1.0", # guessit
]

[tool.poetry.scripts]
sachi = "sachi:cli_app"

[tool.poetry.dependencies]
python = "~3.12"
typer = "0.12.5"
textual = "0.82.0"
tomlkit = "0.13.2"
pydantic = "2.9.2"
aiohttp = { version = "3.10.9", extras = ["speedups"] }
yarl = "1.13.1"
backoff = "2.2.1"
jinja2 = "3.1.4"
pymediainfo = "6.1.0"
guessit = "3.8.0"
setuptools = { version = "75.1.0", markers = "python_version >= '3.12'" } # guessit
[tool.uv]
dev-dependencies = ["pyright==1.1.383", "ruff==0.6.9", "textual-dev==1.6.1"]

[tool.poetry.group.dev.dependencies]
pyright = "1.1.383"
ruff = "0.6.9"
textual-dev = "1.6.1"
[project.scripts]
sachi = "sachi:cli_app"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.ruff]
target-version = "py312"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.ruff.lint]
extend-select = ["I"]
Loading

0 comments on commit b7a0ffe

Please sign in to comment.