Skip to content

Commit

Permalink
feature: use ABI3 for cp36+
Browse files Browse the repository at this point in the history
Signed-off-by: mayeut <[email protected]>
  • Loading branch information
mayeut committed Jun 4, 2022
1 parent 44b986c commit 8077259
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 154 deletions.
85 changes: 0 additions & 85 deletions .ci/appveyor/install.ps1

This file was deleted.

49 changes: 46 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
on: [push, pull_request]
name: build
jobs:
# Linux + macOS + Python 3.6+
linux-macos-py3:
# Linux + macOS + Windows Python 3.6+
py3:
name: ${{ matrix.os }}-py36-plus
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-11]
os: [ubuntu-20.04, macos-11, windows-2019]

steps:
- name: Cancel previous runs
Expand Down Expand Up @@ -62,6 +62,49 @@ jobs:
mv dist/psutil*.tar.gz wheelhouse/
python scripts/internal/print_hashes.py wheelhouse/
# Windows cp37+ tests
# psutil tests do not like running from a virtualenv with python>=3.7 so
# not using cibuildwheel for those. run them "manually" with this job.
windows-py3-test:
name: windows-py3-test-${{ matrix.python }}-${{ matrix.architecture }}
needs: py3
runs-on: windows-2019
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11-dev"]
architecture: ["x86", "x64"]

steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: "${{ matrix.python }}"
architecture: "${{ matrix.architecture }}"
cache: pip
cache-dependency-path: .github/workflows/build.yml
- name: Download wheels
uses: actions/download-artifact@v3
with:
name: wheels
path: wheelhouse
- name: Run tests
run: |
mkdir .tests
cd .tests
pip install $(find ../wheelhouse -name '*-cp36-abi3-${{ matrix.architecture == 'x86' && 'win32' || 'win_amd64'}}.whl')[test]
export PYTHONWARNINGS=always
export PYTHONUNBUFFERED=1
export PSUTIL_DEBUG=1
python ../psutil/tests/runner.py
python ../psutil/tests/test_memleaks.py
shell: bash

# Linux + macOS + Python 2.7 & 3.5
linux-macos-py2:
name: ${{ matrix.os }}-py27-py35
Expand Down
45 changes: 0 additions & 45 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,62 +24,17 @@ environment:
PYTHON_VERSION: "2.7.x"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python36"
PYTHON_VERSION: "3.6.x"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python37"
PYTHON_VERSION: "3.7.x"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python38"
PYTHON_VERSION: "3.8.x"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python39"
PYTHON_VERSION: "3.9.x"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python310"
PYTHON_VERSION: "3.10.x"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
PYTHON_ARCH: "32"

# 64 bits

- PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: "2.7.x"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python36-x64"
PYTHON_VERSION: "3.6.x"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python37-x64"
PYTHON_VERSION: "3.7.x"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python38-x64"
PYTHON_VERSION: "3.8.x"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python39-x64"
PYTHON_VERSION: "3.9.x"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python310-x64"
PYTHON_VERSION: "3.10.x"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
PYTHON_ARCH: "64"

init:
- "ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH%"

install:
- "powershell .ci\\appveyor\\install.ps1"
# - ps: (new-object net.webclient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py', 'C:/get-pip.py')
- "%WITH_COMPILER% %PYTHON%/python.exe -m pip --version"
- "%WITH_COMPILER% %PYTHON%/python.exe -m pip install --upgrade --user setuptools pip"
- "%WITH_COMPILER% %PYTHON%/python.exe scripts/internal/winmake.py setup-dev-env"
Expand Down
15 changes: 15 additions & 0 deletions cibuildwheel.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@ archs = ["x86_64", "universal2"]

[tool.cibuildwheel.macos.environment]
MACOSX_DEPLOYMENT_TARGET = "10.9"

[tool.cibuildwheel.windows]
# psutil tests do not like running from a virtualenv with python>=3.7
# restrict build & tests to cp36
# cp36-abi3 wheels will need to be tested outside cibuildwheel for python>=3.7
build = "cp36-*"
test-command = [
"python {project}/psutil/tests/runner.py",
"python {project}/psutil/tests/test_memleaks.py"
]

[tool.cibuildwheel.windows.environment]
PYTHONWARNINGS = "always"
PYTHONUNBUFFERED = "1"
PSUTIL_DEBUG = "1"
15 changes: 4 additions & 11 deletions psutil/_psutil_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,29 +292,25 @@ psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args) {
pid_t pid;
int i, seq_len;
PyObject *py_cpu_set;
PyObject *py_cpu_seq = NULL;

if (!PyArg_ParseTuple(args, _Py_PARSE_PID "O", &pid, &py_cpu_set))
return NULL;

if (!PySequence_Check(py_cpu_set)) {
PyErr_Format(PyExc_TypeError, "sequence argument expected, got %s",
Py_TYPE(py_cpu_set)->tp_name);
PyErr_Format(PyExc_TypeError, "sequence argument expected, got %R", Py_TYPE(py_cpu_set));
goto error;
}

py_cpu_seq = PySequence_Fast(py_cpu_set, "expected a sequence or integer");
if (!py_cpu_seq)
goto error;
seq_len = PySequence_Fast_GET_SIZE(py_cpu_seq);
seq_len = PySequence_Size(py_cpu_set);
CPU_ZERO(&cpu_set);
for (i = 0; i < seq_len; i++) {
PyObject *item = PySequence_Fast_GET_ITEM(py_cpu_seq, i);
PyObject *item = PySequence_GetItem(py_cpu_set, i);
#if PY_MAJOR_VERSION >= 3
long value = PyLong_AsLong(item);
#else
long value = PyInt_AsLong(item);
#endif
Py_XDECREF(item);
if ((value == -1) || PyErr_Occurred()) {
if (!PyErr_Occurred())
PyErr_SetString(PyExc_ValueError, "invalid CPU value");
Expand All @@ -329,12 +325,9 @@ psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args) {
goto error;
}

Py_DECREF(py_cpu_seq);
Py_RETURN_NONE;

error:
if (py_cpu_seq != NULL)
Py_DECREF(py_cpu_seq);
return NULL;
}
#endif /* PSUTIL_HAVE_CPU_AFFINITY */
Expand Down
2 changes: 1 addition & 1 deletion psutil/arch/windows/process_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ psutil_get_cmdline(DWORD pid, int use_peb) {
wcslen(szArglist[i]));
if (py_unicode == NULL)
goto out;
PyList_SET_ITEM(py_retlist, i, py_unicode);
PyList_SetItem(py_retlist, i, py_unicode);
py_unicode = NULL;
}
ret = py_retlist;
Expand Down
Loading

0 comments on commit 8077259

Please sign in to comment.