Skip to content

Commit 83657cb

Browse files
committed
Migrate to uv and Python 3.14
1 parent f0c1eee commit 83657cb

9 files changed

Lines changed: 1205 additions & 24 deletions

File tree

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.git
2+
.cache
3+
.config
4+
.idea
5+
.local
6+
.nicegui
7+
.uv-cache
8+
.uv-python
9+
.venv
10+
__pycache__
11+
config.json
12+
.gitconfig

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55
.nicegui
66
config.json
77
__pycache__
8-
.gitconfig
8+
.gitconfig
9+
.uv-cache
10+
.uv-python
11+
.venv

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.14

Dockerfile

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,47 @@
1-
FROM python:3.10-slim
1+
FROM ghcr.io/astral-sh/uv:python3.14-trixie-slim
22

3+
# Setup a non-root user
4+
RUN groupadd --system --gid 999 nonroot \
5+
&& useradd --system --gid 999 --uid 999 --create-home nonroot
6+
7+
# Install the project into `/app`
8+
WORKDIR /app
9+
10+
# Keeps Python from buffering stdout and stderr to avoid situations where
11+
# the application crashes without emitting any logs due to buffering.
312
ENV PYTHONUNBUFFERED=1
413

5-
RUN pip install --upgrade pip
14+
# Enable bytecode compilation
15+
ENV UV_COMPILE_BYTECODE=1
616

7-
WORKDIR /app
17+
# Copy from the cache instead of linking since it's a mounted volume
18+
ENV UV_LINK_MODE=copy
19+
20+
# Omit development dependencies
21+
ENV UV_NO_DEV=1
22+
23+
# Ensure installed tools can be executed out of the box
24+
ENV UV_TOOL_BIN_DIR=/usr/local/bin
25+
26+
# Install the project's dependencies using the lockfile and settings
27+
RUN --mount=type=cache,target=/root/.cache/uv \
28+
--mount=type=bind,source=uv.lock,target=uv.lock \
29+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
30+
uv sync --locked --no-install-project
831

9-
COPY requirements.txt .
10-
RUN pip install --no-cache-dir -r requirements.txt
32+
# Then, add the rest of the project source code and install it
33+
# Installing separately from its dependencies allows optimal layer caching
34+
COPY . /app
35+
RUN --mount=type=cache,target=/root/.cache/uv \
36+
uv sync --locked
1137

12-
COPY . .
38+
# Place executables in the environment at the front of the path
39+
ENV PATH="/app/.venv/bin:$PATH"
1340

14-
EXPOSE 8766
41+
# Reset the entrypoint, don't invoke `uv`
42+
ENTRYPOINT []
1543

16-
ENV IS_DOCKER=1
44+
# Use the non-root user to run our application
45+
USER nonroot
1746

18-
CMD ["python", "__main__.py"]
47+
CMD ["uv", "run", "python", "__main__.py"]

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ Uses [Python-PlexAPI](https://github.com/pkkid/python-plexapi) and [NiceGUI](htt
99
## Requirements
1010

1111
- Should work on any Linux (tested on Debian 11), may work on Windows
12-
- Python 3.9+
12+
- Python 3.14
13+
- [uv](https://docs.astral.sh/uv/)
1314

1415
## Features
1516

@@ -39,8 +40,8 @@ You can also find it in your `Preferences.xml` file under the name `ProcessedMac
3940
```bash
4041
git clone https://github.com/zdimension/plexdlweb
4142
cd plexdlweb
42-
pip3 install -r requirements.txt
43-
python3 __main__.py # will generate a config.json file, edit it and start again
43+
uv sync
44+
uv run python __main__.py # will generate a config.json file, edit it and start again
4445
```
4546

4647
### Systemd service
@@ -53,9 +54,9 @@ useradd -d $(pwd) plexdlweb
5354
git clone https://github.com/zdimension/plexdlweb .
5455
chown -R plexdlweb .
5556

56-
sudo -u plexdlweb sh -c "pip3 install -r requirements.txt && python3 __main__.py"
57+
sudo -u plexdlweb sh -c "uv sync && uv run python __main__.py"
5758
nano config.json # edit config here
58-
sudo -u plexdlweb python3 __main__.py # make sure it works before setting up the service
59+
sudo -u plexdlweb uv run python __main__.py # make sure it works before setting up the service
5960

6061
sed -i "s%{PATH}%$(pwd)%g" plexdlweb.service
6162
chown root plexdlweb.service
@@ -89,7 +90,7 @@ docker build -t plexdlweb .
8990

9091
## Updating
9192

92-
As mentioned, an update system is planned. In the meantime, just `git pull` and restart the service.
93+
As mentioned, an update system is planned. In the meantime, just `git pull`, run `uv sync --frozen`, and restart the service.
9394

9495
## Troubleshooting large downloads
9596

plexdlweb.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Restart=always
1010
RestartSec=1
1111
User=plexdlweb
1212
WorkingDirectory={PATH}
13-
ExecStart=/usr/bin/python3 {PATH}/__main__.py
13+
ExecStart={PATH}/.venv/bin/python {PATH}/__main__.py
1414

1515
[Install]
16-
WantedBy=multi-user.target
16+
WantedBy=multi-user.target

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[project]
2+
name = "plexdlweb"
3+
version = "0.1.0"
4+
description = "A simple web UI for downloading media from Plex without the Plex Pass."
5+
readme = "README.md"
6+
requires-python = ">=3.14"
7+
dependencies = [
8+
"dataclasses-json",
9+
"humanize",
10+
"httpcore>=1.0.0",
11+
"httpx",
12+
"nicegui>=2.9.0",
13+
"plexapi>=4.15",
14+
]
15+
16+
[tool.uv]
17+
package = false

requirements.txt

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

uv.lock

Lines changed: 1124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)