Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 6eebcd9

Browse files
PyPy
resolved #63
1 parent 9084982 commit 6eebcd9

File tree

3 files changed

+42
-35
lines changed

3 files changed

+42
-35
lines changed

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ run-client:
77
craftos --id 2828 --exec "shell.run('clear') shell.run('youcube')" --mount-ro /=./client
88

99
docker-build:
10-
docker build -t youcube:1.0.0 -t youcube:latest server/.
10+
docker build -t youcube:latest server/.
1111

1212
illuaminate-lint:
1313
illuaminate lint

Diff for: server/Dockerfile

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
11
# TODO: change from ffmpeg 5.1+ to yt-dlp/FFmpeg
2-
FROM jrottenberg/ffmpeg:5.1-alpine as ffmpeg
2+
FROM jrottenberg/ffmpeg:5.1-alpine AS ffmpeg
33

4-
FROM alpine:latest as sanjuuni
4+
FROM alpine:3.17.0 as sanjuuni
55

66
# TODO: use the same ffmpeg for sanjuuni
7-
RUN set -x \
8-
&& apk add --no-cache --update git g++ zlib-dev poco-dev make ffmpeg-dev \
9-
&& git clone https://github.com/MCJack123/sanjuuni.git
7+
RUN set -eux; \
8+
apk add --no-cache --update g++ zlib-dev poco-dev make ffmpeg-dev; \
9+
wget -O sanjuuni.tar.gz https://github.com/MCJack123/sanjuuni/archive/30dcabb4b56f1eb32c88e1bce384b0898367ebda.tar.gz; \
10+
echo "029eb0e8853eccc74ea328bb5933678e60e2c56f03f321bf5f982643768b2877 *sanjuuni.tar.gz" | sha256sum -c -; \
11+
mkdir -p sanjuuni; \
12+
tar -xC sanjuuni --strip-components=1 -f sanjuuni.tar.gz; \
13+
rm sanjuuni.tar.gz;
1014

1115
WORKDIR /sanjuuni
1216

13-
RUN set -x \
14-
&& ./configure \
15-
&& make
17+
RUN set -eux; \
18+
./configure; \
19+
make
1620

17-
FROM alpine:latest AS builder
21+
FROM ghcr.io/commandcracker/alpine-pypy3.9-pip:3.17.0-pypy-7.3.10-pip-22.3.1 AS builder
1822

1923
COPY requirements.txt .
2024
COPY youcube ./youcube
2125
COPY compile.py .
2226

23-
ENV \
24-
# Make sure we use the virtualenv:
25-
PATH="/opt/venv/bin:$PATH"
26-
27-
RUN set -x \
28-
&& apk add --no-cache --update python3 py3-pip gcc libc-dev \
29-
# Create virtualenv
30-
&& python3 -m venv /opt/venv \
31-
&& pip install --no-cache-dir --upgrade pip \
32-
&& pip install --no-cache-dir --use-pep517 -r requirements.txt \
33-
&& python3 compile.py
27+
RUN set -eux; \
28+
apk add --no-cache --update gcc libc-dev libstdc++-dev; \
29+
pip install --no-cache-dir --use-pep517 -r requirements.txt; \
30+
python3 compile.py; \
31+
pip uninstall pip -y
3432

35-
FROM alpine:latest
33+
FROM alpine:3.17.0
3634

3735
WORKDIR /opt/server
3836

39-
RUN set -x \
40-
&& apk add --no-cache --update python3 \
37+
RUN set -eux; \
38+
apk add --no-cache --update \
39+
# pypy requirements
40+
libffi libbz2 \
4141
# ffmpeg requirements
4242
libgcc libstdc++ ca-certificates libcrypto1.1 libssl1.1 libgomp expat \
4343
# sanjuuni requirements
44-
poco \
45-
&& chown 1000 /opt/server/
44+
poco; \
45+
chown 1000 /opt/server/
4646

47-
COPY --from=builder /opt/venv /opt/venv
47+
COPY --from=builder /opt/pypy /opt/pypy
4848
# add ffmpeg
4949
COPY --from=ffmpeg /usr/local /usr/local
5050
# add sanjuuni
5151
COPY --from=sanjuuni /sanjuuni/sanjuuni /usr/local/bin
5252

5353
ENV \
5454
# Make sure we use the virtualenv:
55-
PATH="/opt/venv/bin:$PATH" \
55+
PATH="/opt/pypy/bin:$PATH" \
5656
# Use ffmpeg libs
5757
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 \
5858
# yt-dlp cache dir

Diff for: server/youcube/youcube.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
from json.decoder import JSONDecodeError
1313
from logging import Logger
1414
from asyncio import get_event_loop
15-
from typing import Callable, Union
15+
from typing import (
16+
Callable,
17+
Union,
18+
Tuple,
19+
Type,
20+
List,
21+
Any
22+
)
1623
from base64 import b64encode
1724
from shutil import which
1825

@@ -67,7 +74,7 @@
6774
# pylint: disable=multiple-statements
6875

6976

70-
def get_vid(vid_file: str, tracker: int) -> list[str]:
77+
def get_vid(vid_file: str, tracker: int) -> List[str]:
7178
"""
7279
Returns given line of 32vid file
7380
"""
@@ -137,14 +144,14 @@ def get_client_ip(request: Request, trusted_proxies: list) -> str:
137144

138145
def assert_resp(
139146
__obj_name: str,
140-
__obj: object,
147+
__obj: Any,
141148
__class_or_tuple: Union[
142-
type, UnionType,
143-
tuple[
149+
Type, UnionType,
150+
Tuple[
144151
Union[
145-
type,
152+
Type,
146153
UnionType,
147-
tuple[object, ...]
154+
Tuple[Any, ...]
148155
],
149156
...
150157
]

0 commit comments

Comments
 (0)