Skip to content

Commit 3f891be

Browse files
committed
docker
1 parent 8a080a5 commit 3f891be

File tree

4 files changed

+80
-13
lines changed

4 files changed

+80
-13
lines changed

scripts/Dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
FROM debian:bookworm
2+
3+
RUN apt-get update && \
4+
apt-get upgrade -y && \
5+
apt-get install -y vim curl wget sudo && \
6+
apt-get install -y build-essential cmake gdb python3-full && \
7+
apt-get install -y clang llvm
8+
9+
# dependency for some puzzles
10+
RUN apt-get install -y z3
11+
12+
# to compile Python 3.x
13+
RUN apt-get install -y libssl-dev liblzma-dev
14+
15+
# seems to be mandatory to compile Python 3.13
16+
RUN apt-get install -y libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
17+
18+
# required to build shapely and numpy, if needed
19+
RUN apt-get install -y libgeos-dev libopenblas-dev
20+
21+
# Rust
22+
ENV CARGO_HOME /usr/local/cargo
23+
ENV RUSTUP_HOME /usr/local/rustup
24+
ENV PATH "/usr/local/cargo/bin:$PATH"
25+
26+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
27+
rustup component add rust-src && \
28+
chmod 777 /usr/local/cargo
29+
30+
# PyPy
31+
RUN curl -sL https://downloads.python.org/pypy/pypy3.10-v7.3.15-linux64.tar.bz2 | tar -C /opt -xj && \
32+
/opt/pypy3.10-v7.3.15-linux64/bin/pypy3 -mensurepip
33+
34+
# Python 3.10 → 3.13
35+
COPY allpython.sh /
36+
RUN /allpython.sh
37+
38+
# Virtual Environments
39+
COPY requirements.txt /
40+
RUN /opt/python/Python-3.10.13/bin/python3.10 -mvenv /venv/py3.10
41+
RUN /opt/python/Python-3.11.7/bin/python3.11 -mvenv /venv/py3.11
42+
RUN /opt/python/Python-3.12.1/bin/python3.12 -mvenv /venv/py3.12
43+
RUN /opt/python/Python-3.13.0a3/bin/python3.13 -mvenv /venv/py3.13
44+
RUN /opt/pypy3.10-v7.3.15-linux64/bin/pypy3.10 -mvenv /venv/pypy3.10
45+
RUN python3 -mvenv /venv/python
46+
47+
# User environment
48+
ARG HOST_U=1027
49+
ARG HOST_G=100
50+
ARG HOST_UN=user
51+
RUN useradd --create-home --no-user-group -g $HOST_G -u $HOST_U $HOST_UN
52+
RUN echo "$HOST_UN ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
53+
RUN echo 'export SHELL=/bin/bash' >> /etc/bash.bashrc
54+
RUN echo 'alias ll="ls -l --color"' >> /etc/bash.bashrc
55+
56+
57+
# WORKDIR /advent-of-rust
58+
# RUN curl -sfL https://github.com/rene-d/advent-of-rust/tarball/refs/heads/main | tar -xz --strip-components=1
59+
# RUN ln -s /venv .venv
60+
# RUN ln -s /data data
61+
# VOLUME /data

scripts/allpython.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -euo pipefail
44

55
script_dir=$(realpath $(dirname $0))
66

7+
mkdir -p /opt/python
8+
79
i()
810
{
911
local v=$1
@@ -15,22 +17,24 @@ i()
1517
rm -rf /tmp/Python-$v /opt/python/Python-$v
1618
curl -sL $url | tar -C /tmp -xJ
1719
cd /tmp/Python-$v
18-
./configure --prefix=/opt/python/Python-$v --enable-optimizations --disable-test-modules
20+
./configure --prefix=/opt/python/Python-$v --enable-optimizations
1921
make -j$(nproc --ignore=1)
2022
make altinstall
2123
# /opt/python/Python-$v/bin/python$m -mensurepip
2224
cd /tmp
2325
rm -rf /tmp/Python-$v
2426

25-
$script_dir/runall.py --venv /opt/python/Python-$v/bin/python$m
27+
if [ -f $script_dir/runall.py ] ; then
28+
$script_dir/runall.py --venv /opt/python/Python-$v/bin/python$m
29+
fi
2630
}
2731

2832
a()
2933
{
3034
i 3.10.13
31-
i 3.11.6
35+
i 3.11.7
3236
i 3.12.1
33-
# i 3.13.0a3
37+
i 3.13.0a3
3438
}
3539

3640
if [ ${1-} ]; then

scripts/debian-packages.txt

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

scripts/runall.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def run(
137137
interpreter: t.Union[None, str],
138138
file: Path,
139139
solution: t.List,
140+
nb_expected: int,
140141
warmup: bool,
141142
) -> t.Dict[str, t.Any]:
142143
if not prog.is_file():
@@ -157,7 +158,10 @@ def run(
157158
start = time.time_ns()
158159
out = subprocess.run(cmd, stdout=subprocess.PIPE)
159160
elapsed = time.time_ns() - start
160-
answers = " ".join(out.stdout.decode().strip().split("\n"))
161+
162+
answers = out.stdout.decode().strip().split("\n")
163+
nb_answers = len(answers)
164+
answers = " ".join(answers)
161165

162166
status = "unknown"
163167
if solution:
@@ -170,7 +174,10 @@ def run(
170174
if answers == "":
171175
status = "missing"
172176
else:
173-
status = "unknown"
177+
if nb_answers != nb_expected:
178+
status = "error"
179+
else:
180+
status = "unknown"
174181

175182
result = {"elapsed": elapsed, "status": status, "answers": answers}
176183

@@ -318,7 +325,8 @@ def run_day(
318325
in_cache = e is not None
319326

320327
if not in_cache and not dry_run:
321-
e = run(prog, lang, interpreter, file, day_sols.get(crc), warmup[lang])
328+
nb_expected = 2 if day <= 24 else 1
329+
e = run(prog, lang, interpreter, file, day_sols.get(crc), nb_expected, warmup[lang])
322330

323331
if e:
324332
warmup[lang] = False

0 commit comments

Comments
 (0)