From 1c51917ba58c87fc5e4c293faf772a284179c263 Mon Sep 17 00:00:00 2001 From: jianfengmao Date: Tue, 5 Nov 2024 23:19:35 -0500 Subject: [PATCH] Respond to review comments --- .github/workflows/build.yml | 2 +- .github/workflows/check.yml | 2 +- jpyutil.py | 7 ++----- src/main/c/jni/org_jpy_PyLib.c | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 04db875..dacf7df 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -169,7 +169,7 @@ jobs: - { machine: 'ubuntu-20.04', python: '3.13t', java: '8', arch: 'amd64', cmd: '.github/env/Linux/bdist-wheel.sh' } - { machine: 'windows-2022', python: '3.13t', java: '8', arch: 'amd64', cmd: '.\.github\env\Windows\bdist-wheel.ps1' } - { machine: 'macos-13', python: '3.13t', java: '8', arch: 'amd64', cmd: '.github/env/macOS/bdist-wheel.sh' } - - { machine: 'macos-latest', python: '3.13t', java: '11', arch: 'arm64', cmd: '.github/env/macOS/bdist-wheel.sh' } + - { machine: 'macos-14', python: '3.13t', java: '11', arch: 'arm64', cmd: '.github/env/macOS/bdist-wheel.sh' } steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 6f8f0b4..92f3eae 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -61,7 +61,7 @@ jobs: source .venv/bin/activate uv pip install pip echo $JAVA_HOME - echo PATH=$PATH >> $GITHUB_ENV + echo PATH=$PATH >> $GITHUB_PATH - run: pip install "setuptools < 72" diff --git a/jpyutil.py b/jpyutil.py index e377765..35557af 100644 --- a/jpyutil.py +++ b/jpyutil.py @@ -331,11 +331,8 @@ def _find_python_dll_file(fail=False): # Prepare list of possible library file names # account for Python debug builds - try: - sys.gettotalrefcount() - debug_build = True - except AttributeError: - debug_build = False + + debug_build = sysconfig.get_config_var('Py_DEBUG') # account for Python 3.13+ with GIL disabled dll_suffix = '' diff --git a/src/main/c/jni/org_jpy_PyLib.c b/src/main/c/jni/org_jpy_PyLib.c index af347f0..3100470 100644 --- a/src/main/c/jni/org_jpy_PyLib.c +++ b/src/main/c/jni/org_jpy_PyLib.c @@ -499,7 +499,7 @@ void dumpDict(const char* dictName, PyObject* dict) size = PyDict_Size(dict); printf(">> dumpDict: %s.size = %ld\n", dictName, size); -#ifdef Py_GIL_DISABLED +#if PY_VERSION_HEX >= 0x030D0000 // >=3.13 // PyDict_Next is not thread-safe, so we need to protect it with a critical section // https://docs.python.org/3/howto/free-threading-extensions.html#pydict-next Py_BEGIN_CRITICAL_SECTION(dict); @@ -510,7 +510,7 @@ void dumpDict(const char* dictName, PyObject* dict) printf(">> dumpDict: %s[%ld].name = '%s'\n", dictName, i, name); i++; } -#ifdef Py_GIL_DISABLED +#if PY_VERSION_HEX >= 0x030D0000 // >=3.13 Py_END_CRITICAL_SECTION(); #endif }