kjbytes commited on
Commit
048a108
·
1 Parent(s): 1429832
Files changed (2) hide show
  1. Dockerfile +16 -3
  2. requirements.txt +0 -1
Dockerfile CHANGED
@@ -1,16 +1,29 @@
1
  FROM python:3.11-slim
2
 
3
- RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg git \
 
4
  && rm -rf /var/lib/apt/lists/*
5
 
6
  # HF Spaces runs as uid 1000; HF_HOME must be writable for model downloads.
7
  RUN useradd -m -u 1000 user
8
- ENV HOME=/home/user HF_HOME=/home/user/.cache/huggingface OUT_DIR=/home/user/audio
 
 
9
  USER user
10
  WORKDIR /home/user/app
11
 
12
  COPY --chown=user requirements.txt .
13
- RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
 
 
 
 
 
 
14
 
15
  COPY --chown=user app.py .
16
 
 
1
  FROM python:3.11-slim
2
 
3
+ # build-essential is needed because pkuseg has no wheel past cp37 and compiles from source.
4
+ RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg git build-essential \
5
  && rm -rf /var/lib/apt/lists/*
6
 
7
  # HF Spaces runs as uid 1000; HF_HOME must be writable for model downloads.
8
  RUN useradd -m -u 1000 user
9
+ # PATH: pip installs to ~/.local as non-root, so its bin dir must be on PATH.
10
+ ENV HOME=/home/user HF_HOME=/home/user/.cache/huggingface OUT_DIR=/home/user/audio \
11
+ PATH=/home/user/.local/bin:$PATH
12
  USER user
13
  WORKDIR /home/user/app
14
 
15
  COPY --chown=user requirements.txt .
16
+ # pkuseg 0.0.25 has no wheel past cp37 and its sdist won't build as-is on modern Python:
17
+ # 1. setup.py imports numpy at build time, which pip's build isolation hides.
18
+ # 2. it ships a Cython-0.28-era inference.cpp (uses the removed tp_print) and skips
19
+ # cythonizing when that file exists -- so delete it and let the .pyx regenerate.
20
+ RUN pip install --no-cache-dir "numpy<2" "cython<3" setuptools wheel \
21
+ && pip download --no-binary :all: --no-deps --no-build-isolation pkuseg==0.0.25 -d /tmp/pk \
22
+ && tar -xzf /tmp/pk/pkuseg-0.0.25.tar.gz -C /tmp/pk \
23
+ && rm /tmp/pk/pkuseg-0.0.25/pkuseg/inference.cpp \
24
+ && pip install --no-cache-dir --no-build-isolation /tmp/pk/pkuseg-0.0.25 \
25
+ && rm -rf /tmp/pk \
26
+ && pip install --no-cache-dir -r requirements.txt
27
 
28
  COPY --chown=user app.py .
29
 
requirements.txt CHANGED
@@ -4,4 +4,3 @@ torchaudio==2.6.0+cpu
4
  fastapi==0.115.6
5
  uvicorn[standard]==0.34.0
6
  chatterbox-tts==0.1.4
7
- numpy==1.26.5
 
4
  fastapi==0.115.6
5
  uvicorn[standard]==0.34.0
6
  chatterbox-tts==0.1.4