diff --git a/.azure-pipelines/azure-pipelines-linux.yml b/.azure-pipelines/azure-pipelines-linux.yml index b866620..aa014dd 100755 --- a/.azure-pipelines/azure-pipelines-linux.yml +++ b/.azure-pipelines/azure-pipelines-linux.yml @@ -24,6 +24,10 @@ jobs: CONFIG: linux_64_python3.13.____cp313 UPLOAD_PACKAGES: 'True' DOCKER_IMAGE: quay.io/condaforge/linux-anvil-cos7-x86_64 + linux_64_python3.13.____cp313t: + CONFIG: linux_64_python3.13.____cp313t + UPLOAD_PACKAGES: 'True' + DOCKER_IMAGE: quay.io/condaforge/linux-anvil-cos7-x86_64 linux_64_python3.9.____cpython: CONFIG: linux_64_python3.9.____cpython UPLOAD_PACKAGES: 'True' @@ -44,6 +48,10 @@ jobs: CONFIG: linux_aarch64_python3.13.____cp313 UPLOAD_PACKAGES: 'True' DOCKER_IMAGE: quay.io/condaforge/linux-anvil-cos7-x86_64 + linux_aarch64_python3.13.____cp313t: + CONFIG: linux_aarch64_python3.13.____cp313t + UPLOAD_PACKAGES: 'True' + DOCKER_IMAGE: quay.io/condaforge/linux-anvil-cos7-x86_64 linux_aarch64_python3.9.____cpython: CONFIG: linux_aarch64_python3.9.____cpython UPLOAD_PACKAGES: 'True' @@ -64,6 +72,10 @@ jobs: CONFIG: linux_ppc64le_python3.13.____cp313 UPLOAD_PACKAGES: 'True' DOCKER_IMAGE: quay.io/condaforge/linux-anvil-cos7-x86_64 + linux_ppc64le_python3.13.____cp313t: + CONFIG: linux_ppc64le_python3.13.____cp313t + UPLOAD_PACKAGES: 'True' + DOCKER_IMAGE: quay.io/condaforge/linux-anvil-cos7-x86_64 linux_ppc64le_python3.9.____cpython: CONFIG: linux_ppc64le_python3.9.____cpython UPLOAD_PACKAGES: 'True' diff --git a/.azure-pipelines/azure-pipelines-osx.yml b/.azure-pipelines/azure-pipelines-osx.yml index 16c1bc2..dc1620d 100755 --- a/.azure-pipelines/azure-pipelines-osx.yml +++ b/.azure-pipelines/azure-pipelines-osx.yml @@ -5,7 +5,7 @@ jobs: - job: osx pool: - vmImage: macOS-12 + vmImage: macOS-13 strategy: matrix: osx_64_python3.10.____cpython: @@ -20,6 +20,9 @@ jobs: osx_64_python3.13.____cp313: CONFIG: osx_64_python3.13.____cp313 UPLOAD_PACKAGES: 'True' + osx_64_python3.13.____cp313t: + CONFIG: osx_64_python3.13.____cp313t + UPLOAD_PACKAGES: 'True' osx_64_python3.9.____cpython: CONFIG: osx_64_python3.9.____cpython UPLOAD_PACKAGES: 'True' @@ -35,6 +38,9 @@ jobs: osx_arm64_python3.13.____cp313: CONFIG: osx_arm64_python3.13.____cp313 UPLOAD_PACKAGES: 'True' + osx_arm64_python3.13.____cp313t: + CONFIG: osx_arm64_python3.13.____cp313t + UPLOAD_PACKAGES: 'True' osx_arm64_python3.9.____cpython: CONFIG: osx_arm64_python3.9.____cpython UPLOAD_PACKAGES: 'True' diff --git a/.azure-pipelines/azure-pipelines-win.yml b/.azure-pipelines/azure-pipelines-win.yml index dfeab3b..18f9a18 100755 --- a/.azure-pipelines/azure-pipelines-win.yml +++ b/.azure-pipelines/azure-pipelines-win.yml @@ -20,6 +20,9 @@ jobs: win_64_python3.13.____cp313: CONFIG: win_64_python3.13.____cp313 UPLOAD_PACKAGES: 'True' + win_64_python3.13.____cp313t: + CONFIG: win_64_python3.13.____cp313t + UPLOAD_PACKAGES: 'True' win_64_python3.9.____cpython: CONFIG: win_64_python3.9.____cpython UPLOAD_PACKAGES: 'True' diff --git a/.ci_support/linux_64_python3.13.____cp313.yaml b/.ci_support/linux_64_python3.13.____cp313.yaml index a65e02f..ace47d1 100644 --- a/.ci_support/linux_64_python3.13.____cp313.yaml +++ b/.ci_support/linux_64_python3.13.____cp313.yaml @@ -9,7 +9,7 @@ c_stdlib_version: cdt_name: - cos7 channel_sources: -- conda-forge/label/python_rc,conda-forge +- conda-forge channel_targets: - conda-forge main docker_image: diff --git a/.ci_support/linux_64_python3.13.____cp313t.yaml b/.ci_support/linux_64_python3.13.____cp313t.yaml new file mode 100644 index 0000000..073102a --- /dev/null +++ b/.ci_support/linux_64_python3.13.____cp313t.yaml @@ -0,0 +1,29 @@ +c_compiler: +- gcc +c_compiler_version: +- '13' +c_stdlib: +- sysroot +c_stdlib_version: +- '2.17' +cdt_name: +- cos7 +channel_sources: +- conda-forge/label/cython_dev,conda-forge +channel_targets: +- conda-forge main +docker_image: +- quay.io/condaforge/linux-anvil-cos7-x86_64 +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.13.* *_cp313t +target_platform: +- linux-64 +zip_keys: +- - c_stdlib_version + - cdt_name +- - python + - channel_sources diff --git a/.ci_support/linux_aarch64_python3.13.____cp313.yaml b/.ci_support/linux_aarch64_python3.13.____cp313.yaml index a5d5c31..2e72535 100644 --- a/.ci_support/linux_aarch64_python3.13.____cp313.yaml +++ b/.ci_support/linux_aarch64_python3.13.____cp313.yaml @@ -13,7 +13,7 @@ cdt_arch: cdt_name: - cos7 channel_sources: -- conda-forge/label/python_rc,conda-forge +- conda-forge channel_targets: - conda-forge main docker_image: diff --git a/.ci_support/linux_aarch64_python3.13.____cp313t.yaml b/.ci_support/linux_aarch64_python3.13.____cp313t.yaml new file mode 100644 index 0000000..74c60e3 --- /dev/null +++ b/.ci_support/linux_aarch64_python3.13.____cp313t.yaml @@ -0,0 +1,33 @@ +BUILD: +- aarch64-conda_cos7-linux-gnu +c_compiler: +- gcc +c_compiler_version: +- '13' +c_stdlib: +- sysroot +c_stdlib_version: +- '2.17' +cdt_arch: +- aarch64 +cdt_name: +- cos7 +channel_sources: +- conda-forge/label/cython_dev,conda-forge +channel_targets: +- conda-forge main +docker_image: +- quay.io/condaforge/linux-anvil-cos7-x86_64 +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.13.* *_cp313t +target_platform: +- linux-aarch64 +zip_keys: +- - c_stdlib_version + - cdt_name +- - python + - channel_sources diff --git a/.ci_support/linux_ppc64le_python3.13.____cp313.yaml b/.ci_support/linux_ppc64le_python3.13.____cp313.yaml index 331d628..99175cc 100644 --- a/.ci_support/linux_ppc64le_python3.13.____cp313.yaml +++ b/.ci_support/linux_ppc64le_python3.13.____cp313.yaml @@ -9,7 +9,7 @@ c_stdlib_version: cdt_name: - cos7 channel_sources: -- conda-forge/label/python_rc,conda-forge +- conda-forge channel_targets: - conda-forge main docker_image: diff --git a/.ci_support/linux_ppc64le_python3.13.____cp313t.yaml b/.ci_support/linux_ppc64le_python3.13.____cp313t.yaml new file mode 100644 index 0000000..a0d22e1 --- /dev/null +++ b/.ci_support/linux_ppc64le_python3.13.____cp313t.yaml @@ -0,0 +1,29 @@ +c_compiler: +- gcc +c_compiler_version: +- '13' +c_stdlib: +- sysroot +c_stdlib_version: +- '2.17' +cdt_name: +- cos7 +channel_sources: +- conda-forge/label/cython_dev,conda-forge +channel_targets: +- conda-forge main +docker_image: +- quay.io/condaforge/linux-anvil-cos7-x86_64 +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.13.* *_cp313t +target_platform: +- linux-ppc64le +zip_keys: +- - c_stdlib_version + - cdt_name +- - python + - channel_sources diff --git a/.ci_support/migrations/python313t.yaml b/.ci_support/migrations/python313t.yaml new file mode 100644 index 0000000..dc79446 --- /dev/null +++ b/.ci_support/migrations/python313t.yaml @@ -0,0 +1,48 @@ +migrator_ts: 1724712608 +__migrator: + commit_message: Rebuild for python 3.13 freethreading + migration_number: 1 + operation: key_add + primary_key: python + ordering: + python: + - 3.6.* *_cpython + - 3.7.* *_cpython + - 3.8.* *_cpython + - 3.9.* *_cpython + - 3.10.* *_cpython + - 3.11.* *_cpython + - 3.12.* *_cpython + - 3.13.* *_cp313 # new entry + - 3.13.* *_cp313t # new entry + - 3.6.* *_73_pypy + - 3.7.* *_73_pypy + - 3.8.* *_73_pypy + - 3.9.* *_73_pypy + paused: true + longterm: true + pr_limit: 20 + max_solver_attempts: 3 # this will make the bot retry "not solvable" stuff 12 times + exclude: + # this shouldn't attempt to modify the python feedstocks + - python + - pypy3.6 + - pypy-meta + - cross-python + - python_abi + exclude_pinned_pkgs: false + additional_zip_keys: + - channel_sources + - is_freethreading + +python: +- 3.13.* *_cp313t +channel_sources: +- conda-forge/label/python_rc,conda-forge/label/cython_dev,conda-forge +# additional entries to add for zip_keys +numpy: +- 2 +python_impl: +- cpython +is_freethreading: +- true diff --git a/.ci_support/osx_64_python3.13.____cp313.yaml b/.ci_support/osx_64_python3.13.____cp313.yaml index fb9b0dd..aa9061a 100644 --- a/.ci_support/osx_64_python3.13.____cp313.yaml +++ b/.ci_support/osx_64_python3.13.____cp313.yaml @@ -11,7 +11,7 @@ c_stdlib: c_stdlib_version: - '10.13' channel_sources: -- conda-forge/label/python_rc,conda-forge +- conda-forge channel_targets: - conda-forge main macos_machine: diff --git a/.ci_support/osx_64_python3.13.____cp313t.yaml b/.ci_support/osx_64_python3.13.____cp313t.yaml new file mode 100644 index 0000000..20eb85e --- /dev/null +++ b/.ci_support/osx_64_python3.13.____cp313t.yaml @@ -0,0 +1,29 @@ +MACOSX_DEPLOYMENT_TARGET: +- '10.13' +MACOSX_SDK_VERSION: +- '10.13' +c_compiler: +- clang +c_compiler_version: +- '17' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '10.13' +channel_sources: +- conda-forge/label/cython_dev,conda-forge +channel_targets: +- conda-forge main +macos_machine: +- x86_64-apple-darwin13.4.0 +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.13.* *_cp313t +target_platform: +- osx-64 +zip_keys: +- - python + - channel_sources diff --git a/.ci_support/osx_arm64_python3.13.____cp313.yaml b/.ci_support/osx_arm64_python3.13.____cp313.yaml index 62a509a..d36d641 100644 --- a/.ci_support/osx_arm64_python3.13.____cp313.yaml +++ b/.ci_support/osx_arm64_python3.13.____cp313.yaml @@ -11,7 +11,7 @@ c_stdlib: c_stdlib_version: - '11.0' channel_sources: -- conda-forge/label/python_rc,conda-forge +- conda-forge channel_targets: - conda-forge main macos_machine: diff --git a/.ci_support/osx_arm64_python3.13.____cp313t.yaml b/.ci_support/osx_arm64_python3.13.____cp313t.yaml new file mode 100644 index 0000000..89756a8 --- /dev/null +++ b/.ci_support/osx_arm64_python3.13.____cp313t.yaml @@ -0,0 +1,29 @@ +MACOSX_DEPLOYMENT_TARGET: +- '11.0' +MACOSX_SDK_VERSION: +- '11.0' +c_compiler: +- clang +c_compiler_version: +- '17' +c_stdlib: +- macosx_deployment_target +c_stdlib_version: +- '11.0' +channel_sources: +- conda-forge/label/cython_dev,conda-forge +channel_targets: +- conda-forge main +macos_machine: +- arm64-apple-darwin20.0.0 +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.13.* *_cp313t +target_platform: +- osx-arm64 +zip_keys: +- - python + - channel_sources diff --git a/.ci_support/win_64_python3.13.____cp313.yaml b/.ci_support/win_64_python3.13.____cp313.yaml index c9319ff..00551da 100644 --- a/.ci_support/win_64_python3.13.____cp313.yaml +++ b/.ci_support/win_64_python3.13.____cp313.yaml @@ -3,7 +3,7 @@ c_compiler: c_stdlib: - vs channel_sources: -- conda-forge/label/python_rc,conda-forge +- conda-forge channel_targets: - conda-forge main pin_run_as_build: diff --git a/.ci_support/win_64_python3.13.____cp313t.yaml b/.ci_support/win_64_python3.13.____cp313t.yaml new file mode 100644 index 0000000..e9b5d9c --- /dev/null +++ b/.ci_support/win_64_python3.13.____cp313t.yaml @@ -0,0 +1,19 @@ +c_compiler: +- vs2019 +c_stdlib: +- vs +channel_sources: +- conda-forge/label/cython_dev,conda-forge +channel_targets: +- conda-forge main +pin_run_as_build: + python: + min_pin: x.x + max_pin: x.x +python: +- 3.13.* *_cp313t +target_platform: +- win-64 +zip_keys: +- - python + - channel_sources diff --git a/.scripts/build_steps.sh b/.scripts/build_steps.sh index ba4b251..856f469 100755 --- a/.scripts/build_steps.sh +++ b/.scripts/build_steps.sh @@ -43,6 +43,8 @@ setup_conda_rc "${FEEDSTOCK_ROOT}" "${RECIPE_ROOT}" "${CONFIG_FILE}" source run_conda_forge_build_setup + + # make the build number clobber make_build_number "${FEEDSTOCK_ROOT}" "${RECIPE_ROOT}" "${CONFIG_FILE}" diff --git a/.scripts/run_win_build.bat b/.scripts/run_win_build.bat index 65650bf..a45c34f 100755 --- a/.scripts/run_win_build.bat +++ b/.scripts/run_win_build.bat @@ -24,7 +24,7 @@ set "CONDA_LIBMAMBA_SOLVER_NO_CHANNELS_FROM_INSTALLED=1" :: Provision the necessary dependencies to build the recipe later echo Installing dependencies -mamba.exe install "python=3.10" pip mamba conda-build conda-forge-ci-setup=4 "conda-build>=24.1" -c conda-forge --strict-channel-priority --yes +mamba.exe install pip mamba conda-build conda-forge-ci-setup=4 "conda-build>=24.1" -c conda-forge --strict-channel-priority --yes if !errorlevel! neq 0 exit /b !errorlevel! :: Set basic configuration @@ -48,7 +48,7 @@ if NOT [%HOST_PLATFORM%] == [%BUILD_PLATFORM%] ( ) if NOT [%flow_run_id%] == [] ( - set "EXTRA_CB_OPTIONS=%EXTRA_CB_OPTIONS% --extra-meta flow_run_id=%flow_run_id% remote_url=%remote_url% sha=%sha%" + set "EXTRA_CB_OPTIONS=%EXTRA_CB_OPTIONS% --extra-meta flow_run_id=%flow_run_id% remote_url=%remote_url% sha=%sha%" ) call :end_group diff --git a/README.md b/README.md index 143b413..9281a08 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,13 @@ Current build status variant + + linux_64_python3.13.____cp313t + + + variant + + linux_64_python3.9.____cpython @@ -100,6 +107,13 @@ Current build status variant + + linux_aarch64_python3.13.____cp313t + + + variant + + linux_aarch64_python3.9.____cpython @@ -135,6 +149,13 @@ Current build status variant + + linux_ppc64le_python3.13.____cp313t + + + variant + + linux_ppc64le_python3.9.____cpython @@ -170,6 +191,13 @@ Current build status variant + + osx_64_python3.13.____cp313t + + + variant + + osx_64_python3.9.____cpython @@ -205,6 +233,13 @@ Current build status variant + + osx_arm64_python3.13.____cp313t + + + variant + + osx_arm64_python3.9.____cpython @@ -240,6 +275,13 @@ Current build status variant + + win_64_python3.13.____cp313t + + + variant + + win_64_python3.9.____cpython diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e5306da..32da3d0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,7 +2,32 @@ # update the conda-forge.yml and/or the recipe/meta.yaml. # -*- mode: yaml -*- -jobs: - - template: ./.azure-pipelines/azure-pipelines-linux.yml - - template: ./.azure-pipelines/azure-pipelines-osx.yml - - template: ./.azure-pipelines/azure-pipelines-win.yml \ No newline at end of file +stages: +- stage: Check + jobs: + - job: Skip + pool: + vmImage: 'ubuntu-22.04' + variables: + DECODE_PERCENTS: 'false' + RET: 'true' + steps: + - checkout: self + fetchDepth: '2' + - bash: | + git_log=`git log --max-count=1 --skip=1 --pretty=format:"%B" | tr "\n" " "` + echo "##vso[task.setvariable variable=log]$git_log" + displayName: Obtain commit message + - bash: echo "##vso[task.setvariable variable=RET]false" + condition: or(contains(variables.log, '[skip azp]'), contains(variables.log, '[azp skip]'), contains(variables.log, '[skip ci]'), contains(variables.log, '[ci skip]')) + displayName: Skip build? + - bash: echo "##vso[task.setvariable variable=start_main;isOutput=true]$RET" + name: result + displayName: Export result +- stage: Build + condition: and(succeeded(), eq(dependencies.Check.outputs['Skip.result.start_main'], 'true')) + dependsOn: Check + jobs: + - template: ./.azure-pipelines/azure-pipelines-linux.yml + - template: ./.azure-pipelines/azure-pipelines-osx.yml + - template: ./.azure-pipelines/azure-pipelines-win.yml \ No newline at end of file diff --git a/build-locally.py b/build-locally.py index d78427b..6788aea 100755 --- a/build-locally.py +++ b/build-locally.py @@ -1,8 +1,11 @@ -#!/usr/bin/env python3 +#!/bin/sh +"""exec" "python3" "$0" "$@" #""" # fmt: off # fmt: on # # This file has been generated by conda-smithy in order to build the recipe # locally. # +# The line above this comment is a bash / sh / zsh guard +# to stop people from running it with the wrong interpreter import glob import os import platform diff --git a/recipe/0001-Fix-GIL-warnings-and-a-few-thread-safety-issues-in-f.patch b/recipe/0001-Fix-GIL-warnings-and-a-few-thread-safety-issues-in-f.patch new file mode 100644 index 0000000..f7ee4bb --- /dev/null +++ b/recipe/0001-Fix-GIL-warnings-and-a-few-thread-safety-issues-in-f.patch @@ -0,0 +1,168 @@ +From 6ba9b4ebe51d4ef706256a223d03406b90192225 Mon Sep 17 00:00:00 2001 +From: Sam Gross +Date: Mon, 24 Jun 2024 17:51:07 +0000 +Subject: [PATCH 1/2] Fix GIL warnings and a few thread-safety issues in + free-threaded CPython + +- The temporary `argv` C array is no longer global in OpenBSD's + proc_cmdline +- The `maxcpus` variable is no longer global in FreeBSD's per_cpu_times. + +Signed-off-by: Sam Gross +--- + psutil/_psutil_aix.c | 3 +++ + psutil/_psutil_bsd.c | 4 ++++ + psutil/_psutil_linux.c | 4 ++++ + psutil/_psutil_osx.c | 4 ++++ + psutil/_psutil_posix.c | 4 ++++ + psutil/_psutil_sunos.c | 4 ++++ + psutil/_psutil_windows.c | 4 ++++ + psutil/arch/freebsd/cpu.c | 2 +- + psutil/arch/openbsd/proc.c | 4 +++- + 9 files changed, 31 insertions(+), 2 deletions(-) + +diff --git a/psutil/_psutil_aix.c b/psutil/_psutil_aix.c +index ce89a7b..42f9211 100644 +--- a/psutil/_psutil_aix.c ++++ b/psutil/_psutil_aix.c +@@ -1080,6 +1080,9 @@ void init_psutil_aix(void) + PyObject *module = PyModule_Create(&moduledef); + #else + PyObject *module = Py_InitModule("_psutil_aix", PsutilMethods); ++#endif ++#ifdef Py_GIL_DISABLED ++ PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED); + #endif + PyModule_AddIntConstant(module, "version", PSUTIL_VERSION); + +diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c +index 6517d58..facaba8 100644 +--- a/psutil/_psutil_bsd.c ++++ b/psutil/_psutil_bsd.c +@@ -143,6 +143,10 @@ static PyMethodDef mod_methods[] = { + if (mod == NULL) + INITERR; + ++#ifdef Py_GIL_DISABLED ++ PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED); ++#endif ++ + if (PyModule_AddIntConstant(mod, "version", PSUTIL_VERSION)) INITERR; + // process status constants + +diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c +index 292e1c5..46244c5 100644 +--- a/psutil/_psutil_linux.c ++++ b/psutil/_psutil_linux.c +@@ -78,6 +78,10 @@ static PyMethodDef mod_methods[] = { + if (mod == NULL) + INITERR; + ++#ifdef Py_GIL_DISABLED ++ PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED); ++#endif ++ + if (PyModule_AddIntConstant(mod, "version", PSUTIL_VERSION)) INITERR; + if (PyModule_AddIntConstant(mod, "DUPLEX_HALF", DUPLEX_HALF)) INITERR; + if (PyModule_AddIntConstant(mod, "DUPLEX_FULL", DUPLEX_FULL)) INITERR; +diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c +index 4aa11d1..09fa267 100644 +--- a/psutil/_psutil_osx.c ++++ b/psutil/_psutil_osx.c +@@ -91,6 +91,10 @@ static PyMethodDef mod_methods[] = { + if (mod == NULL) + INITERR; + ++#ifdef Py_GIL_DISABLED ++ PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED); ++#endif ++ + if (psutil_setup() != 0) + INITERR; + +diff --git a/psutil/_psutil_posix.c b/psutil/_psutil_posix.c +index 24628af..8ced7be 100644 +--- a/psutil/_psutil_posix.c ++++ b/psutil/_psutil_posix.c +@@ -913,6 +913,10 @@ static PyMethodDef mod_methods[] = { + if (mod == NULL) + INITERR; + ++#ifdef Py_GIL_DISABLED ++ PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED); ++#endif ++ + #if defined(PSUTIL_BSD) || \ + defined(PSUTIL_OSX) || \ + defined(PSUTIL_SUNOS) || \ +diff --git a/psutil/_psutil_sunos.c b/psutil/_psutil_sunos.c +index 54f353c..d21f59c 100644 +--- a/psutil/_psutil_sunos.c ++++ b/psutil/_psutil_sunos.c +@@ -1721,6 +1721,10 @@ void init_psutil_sunos(void) + if (module == NULL) + INITERROR; + ++#ifdef Py_GIL_DISABLED ++ PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED); ++#endif ++ + if (psutil_setup() != 0) + INITERROR; + +diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c +index bb6e12f..0c221bd 100644 +--- a/psutil/_psutil_windows.c ++++ b/psutil/_psutil_windows.c +@@ -165,6 +165,10 @@ void init_psutil_windows(void) + if (module == NULL) + INITERROR; + ++#ifdef Py_GIL_DISABLED ++ PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED); ++#endif ++ + if (psutil_setup() != 0) + INITERROR; + if (psutil_set_se_debug() != 0) +diff --git a/psutil/arch/freebsd/cpu.c b/psutil/arch/freebsd/cpu.c +index a15d96e..9fa1a7d 100644 +--- a/psutil/arch/freebsd/cpu.c ++++ b/psutil/arch/freebsd/cpu.c +@@ -26,7 +26,7 @@ For reference, here's the git history with original(ish) implementations: + + PyObject * + psutil_per_cpu_times(PyObject *self, PyObject *args) { +- static int maxcpus; ++ int maxcpus; + int mib[2]; + int ncpu; + size_t len; +diff --git a/psutil/arch/openbsd/proc.c b/psutil/arch/openbsd/proc.c +index 96b85bc..bec2c42 100644 +--- a/psutil/arch/openbsd/proc.c ++++ b/psutil/arch/openbsd/proc.c +@@ -147,7 +147,7 @@ PyObject * + psutil_proc_cmdline(PyObject *self, PyObject *args) { + pid_t pid; + int mib[4]; +- static char **argv; ++ char **argv = NULL; + char **p; + size_t argv_size = 128; + PyObject *py_retlist = PyList_New(0); +@@ -189,9 +189,11 @@ psutil_proc_cmdline(PyObject *self, PyObject *args) { + Py_DECREF(py_arg); + } + ++ free(argv); + return py_retlist; + + error: ++ free(argv); + Py_XDECREF(py_arg); + Py_DECREF(py_retlist); + return NULL; +-- +2.44.0 + diff --git a/recipe/0002-Add-if-argv-NULL-check.patch b/recipe/0002-Add-if-argv-NULL-check.patch new file mode 100644 index 0000000..593e5eb --- /dev/null +++ b/recipe/0002-Add-if-argv-NULL-check.patch @@ -0,0 +1,27 @@ +From ad34a0bfbd75e2b5a21c0cfc0fee77529e0d2319 Mon Sep 17 00:00:00 2001 +From: Sam Gross +Date: Mon, 24 Jun 2024 18:26:00 +0000 +Subject: [PATCH 2/2] Add `if (argv != NULL)` check + +Signed-off-by: Sam Gross +--- + psutil/arch/openbsd/proc.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/psutil/arch/openbsd/proc.c b/psutil/arch/openbsd/proc.c +index bec2c42..0881ccd 100644 +--- a/psutil/arch/openbsd/proc.c ++++ b/psutil/arch/openbsd/proc.c +@@ -193,7 +193,8 @@ psutil_proc_cmdline(PyObject *self, PyObject *args) { + return py_retlist; + + error: +- free(argv); ++ if (argv != NULL) ++ free(argv); + Py_XDECREF(py_arg); + Py_DECREF(py_retlist); + return NULL; +-- +2.44.0 + diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 19133f5..d0df11c 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -8,9 +8,13 @@ package: source: url: https://pypi.io/packages/source/p/psutil/psutil-{{ version }}.tar.gz sha256: {{ sha256 }} + patches: + # These two patches are from gh2428 + - 0001-Fix-GIL-warnings-and-a-few-thread-safety-issues-in-f.patch + - 0002-Add-if-argv-NULL-check.patch build: - number: 1 + number: 2 script: # macOS renamed this variable, but it is `NULL` in either case. # Workaround the missing definition by setting it to `0`.