From b193c80aa5475fb49ca0ec33a286deca92e384ce Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Tue, 17 Dec 2024 21:49:00 -0600 Subject: [PATCH 1/3] Support compiling with Python 3.13 --- dpctl/_host_task_util.hpp | 8 +++++++- dpctl/apis/include/dpctl4pybind11.hpp | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dpctl/_host_task_util.hpp b/dpctl/_host_task_util.hpp index f3e710438f..166fa814b1 100644 --- a/dpctl/_host_task_util.hpp +++ b/dpctl/_host_task_util.hpp @@ -58,8 +58,14 @@ DPCTLSyclEventRef async_dec_ref(DPCTLSyclQueueRef QRef, cgh.depends_on(*(unwrap(depERefs[ev_id]))); } cgh.host_task([obj_array_size, obj_vec]() { + const bool initialized = Py_IsInitialized(); +#if PY_VERSION_HEX < 0x30d0000 + const bool finalizing = _Py_IsFinalizing(); +#else + const bool finalizing = Py_IsFinalizing(); +#endif // if the main thread has not finilized the interpreter yet - if (Py_IsInitialized() && !_Py_IsFinalizing()) { + if (initialized && !finalizing) { PyGILState_STATE gstate; gstate = PyGILState_Ensure(); for (size_t i = 0; i < obj_array_size; ++i) { diff --git a/dpctl/apis/include/dpctl4pybind11.hpp b/dpctl/apis/include/dpctl4pybind11.hpp index 30cd7572ea..1fe8b91ab1 100644 --- a/dpctl/apis/include/dpctl4pybind11.hpp +++ b/dpctl/apis/include/dpctl4pybind11.hpp @@ -198,7 +198,13 @@ class dpctl_capi { void operator()(py::object *p) const { - bool guard = (Py_IsInitialized() && !_Py_IsFinalizing()); + const bool initialized = Py_IsInitialized(); +#if PY_VERSION_HEX < 0x30d0000 + const bool finilizing = _Py_IsFinalizing(); +#else + const bool finilizing = Py_IsFinalizing(); +#endif + const bool guard = initialized && !finilizing; if (guard) { delete p; From 9e20a27e39ab5dadb0cc323be0464a48b5be6097 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Tue, 17 Dec 2024 22:01:34 -0600 Subject: [PATCH 2/3] Build and test for Python 3.13 --- .github/workflows/conda-package.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 55e90d8062..cfb5a13f2d 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: - python: ['3.9', '3.10', '3.11', '3.12'] + python: ['3.9', '3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v4.2.2 with: @@ -80,7 +80,7 @@ jobs: strategy: matrix: - python: ['3.9', '3.10', '3.11', '3.12'] + python: ['3.9', '3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v4.2.2 with: @@ -145,7 +145,7 @@ jobs: strategy: matrix: - python: ['3.9', '3.10', '3.11', '3.12'] + python: ['3.9', '3.10', '3.11', '3.12', '3.13'] experimental: [false] runner: [ubuntu-22.04] continue-on-error: ${{ matrix.experimental }} @@ -239,7 +239,7 @@ jobs: shell: cmd /C CALL {0} strategy: matrix: - python: ['3.9', '3.10', '3.11', '3.12'] + python: ['3.9', '3.10', '3.11', '3.12', '3.13'] experimental: [false] runner: [windows-2019] continue-on-error: ${{ matrix.experimental }} @@ -408,7 +408,7 @@ jobs: timeout-minutes: 20 strategy: matrix: - python: ['3.9', '3.10', '3.11', '3.12'] + python: ['3.9', '3.10', '3.11', '3.12', '3.13'] steps: - name: Download conda artifact uses: actions/download-artifact@v4 @@ -445,7 +445,7 @@ jobs: timeout-minutes: 20 strategy: matrix: - python: ['3.9', '3.10', '3.11', '3.12'] + python: ['3.9', '3.10', '3.11', '3.12', '3.13'] steps: - name: Download artifact uses: actions/download-artifact@v4 From cc902e72bf60854f82b1b4e5df3a15d6435ee0a1 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Wed, 18 Dec 2024 06:37:40 -0600 Subject: [PATCH 3/3] Support for Python 3.13 added to maintenance section --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0957f99e35..fec5e79f17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Add missing include of SYCL header to "math_utils.hpp" [gh-1899](https://github.com/IntelPython/dpctl/pull/1899) * Add support of CV-qualifiers in `is_complex` helper [gh-1900](https://github.com/IntelPython/dpctl/pull/1900) * Tuning work for elementwise functions with modest performance gains (under 10%) [gh-1889](https://github.com/IntelPython/dpctl/pull/1889) +* Support for Python 3.13 for `dpctl` [gh-1941](https://github.com/IntelPython/dpctl/pull/1941) ## [0.18.3] - Dec. 07, 2024