Skip to content

Commit 7053c28

Browse files
committed
minor changes
1 parent 3a9f448 commit 7053c28

File tree

2 files changed

+53
-45
lines changed

2 files changed

+53
-45
lines changed

scripts/all_python.sh

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,38 @@ fi
1010
scripts_dir=$(realpath $(dirname $0))
1111

1212
versions=(
13-
# 3.10
1413
3.11
1514
3.12
1615
3.13
17-
# 3.13t
1816
3.14
19-
# 3.14t
2017
)
2118

22-
for v in ${versions[*]}; do
23-
venv=${AOC_TARGET_DIR:-target}/venv/py$v
24-
uv python install $v
25-
uv venv -p $v --managed-python --clear $venv
26-
VIRTUAL_ENV=$venv uv pip install -r $scripts_dir/requirements.txt
27-
done
19+
function inst_py()
20+
{
21+
local version=$1
22+
if [[ $version == "system" ]] ; then
23+
if command -v /usr/bin/python3 >/dev/null \
24+
&& [[ $(/usr/bin/python3 -c "import sys;print(sys.hexversion>=0x30A0000)") == "True" ]]
25+
then
26+
venv=${AOC_TARGET_DIR:-target}/venv/python
27+
uv venv -p /usr/bin/python3 --clear $venv
28+
VIRTUAL_ENV=$venv uv pip install -r $scripts_dir/requirements.txt
29+
else
30+
echo "$(/usr/bin/python3 -V) is too old."
31+
fi
32+
else
33+
local venv=${AOC_TARGET_DIR:-target}/venv/py$version
34+
uv python install $version
35+
uv venv -p $version --managed-python --clear $venv
36+
VIRTUAL_ENV=$venv uv pip install -r $scripts_dir/requirements.txt
37+
fi
38+
}
39+
2840

29-
if command -v /usr/bin/python3 >/dev/null ; then
30-
venv=${AOC_TARGET_DIR:-target}/venv/python
31-
uv venv -p /usr/bin/python3 --clear $venv
32-
VIRTUAL_ENV=$venv uv pip install -r $scripts_dir/requirements.txt
41+
if [[ $# == 0 ]] ; then
42+
set -- ${versions[*]}
3343
fi
44+
45+
for version ; do
46+
inst_py $version
47+
done

scripts/runall.py

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
CR = "\r"
3636
TRANSIENT = f"{CLEAR_EOL}{CR}"
3737

38-
TERMINAL_COLS = 96
39-
4038

4139
@lru_cache(maxsize=None)
4240
def aoc_available_puzzles(
@@ -491,12 +489,13 @@ def run_day(
491489
year: int,
492490
day: int,
493491
mday: str,
494-
day_inputs: t.Dict,
495-
day_answers: t.Dict,
492+
day_inputs: dict,
493+
day_answers: dict,
496494
languages: dict,
497-
problems: t.Set,
495+
problems: list[str],
498496
refresh: bool,
499497
dry_run: bool,
498+
terminal_columns: int,
500499
):
501500
elapsed = defaultdict(list)
502501

@@ -549,23 +548,20 @@ def run_day(
549548
continue
550549

551550
if (e["status"] == "unknown" and day_answers.get(crc)) or e["status"] in ("error", "failed"):
552-
script = Path(f"resolve_{e['status']}.sh")
551+
resolve_script = Path(f"resolve_{e['status']}.sh")
553552
if "AOC_TARGET_DIR" in os.environ:
554-
script = Path(os.environ["AOC_TARGET_DIR"]) / script
553+
resolve_script = Path(os.environ["AOC_TARGET_DIR"]) / resolve_script
555554

556-
if not globals().get(script):
557-
with script.open("wt") as f:
555+
if not globals().get(resolve_script):
556+
with resolve_script.open("wt") as f:
558557
print("#!/bin/sh", file=f)
559-
script.chmod(0o755)
560-
globals()[script] = True
558+
resolve_script.chmod(0o755)
559+
globals()[resolve_script] = True
561560

562-
with script.open("at") as f:
561+
with resolve_script.open("at") as f:
563562
print(f"{__file__} --no-build -u {input_name} -l {lang} -r {year} {day}", file=f)
564563

565-
if e["status"] != "ok":
566-
info = f" {file}"
567-
else:
568-
info = ""
564+
answers = e["answers"]
569565

570566
status_color = {
571567
"ok": GREEN,
@@ -574,22 +570,21 @@ def run_day(
574570
"error": RED,
575571
}[e["status"]]
576572

577-
answers = e["answers"]
578-
579573
line = (
580574
f"{CR}{RESET}{CLEAR_EOL}"
581575
f"{prefix}"
582576
f" {YELLOW}{lang:<7}{RESET}:"
583577
f" {status_color}{e['status']:7}{RESET}"
584578
f" {WHITE}{e['elapsed'] / 1e9:7.3f}s"
585579
f" {GRAY}{'☽' if in_cache else ' '}"
586-
f" {status_color}{str(answers):<50}{RESET}"
587-
f" {FEINT}{file}{RESET}"
588580
)
589-
if TERMINAL_COLS >= 130:
590-
print(line, info)
591-
else:
581+
582+
if terminal_columns < 60:
592583
print(line)
584+
elif terminal_columns < 130:
585+
print(line, f"{status_color}{str(answers)}{RESET}")
586+
else:
587+
print(line, f" {status_color}{str(answers):<50}{RESET} {FEINT}{file}{RESET}")
593588

594589
if e["status"] in ("error", "failed"):
595590
problems.append(line)
@@ -598,10 +593,10 @@ def run_day(
598593

599594
elapsed[lang].append(e["elapsed"] / 1e9)
600595

601-
if len(results) > 1:
602-
line = f"{prefix} {RED}{BLINK}MISMATCH BETWEEN SOLUTIONS{RESET}"
603-
print(line)
604-
problems.append(line)
596+
# if len(results) > 1:
597+
# line = f"{prefix} {RED}{BLINK}MISMATCH BETWEEN SOLUTIONS{RESET}"
598+
# print(line)
599+
# problems.append(line)
605600

606601
nb_samples = set(len(t) for _, t in elapsed.items())
607602
assert len(nb_samples) == 1 or len(nb_samples) == 0
@@ -794,10 +789,7 @@ def main():
794789
CR = ""
795790

796791
# the terminal size
797-
cols = subprocess.getoutput("tput cols")
798-
if cols.isdigit():
799-
global TERMINAL_COLS
800-
TERMINAL_COLS = int(cols)
792+
terminal_columns = os.get_terminal_size().columns
801793

802794
if args.working_dir and args.working_dir.is_dir():
803795
logging.debug(f"set working directory to: {args.working_dir}")
@@ -886,12 +878,13 @@ def main():
886878
for mday in day_solutions:
887879
if prev_shown_year != year:
888880
if prev_shown_year != 0:
889-
print(
881+
line = (
890882
"==========================" # prefix
891883
" ===========================" # language, status
892884
" ==================================================" # answers
893885
" ==================================" # input path
894886
)
887+
print(line[: terminal_columns - 1])
895888
prev_shown_year = year
896889

897890
mday = mday.name.removeprefix("day")
@@ -906,6 +899,7 @@ def main():
906899
problems,
907900
args.refresh,
908901
args.dry_run,
902+
terminal_columns,
909903
)
910904

911905
if elapsed:

0 commit comments

Comments
 (0)