diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f609ee651..1e2b0a8e1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,10 +56,7 @@ jobs: uses: pypa/cibuildwheel@v2.22.0 env: CIBW_ARCHS: "${{ matrix.arch }}" - CIBW_ENABLE: "cpython-prerelease" - CIBW_TEST_EXTRAS: test - CIBW_TEST_COMMAND: - make -C {project} PYTHON="env python" PSUTIL_SCRIPTS_DIR="{project}/scripts" install-sysdeps install-pydeps-test install print-sysinfo test test-memleaks + CIBW_ENABLE: "${{ startsWith(github.ref, 'refs/tags/') && '' || 'cpython-prerelease' }}" - name: Upload wheels uses: actions/upload-artifact@v4 diff --git a/.gitignore b/.gitignore index ddafc64c6..d9f3d671b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ syntax: glob build/ dist/ wheelhouse/ +.tests/ diff --git a/HISTORY.rst b/HISTORY.rst index 39bb66157..173e514b1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,7 @@ XXXX-XX-XX **Enhancements** +- 2476_: Build Python 3.13t (free-threading) wheels - 2480_: Python 2.7 is no longer supported. Latest version supporting Python 2.7 is psutil 6.1.X. Install it with: ``pip2 install psutil==6.1.*``. - 2490_: removed long deprecated ``Process.memory_info_ex()`` method. It was diff --git a/Makefile b/Makefile index 3e74e8c7d..188169c72 100644 --- a/Makefile +++ b/Makefile @@ -162,6 +162,12 @@ test-coverage: ## Run test coverage. $(PYTHON) -m coverage html $(PYTHON) -m webbrowser -t htmlcov/index.html +test-ci: install-sysdeps + mkdir -p .tests + cd .tests/ && $(PYTHON) -c "from psutil.tests import print_sysinfo; print_sysinfo()" + cd .tests/ && $(PYTHON_ENV_VARS) PYTEST_ADDOPTS="-k 'not test_memleaks.py'" $(PYTHON) -m pytest $(PYTEST_ARGS) --pyargs psutil.tests + cd .tests/ && $(PYTHON_ENV_VARS) PYTEST_ADDOPTS="-k 'test_memleaks.py'" $(PYTHON) -m pytest $(PYTEST_ARGS) --pyargs psutil.tests + # =================================================================== # Linters # =================================================================== diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index 1d81d498f..4b999760d 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -798,7 +798,13 @@ def test_long_cmdline(self): def test_name(self): p = self.spawn_psproc() name = p.name().lower() - pyexe = os.path.basename(os.path.realpath(sys.executable)).lower() + pypath = os.path.realpath(sys.executable) + if pypath.startswith("/Library/Frameworks/PythonT.framework/"): + # macOS Framework installations of Python can have their process + # replaced by PythonT using execve / posix_spawn + assert name == "pythont" + pypath = psutil.Process().cmdline()[0] + pyexe = os.path.basename(pypath).lower() assert pyexe.startswith(name), (pyexe, name) @pytest.mark.skipif(PYPY or QEMU_USER, reason="unreliable on PYPY") diff --git a/psutil/tests/test_unicode.py b/psutil/tests/test_unicode.py index d8a8c4bfc..3c736630b 100755 --- a/psutil/tests/test_unicode.py +++ b/psutil/tests/test_unicode.py @@ -229,9 +229,12 @@ def test_proc_net_connections(self): name = self.get_testfn(suffix=self.funky_suffix) sock = bind_unix_socket(name) with closing(sock): - conn = psutil.Process().net_connections('unix')[0] - assert isinstance(conn.laddr, str) - assert conn.laddr == name + conns = psutil.Process().net_connections('unix') + for conn in conns: + assert isinstance(conn.laddr, str) + if conn.laddr == name: + return + raise ValueError("connection not found") @pytest.mark.skipif(not POSIX, reason="POSIX only") @pytest.mark.skipif( diff --git a/pyproject.toml b/pyproject.toml index f6eb772d8..033ac74af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -223,10 +223,13 @@ trailing_comma_inline_array = true [tool.cibuildwheel] skip = [ "*-musllinux*", - "cp313-win*", # pywin32 is not available on cp313 yet "cp3{7,8,9,10,11,12}-*linux_{aarch64,ppc64le,s390x}", # Only test cp36/cp313 on qemu tested architectures "pp*", ] +enable = ["cpython-freethreading"] +test-extras = ["test"] +test-command = "make -C {project} PYTHON=python PSUTIL_SCRIPTS_DIR=\"{project}/scripts\" test-ci" +test-skip = ["cp3*t-win*"] # pywin32 is not available for free-threaded python yet, https://github.com/mhammond/pywin32/issues/2303 [tool.cibuildwheel.macos] archs = ["arm64", "x86_64"] diff --git a/scripts/internal/install-sysdeps.sh b/scripts/internal/install-sysdeps.sh index 003a7d081..830ab5e88 100755 --- a/scripts/internal/install-sysdeps.sh +++ b/scripts/internal/install-sysdeps.sh @@ -29,6 +29,9 @@ case "$UNAME_S" in OpenBSD) OPENBSD=true ;; + Darwin) + DARWIN=true + ;; esac # Check if running as root @@ -54,6 +57,8 @@ main() { $SUDO pkgin -y install python311-* gcc12-* elif [ $OPENBSD ]; then $SUDO pkg_add gcc python3 + elif [ $DARWIN ]; then + : else echo "Unsupported platform: $UNAME_S" fi