chore: migrate from pipenv to uv and update Dockerfile & update to Python 3.13

This commit is contained in:
mhdzumair
2025-03-01 08:58:22 +05:30
parent 860c1e3d9e
commit de5dd555c0
8 changed files with 2690 additions and 3455 deletions
+10 -1
View File
@@ -45,4 +45,13 @@ mediafusion.local*
.git
kodi/
!kodi/*.py
!deployment/startup.sh
!deployment/startup.sh
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
+2
View File
@@ -56,6 +56,8 @@ endif
@sed -i 's|image: $(DOCKER_REPO)/$(IMAGE_NAME):[0-9.]*|image: $(DOCKER_REPO)/$(IMAGE_NAME):$(VERSION_NEW)|g' deployment/docker-compose/docker-compose-minimal.yml
# Update k8s deployment
@sed -i 's|image: $(DOCKER_REPO)/$(IMAGE_NAME):[0-9.]*|image: $(DOCKER_REPO)/$(IMAGE_NAME):$(VERSION_NEW)|g' deployment/k8s/local-deployment.yaml
# Update pyproject.toml
@sed -i -e "s/version = \"[0-9.]*\"/version = \"$(VERSION_NEW)\"/" pyproject.toml
@echo "Version updated to $(VERSION_NEW) in all files"
build-multi:
-61
View File
@@ -1,61 +0,0 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
fastapi = "*"
uvicorn = { extras = ["standard"] }
pydantic = "*"
requests = "*"
beautifulsoup4 = "*"
beanie = "*"
motor = "*"
pymongo = "*"
dnspython = "*"
jinja2 = "*"
apscheduler = "*"
python-dateutil = "*"
bencodepy = "*"
pydantic-settings = "*"
pycryptodome = "*"
pillow = "*"
httpx = "*"
uvloop = { markers = "sys_platform != 'win32'" }
thefuzz = "*"
pikpakapi = {git = "git+https://github.com/mhdzumair/PikPakAPI.git"}
diskcache = "*"
demagnetize = "*"
redis = {extras = ["hiredis"] }
dramatiq = {extras = ["redis", "watch"] }
gunicorn = "*"
scrapy = "*"
aioqbt = {git = "git+https://github.com/mhdzumair/aioqbt.git"}
aiowebdav = "*"
m3u-ipytv = "*"
python-multipart = "*"
prometheus-client = "*"
pyasynctracker = "*"
humanize = {git = "git+https://github.com/python-humanize/humanize.git"}
scrapy-playwright = "*"
cinemagoerng = {git = "git+https://github.com/mhdzumair/cinemagoerng.git"}
tqdm = "*"
parsett = "*"
tenacity = "*"
ratelimit = "*"
qrcode = "*"
aioseedrcc = "*"
pytz = "*"
aiohttp-socks = "*"
socksio = "*"
dramatiq-abort = "*"
tzdata = "*"
ipython = "*"
[dev-packages]
pysocks = "*"
requests-cache = "*"
kodistubs = "*"
[requires]
python_version = "3.12"
Generated
-3375
View File
File diff suppressed because it is too large Load Diff
+17 -16
View File
@@ -1,10 +1,10 @@
FROM python:3.12-slim-bookworm AS builder
FROM python:3.13-slim-bookworm AS builder
WORKDIR /mediafusion
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends git curl && \
apt-get install -y --no-install-recommends git curl build-essential && \
pip install --upgrade pip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
@@ -18,37 +18,38 @@ USER mediafusion
# Set the PATH environment variable to include the local bin directory
ENV PATH="/home/mediafusion/.local/bin:$PATH"
ENV PYTHONUNBUFFERED=1
# Install pipenv and Python dependencies
COPY --chown=mediafusion:mediafusion Pipfile Pipfile.lock ./
RUN pip install --user pipenv && \
pipenv install --deploy --ignore-pipfile
# Install uv and Python dependencies
COPY --from=ghcr.io/astral-sh/uv:0.6.3 /uv /uvx /bin/
RUN --mount=type=cache,target=/mediafusion/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project --compile-bytecode
FROM python:3.12-slim-bookworm
FROM python:3.13-slim-bookworm AS runtime
ARG VERSION
WORKDIR /mediafusion
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create the mediafusion user with a specified home directory
RUN groupadd -r mediafusion && \
useradd --no-log-init -r -g mediafusion -m -d /home/mediafusion mediafusion
# Copy the Python environment and other necessary files from the builder stage
COPY --from=builder /home/mediafusion/.local /home/mediafusion/.local
COPY --from=builder /etc/group /etc/passwd /etc/
ENV PATH="/home/mediafusion/.local/bin:$PATH"
COPY --from=builder --chown=mediafusion:mediafusion /mediafusion/.venv /mediafusion/.venv
ENV PATH="/mediafusion/.venv/bin:$PATH"
ENV VERSION=${VERSION}
COPY . .
# set folder permissions
RUN chown -R mediafusion:mediafusion /mediafusion
COPY --chown=mediafusion:mediafusion . /mediafusion
USER mediafusion
+2 -2
View File
@@ -1,7 +1,7 @@
#!/bin/bash
echo "Running Beanie migrations..."
pipenv run beanie migrate -uri "${MONGO_URI:-$mongo_uri}" -db mediafusion -p migrations/
beanie migrate -uri "${MONGO_URI:-$mongo_uri}" -db mediafusion -p migrations/
echo "Starting FastAPI server..."
pipenv run gunicorn api.main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 --timeout 120 --max-requests 500 --max-requests-jitter 200
gunicorn api.main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 --timeout 120 --max-requests 500 --max-requests-jitter 200
+74
View File
@@ -0,0 +1,74 @@
[project]
name = "mediafusion"
version = "4.3.23"
description = "Media Fusion Add-On For Stremio & Kodi - A powerful streaming API with support for multiple providers and advanced scraping capabilities"
readme = "README.md"
requires-python = ">=3.12"
license = "MIT"
authors = [
{ name = "Mohamed Zumair", email = "mhdzumair@gmail.com" },
{ name = "ragmehos" }
]
dependencies = [
"fastapi",
"uvicorn[standard]",
"pydantic",
"requests",
"beautifulsoup4",
"beanie",
"motor",
"pymongo",
"dnspython",
"jinja2",
"apscheduler",
"python-dateutil",
"bencodepy",
"pydantic-settings",
"pycryptodome",
"pillow",
"httpx",
"uvloop; sys_platform != \"win32\"",
"thefuzz",
"pikpakapi",
"diskcache",
"demagnetize",
"redis[hiredis]",
"dramatiq[redis,watch]",
"gunicorn",
"scrapy",
"aioqbt",
"aiowebdav",
"m3u-ipytv",
"python-multipart",
"prometheus-client",
"pyasynctracker",
"scrapy-playwright",
"cinemagoerng",
"tqdm",
"parsett",
"tenacity",
"ratelimit",
"qrcode",
"aioseedrcc",
"pytz",
"aiohttp-socks",
"socksio",
"dramatiq-abort",
"tzdata",
"ipython",
"scrapy-fake-useragent>=1.4.4",
"humanize>=4.12.1",
]
[dependency-groups]
dev = [
"pysocks",
"requests-cache",
"kodistubs",
]
[tool.uv.sources]
pikpakapi = {git = "git+https://github.com/mhdzumair/PikPakAPI.git"}
aioqbt = {git = "git+https://github.com/mhdzumair/aioqbt.git"}
cinemagoerng = {git = "git+https://github.com/mhdzumair/cinemagoerng.git"}
Generated
+2585
View File
File diff suppressed because it is too large Load Diff