Skip to content

Commit 17524e2

Browse files
authored
update (#20)
* update * update to py3.12 * update to py3.12
1 parent 93f45e4 commit 17524e2

32 files changed

+400
-173
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Project-specific conventions and gotchas (be precise):
3737

3838
- Zero-padding is significant: day files and input files are named with two-digit zero padding (e.g., `day_01.py``01.dat`). `run_day.py` zero-pads the provided `--day` argument.
3939
- `run_all_solutions.py` relies on simple `os.listdir` ordering; do not assume nested directories beyond `src/advent_of_code/year_<YYYY>/`.
40-
- The repo uses `python3` in scripts; local development should use a Python 3.8+ interpreter (pyproject says >=3.8). Black config targets Python 3.9 but code is compatible with 3.8+.
40+
- The repo uses `python3` in scripts; local development should use a Python 3.8+ interpreter (pyproject says >=3.8). Black config targets Python 3.12 but code is compatible with 3.8+.
4141
- Tests import the package from `src/` via pytest config. When editing tests or modules, ensure the module path `advent_of_code.year_<YYYY>.day_<NN>` is importable.
4242

4343
Small implementation checklist for a new/updated day module:

.github/workflows/orchestrator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
python-version: ["3.9"]
12+
python-version: ["3.12"]
1313

1414
steps:
1515
- uses: actions/checkout@v3

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.9
1+
FROM python:3.12
22

33
RUN mkdir -p /usr/src/app
44

pyproject.toml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ authors = [
66
]
77
description = "Code for Advent of Code 2023"
88
readme = "README.md"
9-
requires-python = ">=3.8"
9+
requires-python = ">=3.12,<4"
1010
classifiers = [
1111
"Programming Language :: Python :: 3",
1212
"License :: OSI Approved :: MIT License",
1313
"Operating System :: OS Independent",
1414
]
15+
dependencies = [
16+
"numpy==1.26.2",
17+
"pytest==7.4.3",
18+
"ruff>=0.14.8",
19+
"setuptools==68.2.2",
20+
"uv>=0.9.16",
21+
]
1522

1623
[project.urls]
1724
Homepage = "https://github.com/jameslawlor/advent-of-code-python"
@@ -31,8 +38,14 @@ addopts = [
3138

3239
[tool.black]
3340
line-length = 88
34-
target-version = ['py39']
41+
target-version = ['py312']
42+
43+
[tool.ruff]
44+
line-length = 88
45+
target-version = "py312"
46+
exclude = ["__pycache__", ".venv", "build", "dist"]
47+
lint.select = ["E", "F", "W", "C", "B", "I"]
3548

3649
[project.scripts]
3750
# Console script for running day solutions: after `pip install -e .` you can run `aoc --year 2025 --day 1`
38-
aoc = "advent_of_code.cli:main"
51+
aoc = "advent_of_code.cli:main"

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
ruff==0.1.9
21
numpy==1.26.2
32
pytest==7.4.3
3+
ruff==0.14.8
44
setuptools==68.2.2
5+
uv==0.9.16
6+
black

scripts/generate_new_day_skeleton_files_from_templates.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import os
21
import argparse
3-
2+
import os
43

54
TEMPLATES_PATH = os.path.join("scripts", "templates")
65

scripts/run_all_solutions.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
RUN_DAY_SCRIPT = "scripts/run_day.py"
88
INPUTS_DIR = "inputs"
99

10+
1011
def discover_and_run_solutions():
1112
# Regex to match "day_<number>.py"
1213
day_pattern = re.compile(r"day_(\d{2})\.py")
13-
14+
1415
for year in sorted(os.listdir(BASE_DIR)):
1516
if year.startswith("year_"):
1617
year_path = os.path.join(BASE_DIR, year)
@@ -24,25 +25,33 @@ def discover_and_run_solutions():
2425
day_number = match.group(1)
2526

2627
# Build input file path
27-
input_file = os.path.join(INPUTS_DIR, f"year_{year_number}", f"{day_number}.dat")
28+
input_file = os.path.join(
29+
INPUTS_DIR, f"year_{year_number}", f"{day_number}.dat"
30+
)
2831
if not os.path.exists(input_file):
29-
print(f"Input file for {year_number} Day {day_number} not found, skipping.")
32+
print(f"Input for {year_number} {day_number} missing, skipping")
3033
continue
3134

3235
# Run the solution using run_day.py
3336
try:
3437
print(f"Running {year_number} Day {day_number}...")
3538
subprocess.run(
3639
[
37-
"python3", RUN_DAY_SCRIPT,
38-
"--year", year_number,
39-
"--day", str(int(day_number)), # Remove leading zero for argument
40+
"python3",
41+
RUN_DAY_SCRIPT,
42+
"--year",
43+
year_number,
44+
"--day",
45+
str(
46+
int(day_number)
47+
), # Remove leading zero for argument
4048
],
41-
check=True
49+
check=True,
4250
)
4351
print("\n")
4452
except subprocess.CalledProcessError as e:
4553
print(f"Error running {year_number} Day {day_number}: {e}")
4654

55+
4756
if __name__ == "__main__":
4857
discover_and_run_solutions()

scripts/run_day.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1+
import argparse
12
import importlib
23
import sys
3-
import argparse
4+
45

56
def main():
6-
parser = argparse.ArgumentParser(description="Run a specific Advent of Code solution.")
7+
parser = argparse.ArgumentParser(
8+
description="Run a specific Advent of Code solution."
9+
)
710
# parser.add_argument(
8-
# "--input_file",
9-
# required=True,
10-
# type=str,
11+
# "--input_file",
12+
# required=True,
13+
# type=str,
1114
# help="Path to the input file for the day's solution."
1215
# )
1316
parser.add_argument(
14-
"--year",
15-
required=True,
16-
type=int,
17+
"--year",
18+
required=True,
19+
type=int,
1720
)
1821
parser.add_argument(
19-
"--day",
20-
required=True,
21-
type=str,
22+
"--day",
23+
required=True,
24+
type=str,
2225
)
2326

2427
args = parser.parse_args()
@@ -35,10 +38,13 @@ def main():
3538
module.main(input_file)
3639
else:
3740
print("man")
38-
print(f"The module {day_module} does not have a 'main(input_file)' function.")
41+
print(
42+
f"The module {day_module} does not have a 'main(input_file)' function."
43+
)
3944
except ModuleNotFoundError:
4045
print(f"Could not find module: {day_module}")
4146
sys.exit(1)
4247

48+
4349
if __name__ == "__main__":
4450
main()

setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
from setuptools import setup
22

3-
setup(name="advent-of-code-python", version="0.1", description="advent-of-code-python", packages=["src/advent_of_code"])
3+
setup(
4+
name="advent-of-code-python",
5+
version="0.1",
6+
description="advent-of-code-python",
7+
packages=["src/advent_of_code"],
8+
python_requires=">=3.12,<4",
9+
)

src/advent_of_code/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
66
This file delegates to `advent_of_code.cli:main`.
77
"""
8-
from .cli import main
98

9+
from .cli import main
1010

1111
if __name__ == "__main__":
1212
raise SystemExit(main())

0 commit comments

Comments
 (0)