Skip to content

Commit 726adb2

Browse files
authored
support Python versions 3.11 and 3.12 (#131)
1 parent 1d49ce4 commit 726adb2

File tree

7 files changed

+761
-2280
lines changed

7 files changed

+761
-2280
lines changed

.github/workflows/check_dependencies.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ jobs:
1010
permissions:
1111
contents: read
1212
pull-requests: read
13+
strategy:
14+
matrix:
15+
python-version: ["3.11", "3.12"]
1316
steps:
1417
- uses: actions/checkout@v4
1518
- uses: actions/setup-python@v5
1619
with:
17-
python-version: '3.11'
20+
python-version: ${{ matrix.python-version }}
1821
- name: Check Python version
1922
run: python --version
2023
- name: Install PDM

.github/workflows/integration_tests.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ jobs:
1212
pull-requests: read
1313
strategy:
1414
matrix:
15-
# Run tests only for Python 3.11 due to torch dependency.
16-
# python-version: ["3.11", "3.12", "3.13"]
17-
python-version: ["3.11"]
15+
python-version: ["3.11", "3.12"]
1816
steps:
1917
- uses: actions/checkout@v4
2018
- name: Set up Python ${{ matrix.python-version }}

.github/workflows/unit_tests.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ jobs:
1212
pull-requests: read
1313
strategy:
1414
matrix:
15-
# Run tests only for Python 3.11 due to torch dependency.
16-
# python-version: ["3.11", "3.12", "3.13"]
17-
python-version: ["3.11"]
15+
python-version: ["3.11", "3.12"]
1816
steps:
1917
- uses: actions/checkout@v4
2018
- name: Set up Python ${{ matrix.python-version }}

Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,43 @@ install-woke: ## Install woke, required for Inclusive Naming scan
4949
pdm-lock-check: ## Check that the pdm.lock file is in a good shape
5050
pdm lock --check
5151

52+
regenerate-lock: ## Regenerate pdm.lock for current Python version (supports 3.11 and 3.12)
53+
@PYTHON_VERSION=$$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")'); \
54+
echo "Detected Python version: $$PYTHON_VERSION"; \
55+
if [ "$$PYTHON_VERSION" = "3.11" ]; then \
56+
if [ ! -f pdm.lock ]; then \
57+
echo "Creating new lock file for Python 3.11..."; \
58+
pdm lock --python ">=3.11,<3.12" --platform linux; \
59+
else \
60+
echo "Updating lock file for Python 3.11..."; \
61+
pdm lock --python ">=3.11,<3.12" --platform linux; \
62+
fi \
63+
elif [ "$$PYTHON_VERSION" = "3.12" ]; then \
64+
if [ ! -f pdm.lock ]; then \
65+
echo "Creating new lock file for Python 3.12..."; \
66+
pdm lock --python ">=3.12,<3.13" --platform linux; \
67+
else \
68+
echo "Appending Python 3.12 to existing lock file..."; \
69+
pdm lock --python ">=3.12,<3.13" --platform linux --append; \
70+
fi \
71+
else \
72+
echo "ERROR: Unsupported Python version $$PYTHON_VERSION. Only 3.11 and 3.12 are supported."; \
73+
exit 1; \
74+
fi
75+
76+
regenerate-lock-all: ## Regenerate complete multi-target pdm.lock for both Python 3.11 and 3.12
77+
@echo "This requires both .venv311 and .venv312 virtual environments"
78+
@if [ ! -d .venv311 ] || [ ! -d .venv312 ]; then \
79+
echo "ERROR: Missing virtual environments. Please create .venv311 and .venv312"; \
80+
exit 1; \
81+
fi
82+
@echo "Step 1: Creating lock file for Python 3.11..."
83+
@rm -f pdm.lock
84+
(source .venv311/bin/activate && pdm lock --python ">=3.11,<3.12" --platform linux)
85+
@echo "Step 2: Appending Python 3.12 target..."
86+
(source .venv312/bin/activate && pdm lock --python ">=3.12,<3.13" --platform linux --append)
87+
@echo "✅ Multi-target lock file created successfully!"
88+
5289
install-deps: install-tools pdm-lock-check ## Install all required dependencies needed to run the service, according to pdm.lock
5390
@for a in 1 2 3 4 5; do pdm sync && break || sleep 15; done
5491

pdm.lock

Lines changed: 459 additions & 1382 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ version = "pdm run make print-version"
5555
verify-sources = "pdm run make verify"
5656
verify-packages = " pdm run make verify-packages-completeness"
5757

58-
5958
[build-system]
6059
requires = ["pdm-backend"]
6160
build-backend = "pdm.backend"
@@ -67,8 +66,10 @@ description = "Road-core service is an AI powered assistant that runs on OpenShi
6766
authors = []
6867
dependencies = [
6968
"pdm>=2.21.0",
70-
'torch@http://download.pytorch.org/whl/cpu/torch-2.5.1%2Bcpu-cp311-cp311-linux_x86_64.whl ; platform_system != "Darwin"',
71-
'torch-macos@http://download.pytorch.org/whl/cpu/torch-2.5.1-cp311-none-macosx_11_0_arm64.whl ; platform_system == "Darwin"',
69+
'torch @ https://download.pytorch.org/whl/cpu/torch-2.5.1%2Bcpu-cp311-cp311-linux_x86_64.whl ; sys_platform == "linux" and python_version < "3.12"',
70+
'torch @ https://download.pytorch.org/whl/cpu/torch-2.5.1%2Bcpu-cp312-cp312-linux_x86_64.whl ; sys_platform == "linux" and python_version >= "3.12"',
71+
'torch @ https://download.pytorch.org/whl/cpu/torch-2.5.1-cp311-none-macosx_11_0_arm64.whl ; sys_platform == "darwin" and python_version < "3.12"',
72+
'torch @ https://download.pytorch.org/whl/cpu/torch-2.5.1-cp312-none-macosx_11_0_arm64.whl ; sys_platform == "darwin" and python_version >= "3.12"',
7273
"pandas>=2.2.3",
7374
"httpx==0.27.2",
7475
"fastapi>=0.121.0",
@@ -120,7 +121,7 @@ dependencies = [
120121
# need to pin to avoid deadlock
121122
"requests==2.32.2",
122123
]
123-
requires-python = ">=3.11.1,<=3.12.8"
124+
requires-python = ">=3.11.1,<3.13"
124125
readme = "README.md"
125126
license = {file = "LICENSE"}
126127

0 commit comments

Comments
 (0)