Skip to content

Commit 7bdf550

Browse files
Python: experimental py3.13 support (#10276)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Some small fixes in uv setup within actions Added experimental unit tests runs for py3.13 First typing improvement from pyright and pyright config. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
1 parent 9d5ad78 commit 7bdf550

File tree

54 files changed

+624
-642
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+624
-642
lines changed

.github/workflows/python-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
version: "0.5.x"
2222
enable-cache: true
2323
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
24+
cache-dependency-glob: "**/uv.lock"
2425
- name: Check version
2526
run: |
2627
echo "Building and uploading Python package version: ${{ github.event.release.tag_name }}"

.github/workflows/python-integration-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ jobs:
120120
version: "0.5.x"
121121
enable-cache: true
122122
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
123+
cache-dependency-glob: "**/uv.lock"
123124
- name: Install dependencies
124125
run: |
125126
uv sync --all-extras --dev
@@ -257,6 +258,7 @@ jobs:
257258
version: "0.5.x"
258259
enable-cache: true
259260
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
261+
cache-dependency-glob: "**/uv.lock"
260262
- name: Install dependencies
261263
run: |
262264
uv sync --all-extras --dev
@@ -321,6 +323,7 @@ jobs:
321323
version: "0.5.x"
322324
enable-cache: true
323325
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
326+
cache-dependency-glob: "**/uv.lock"
324327
- name: Install dependencies
325328
run: |
326329
uv sync --all-extras --dev
@@ -379,6 +382,7 @@ jobs:
379382
version: "0.5.x"
380383
enable-cache: true
381384
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
385+
cache-dependency-glob: "**/uv.lock"
382386
- name: Install dependencies
383387
run: |
384388
uv sync --all-extras --dev

.github/workflows/python-lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
version: "0.5.x"
3131
enable-cache: true
3232
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
33+
cache-dependency-glob: "**/uv.lock"
3334
- name: Install the project
3435
run: uv sync --all-extras --dev
3536
- uses: pre-commit/[email protected]

.github/workflows/python-test-coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
version: "0.5.x"
3333
enable-cache: true
3434
cache-suffix: ${{ runner.os }}-${{ env.UV_PYTHON }}
35+
cache-dependency-glob: "**/uv.lock"
3536
- name: Install the project
3637
run: uv sync --all-extras --dev
3738
- name: Test with pytest

.github/workflows/python-unit-tests.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,10 @@ jobs:
2020
python-version: ["3.10", "3.11", "3.12"]
2121
os: [ubuntu-latest, windows-latest, macos-latest]
2222
experimental: [false]
23-
# include:
24-
# - python-version: "3.13"
25-
# os: "ubuntu-latest"
26-
# experimental: true
27-
# - python-version: "3.13t"
28-
# os: "ubuntu-latest"
29-
# experimental: true
30-
# gil: 0
31-
# - python-version: "3.13t"
32-
# os: "ubuntu-latest"
33-
# experimental: true
34-
# gil: 1
23+
include:
24+
- python-version: "3.13"
25+
os: "ubuntu-latest"
26+
experimental: true
3527
env:
3628
UV_PYTHON: ${{ matrix.python-version }}
3729
permissions:
@@ -47,6 +39,7 @@ jobs:
4739
version: "0.5.x"
4840
enable-cache: true
4941
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
42+
cache-dependency-glob: "**/uv.lock"
5043
- name: Install the project
5144
run: uv sync --all-extras --dev -U --prerelease=if-necessary-or-explicit
5245
- name: Test with pytest

python/.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ repos:
3232
- id: pyupgrade
3333
args: [--py310-plus]
3434
- repo: https://github.com/astral-sh/ruff-pre-commit
35-
rev: v0.7.4
35+
rev: v0.9.6
3636
hooks:
3737
- id: ruff
3838
args: [ --fix, --exit-non-zero-on-fix ]
3939
- id: ruff-format
4040
- repo: https://github.com/astral-sh/uv-pre-commit
4141
# uv version.
42-
rev: 0.5.21
42+
rev: 0.5.30
4343
hooks:
4444
# Update the uv lockfile
4545
- id: uv-lock

python/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ help:
3232
echo ""
3333
echo -e "\033[1mVARIABLES:\033[0m"
3434
echo " PYTHON_VERSION - Python version to use. Default is 3.10"
35-
echo " By default, 3.10, 3.11, and 3.12 are installed as well."
35+
echo " By default, 3.10, 3.11, 3.12 and 3.13 are installed as well."
3636

3737
##############################
3838
# INSTALL
@@ -68,8 +68,8 @@ endif
6868
##############################
6969
.ONESHELL:
7070
install-python:
71-
echo "Installing python 3.10, 3.11, 3.12"
72-
uv python install 3.10 3.11 3.12
71+
echo "Installing python versions"
72+
uv python install 3.10 3.11 3.12 3.13
7373

7474
##############################
7575
# INSTALL-PRE-COMMIT
@@ -87,7 +87,7 @@ install-sk:
8787
echo "Creating and activating venv for python $(PYTHON_VERSION)"
8888
uv venv --python $(PYTHON_VERSION)
8989
echo "Installing Semantic Kernel and all dependencies"
90-
uv sync --all-extras --dev
90+
uv sync --all-extras --dev --prerelease=if-necessary-or-explicit
9191

9292
##############################
9393
# CLEAN

python/pyproject.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ dependencies = [
4545
"pybars4 ~= 0.9",
4646
"jinja2 ~= 3.1",
4747
"nest-asyncio ~= 1.6",
48+
"scipy>=1.15.1",
4849
]
4950

5051
### Optional dependencies
@@ -62,7 +63,7 @@ chroma = [
6263
]
6364
google = [
6465
"google-cloud-aiplatform == 1.79.0",
65-
"google-generativeai == 0.7"
66+
"google-generativeai ~= 0.8"
6667
]
6768
hugging_face = [
6869
"transformers[torch] ~= 4.28",
@@ -87,7 +88,7 @@ ollama = [
8788
"ollama ~= 0.4"
8889
]
8990
onnx = [
90-
"onnxruntime-genai ~= 0.5"
91+
"onnxruntime-genai ~= 0.5; python_version < '3.13'"
9192
]
9293
anthropic = [
9394
"anthropic ~= 0.32"
@@ -107,11 +108,11 @@ redis = [
107108
"redisvl >= 0.3.6",
108109
]
109110
usearch = [
110-
"usearch ~= 2.9",
111+
"usearch ~= 2.16",
111112
"pyarrow >= 12.0,< 20.0"
112113
]
113114
weaviate = [
114-
"weaviate-client>=4.7,<5.0",
115+
"weaviate-client>=4.10,<5.0",
115116
]
116117
pandas = [
117118
"pandas ~= 2.2"
@@ -139,7 +140,8 @@ dev-dependencies = [
139140
"snoop ~= 0.4",
140141
"mypy >= 1.10",
141142
"types-PyYAML ~= 6.0.12.20240311",
142-
"ruff ~= 0.7",
143+
"ruff ~= 0.9",
144+
"pyright>=1.1.392.post0",
143145
]
144146
environments = [
145147
"sys_platform == 'darwin'",

python/pyrightconfig.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"reportMissingImports": false,
3+
"include": [
4+
"semantic_kernel/**/*.py"
5+
],
6+
"pythonVersion": "3.10",
7+
"exclude": [
8+
"semantic_kernel/memory/*",
9+
"semantic_kernel/planners/*",
10+
"semantic_kernel/connectors/memory/astradb/*",
11+
"semantic_kernel/connectors/memory/azure_ai_search/*",
12+
"semantic_kernel/connectors/memory/azure_cognitive_search/*",
13+
"semantic_kernel/connectors/memory/azure_cosmosdb/*",
14+
"semantic_kernel/connectors/memory/azure_cosmosdb_no_sql/*",
15+
"semantic_kernel/connectors/memory/chroma/*",
16+
"semantic_kernel/connectors/memory/milvus/*",
17+
"semantic_kernel/connectors/memory/mongodb_atlas/*",
18+
"semantic_kernel/connectors/memory/pinecone/*",
19+
"semantic_kernel/connectors/memory/postgres/*",
20+
"semantic_kernel/connectors/memory/qdrant/*",
21+
"semantic_kernel/connectors/memory/redis/*",
22+
"semantic_kernel/connectors/memory/usearch/*",
23+
"semantic_kernel/connectors/memory/weaviate/*"
24+
],
25+
"venvPath": ".",
26+
"venv": ".venv"
27+
}

python/samples/concepts/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,6 @@
102102
- [Azure Chat GPT with Data API Function Calling](./on_your_data/azure_chat_gpt_with_data_api_function_calling.py)
103103
- [Azure Chat GPT with Data API Vector Search](./on_your_data/azure_chat_gpt_with_data_api_vector_search.py)
104104

105-
### Planners - Showing the uses of [`Planners`](https://github.com/microsoft/semantic-kernel/tree/main/python/semantic_kernel/planners)
106-
107-
- [Sequential Planner](./planners/sequential_planner.py)
108-
- [OpenAI Function Calling Stepwise Planner](./planners/openai_function_calling_stepwise_planner.py)
109-
- [Azure OpenAI Function Calling Stepwise Planner](./planners/azure_openai_function_calling_stepwise_planner.py)
110-
111105
### Plugins - Different ways of creating and using [`Plugins`](https://github.com/microsoft/semantic-kernel/blob/main/python/semantic_kernel/functions/kernel_plugin.py)
112106

113107
- [Azure Key Vault Settings](./plugins/azure_key_vault_settings.py)

0 commit comments

Comments
 (0)