From patchwork Wed Nov 20 13:18:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 844975 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 927BF158DD8 for ; Wed, 20 Nov 2024 13:18:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732108723; cv=none; b=q6Mpn48URX7YbkMDWQ0ptixiffpxrF8ymSJmktLiNa4wB3usNjEM6eJNDLE/VppqH97KniKR0wM+y45tOYLi+JgQ+3NUAJjgnFm0q/jWSXFuYJQhMnbKAaXXDLyG3kgGzZFsJ9qU8nxGh74BliBZrOOL4VEPKhb4XMVVd09sHFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732108723; c=relaxed/simple; bh=ecI8JgPiwysUn4/RxKJ4oEhqEgtsMDf4RV27KRsn9yA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A/c+aZDP9FGkvMI0yLpqx/es4XNA4ysjKGJQ7a0Q7AqesY3M/pE/jm7Q5BodBNKYPxW3bfFur61JA5gT1xxHIEoBF8Ry4P2wcbwjZaCJzN93JVy7mlAA4Q6wZqpWd4E2aqqpYcaIoNfoVc/U0N/k1uq9gCpdPIeda0t2Ja/hcwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=oFXYTT+e; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="oFXYTT+e" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-43161e7bb25so56573345e9.2 for ; Wed, 20 Nov 2024 05:18:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1732108720; x=1732713520; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Obywm8qFcWYhfI7yfALUSGj6P1J1l92eFi4boKLeRBY=; b=oFXYTT+ec4MSyHNgtMLIfsb4eoZZ1ow49W2Ou0kKtYzpdRdf6iCsMNgMcxi+skutlg +/VI9n5+nMaNKdRK2XzD6bwHon3vAs9uEVFD4q7Kx/CXvznjfF9im8aeuU4FeT36yPmx XAjKFcV8Q3plvE71eCwHLp6rOSEmlGnv53L1JZfJr+wroJVA4oLioMC1VMDAtr0hq0S9 JvW5+z9+d7rhW5ysP0aF/l7MWAp0qbpYFGdAR3ffaTXL8x2jwW2t3cacmiVeBUzD6vG0 KUbI3VPA1aopYihQfU3u28umx/kYnvEeK5XcyWFXH6+g02iufg8fRapg51CqOIXLC0pi BxWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732108720; x=1732713520; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Obywm8qFcWYhfI7yfALUSGj6P1J1l92eFi4boKLeRBY=; b=f/Z02H+ePmSCQ+ZfbiKebN7FtR6wB5ow1B7+h1psS57/XBKy5q8eQTWLQ9zYuX0FnE W31gSDKmfmhha+sTgXwb7DUi3jZLPDN0TJZicfOwUyuVlQXh9cTq5xBJfqBeYD7/itEQ uaNpfF9n5wehyhm0Kls/FUzWIz3ADjh8D2/Z5voi8QOKfRZyRtM3OdOKWZm3RWDblKwC g5hlrMTFLwnXznNn8TsYcIdoRGb7zY3/Xx44cMYJsjnW+y2oeCwzoqrOPBi28F9U3ZaM tOK9ojJGe9Vm5heG4e8c1RFTyqVPUW/SPIAAkK4jnT6XUIQavbpIesYx8FZLpXbh5hbx zKZw== X-Forwarded-Encrypted: i=1; AJvYcCXqVPqJA2DigPeQw5BQ/BkyPva1S9lQp1y/uUDs2evjCUyVjEy4Fso8Nm628fwThpKPx5UgpQSsafZ3@vger.kernel.org X-Gm-Message-State: AOJu0YxiUnw/PHBAihy/XG9wjhMYtE88dwaekNDj75ZavaQr97W4SP0M 3/hskNlm+OQLK/Hm4wL5t6pm6GN5u7Jzj6IIEwHfV3t2tKHHGUpadEJQpmfx2GQ= X-Google-Smtp-Source: AGHT+IEIczEbKOpnEYf3hw2tOjaMaIuZBEtwvR2uU53Uy1WqFZ7KLFyAuRlpNL0HwRUFf4ijFt73Fw== X-Received: by 2002:a5d:5887:0:b0:382:4fd6:405e with SMTP id ffacd0b85a97d-38254afa8ecmr1947910f8f.29.1732108719847; Wed, 20 Nov 2024 05:18:39 -0800 (PST) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:e93c:902f:82f5:7ce8]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825493ee48sm2040188f8f.98.2024.11.20.05.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 05:18:39 -0800 (PST) From: Bartosz Golaszewski Date: Wed, 20 Nov 2024 14:18:18 +0100 Subject: [PATCH 1/3] bindings: python: add .pyi files to EXTRA_DIST Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241120-drop-distutils-v1-1-7498e8b3babe@linaro.org> References: <20241120-drop-distutils-v1-0-7498e8b3babe@linaro.org> In-Reply-To: <20241120-drop-distutils-v1-0-7498e8b3babe@linaro.org> To: Vincent Fazio , Phil Howard , Kent Gibson , Linus Walleij Cc: Bartosz Golaszewski , linux-gpio@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1523; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=b/1GlSu5rgSLKbC9x+OzdesIfP/6+zrkm7pjV99kozY=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBnPeGt/nXI2s2x/6XHmctVdGtMMSLCWn6YsokGo TFaeRqHnLeJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZz3hrQAKCRARpy6gFHHX ctdoD/9c+Dme2IMD9kz6VjQFwkyBukV2YyPsw04/5eYjbmi39I4NMT/aD8zYk9icpcgcn+mU7n2 MhLy2Stssn+tuhXMrvX1nH0W+2XtWe5g6wTCBInz95/HA28BNCs1PTVFFuq8OX8EVUMyy/hHX/g BGF+pH6o4YyA4yNBKZzLP6PeUFgtjM66fRPwdarKEK6qikLxm/LQhWG1ZV1dmut2+CgL8w8ky3F sEWfmvHDb9KeidJiT9kpROOfxkc38rqqAJRotA07pGsUGTlAqcF8fgdrTAN4LeUKTB9swqw8ldx ObA9IhqzvD5B5b+UR9trbMA9VhsxhVIImchiWQJYHS05OkPYPFu5JjQtc+fK8hSmegrHXrCIRi7 UsI9fsPsFS7qck5s2vdZNk7Ys+ri1+9ne14jo/jzKo+xYF2l1SVAfjpmAl98+kVjUA2NrvKX2g2 KB0OE4Cr4WS/PMatkxv6LKnDeIOsXzmsh/Krwapg4w+V/1ByHwZMptu7rs0OZskCWNtbc506Oih LFCmy4V/166TESCUnQ3ydKvDYlKK2YbEDcrHrj7Z5G+tBbiwfhYl3f+TlGFbgO8depAwqv9roGP iNVl63BLt8WQ6E0NxTjjRXiE1kOEGa2FbhqrPIzwxLQ63AESFwhRyBqzyREKwt5QbkBhbcLAluC CYlm1BbzZ8m7zkw== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski While python sdist and wheels are built separately these days, we still want to package all the extra files in the regular libgpiod release tarballs. Add new .pyi files to automake's EXTRA_DIST. Signed-off-by: Bartosz Golaszewski --- bindings/python/gpiod/Makefile.am | 1 + bindings/python/tests/gpiosim/Makefile.am | 1 + bindings/python/tests/procname/Makefile.am | 1 + 3 files changed, 3 insertions(+) diff --git a/bindings/python/gpiod/Makefile.am b/bindings/python/gpiod/Makefile.am index daf7bae..e50297c 100644 --- a/bindings/python/gpiod/Makefile.am +++ b/bindings/python/gpiod/Makefile.am @@ -6,6 +6,7 @@ SUBDIRS = ext EXTRA_DIST = \ chip_info.py \ chip.py \ + _ext.pyi \ edge_event.py \ exception.py \ info_event.py \ diff --git a/bindings/python/tests/gpiosim/Makefile.am b/bindings/python/tests/gpiosim/Makefile.am index 7004f3a..b403f3c 100644 --- a/bindings/python/tests/gpiosim/Makefile.am +++ b/bindings/python/tests/gpiosim/Makefile.am @@ -3,5 +3,6 @@ EXTRA_DIST = \ chip.py \ + _ext.pyi \ ext.c \ __init__.py diff --git a/bindings/python/tests/procname/Makefile.am b/bindings/python/tests/procname/Makefile.am index c4a8fd5..dbc8e64 100644 --- a/bindings/python/tests/procname/Makefile.am +++ b/bindings/python/tests/procname/Makefile.am @@ -2,5 +2,6 @@ # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski EXTRA_DIST = \ + _ext.pyi \ ext.c \ __init__.py From patchwork Wed Nov 20 13:18:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 844581 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F7BB1A0AE1 for ; Wed, 20 Nov 2024 13:18:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732108724; cv=none; b=H2gKWDbJ52UbdFxzCoPpcoPAQ1UFHhVaQYpYnmOELiLfFqAY3Wh8wEuHXV2bHVqTry9IRHOG7+9x49RG0oD3+6h3KReo6azvvmlJGFaDuYgNpZbMK81uDN6FGo7jIOQqPXQMYoOO3f+c7GvxR2g0bOVBLr+tFMtpV9Spr+cYXUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732108724; c=relaxed/simple; bh=3cxx+Wru9EG8SIvx74WC75dbc3xijjQmwhYe5O+ee0o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I1EqoBN2DaRwQ0+b/uC34KPdGcg19buPl4EeuZTssXDYWI93Be3a0Ma0UuJ/wlFw5PHHTPMa0DAZ6h2mWBUpSvf5oAARAGC4POnCa2bxsHfg6hTJKNN4vEcx31OdquUTtbhECPu5fp0tUS1hQR/g4vvQFCZ0Ulxljga8FtUJHkI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=dKWTQBtC; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="dKWTQBtC" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-38241435528so2685018f8f.2 for ; Wed, 20 Nov 2024 05:18:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1732108721; x=1732713521; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=D54gqweBguAPuyzvfVpbw7QBvwFgz+QA1eIuUgV45y0=; b=dKWTQBtCqspmBi+bftTj4PSFznuHZVACJRxCD95HhziAnTf2xDirM9IOL2Fn7LLp+x IrTkysyM/xoswqpgIeyTmeww6P520kgks26kCBBCpkNjhPcVkvZi9qSFLRcvv6wfzioJ PKDJ1AhDoO87BbHLo4DbxhQ2kJffpVDq8Bj6VfEBCcEbCBFtIc/2XOUlyOMV52o7Goto fDh3CiC2d4+hO+du6R9VCeHf7JwoOXYYg48oQIGCrcJbmvl4nfmg4HMZt/pS9A1RXcuC 75tDLD6g7h/I+4jwPr5ct6erlJGAAXSqnCYOwr3C+ofVyGyB+o9giARLMhOMsD+tm24Q +6Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732108721; x=1732713521; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D54gqweBguAPuyzvfVpbw7QBvwFgz+QA1eIuUgV45y0=; b=BEeJynlzOhM4qeaZqOa6hIAKcUormR69ZovNgH4aJvfKxQgJB6bxcdGhpgP0Of0vXe V7FyyEFsN6q41jBxpUAlErchq3G/byWF0EQYjJbpOkgiFTuNjaHs3fPzt0SCAlTZ95bP iR37xUVhoQ2dRPlK1/jP3kRn/8mZLBdIAuZl8UY8Pv5yJs5gdhk2m4x1UEoRiFhkOtCu nAkwHdqqHJt/VBbjNDfUBdqVB2cZxxcdPWh0sx1aQupsM0TdnKTLU44lRJH97nFRXp++ ypINdcNCxorw3vtyNSpQUybmvjgXUKnleMCVgCuxxJgpN0S9UIE206JZYGfV7+6YUgP3 /JMA== X-Forwarded-Encrypted: i=1; AJvYcCXxvWE/P7KyU8QBLjbdezHm7hVrLqn0sWwCFPtC/EdFtY55H+Z40K1S583sonyjZ64SgPXxJTEMKt6s@vger.kernel.org X-Gm-Message-State: AOJu0Yw/l9Lsjc7PRoPhJQ1VmioWV/nZpD7INHaHGcJdkJmoHh+2smP/ VqzgPwvtU8HbV/CEaEnsxV9dWty4xUf/8Wtfl+EBm5CFTYTBgMbvtSEAsoeISC4= X-Google-Smtp-Source: AGHT+IFlGSBeRjLddn4vwOJwbeCWj+eaUD+qmSpFGrVk2IvCONywi4ga60jJ9yQSHBQPq1MoW7oepA== X-Received: by 2002:a05:6000:154e:b0:382:22f4:7773 with SMTP id ffacd0b85a97d-38254a83f8fmr2488761f8f.0.1732108720776; Wed, 20 Nov 2024 05:18:40 -0800 (PST) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:e93c:902f:82f5:7ce8]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825493ee48sm2040188f8f.98.2024.11.20.05.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 05:18:40 -0800 (PST) From: Bartosz Golaszewski Date: Wed, 20 Nov 2024 14:18:19 +0100 Subject: [PATCH 2/3] bindings: python: tests: rename procname to system Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241120-drop-distutils-v1-2-7498e8b3babe@linaro.org> References: <20241120-drop-distutils-v1-0-7498e8b3babe@linaro.org> In-Reply-To: <20241120-drop-distutils-v1-0-7498e8b3babe@linaro.org> To: Vincent Fazio , Phil Howard , Kent Gibson , Linus Walleij Cc: Bartosz Golaszewski , linux-gpio@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=5074; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=UIBtCIoU20n9ZDZQpvZ1ig2G4R5kAS2Kg3Q8Dkp3GW0=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBnPeGtJwaMukwt2nmSQbXd4zArTeJSkHKQitJj0 SK5WHGR29+JAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZz3hrQAKCRARpy6gFHHX cuVhD/4kzDtvbYzowCZCe87ouEJisqOpuoUKjx/NhajOhaP6Xfy2w+uR6NIHlgG+R42eFiW5Bt3 19k87VHkvjm1/85rF3bqWPnCD8GX3SnYvWqY1+xNA8CdmfoZUyAu10XPU7YwG8TWCcLj+Nkl5l4 bgj/GyIbwkOzHoMij1sk0e216AyP6DE2gPGAIUfiB3uDolVfJq3sMY8Khc9o6+5/0lc2ydfjZe+ n83OSWOTBNGtJrBBeO5aVoNN25+HmEB/4Fu/EWXRU1zGZVciFTdhXcu0GmaEI5fS5FJ7ZIdqaFh nGHt0igIlM6bYwrwl0GnxEBtzy1coPeLb5Xjjyto70lwRZDkgF3BxrdvbOJPuq4eO2HTRQ8F/JD ugmwXjWIqcOd/OZEIsxMiqvOwtc5DUYtSPjL8+G93VlhAmbWpYhN/X9lOgH7MlU9dSQMKjCxQNP YMPPsAg4Xapw3Rhc85jWcHS/Tv4T1KWUr4ovrmwe9FjtqwYA9HpwbybdMuF3H37Dg8c0QWL87C/ ryFLZcnaTxD6wXjurgWltX3PZjxMcKxJfODFnc1wCNHDTdjiYgU2lOAghYNXTKmH/l/AEtVUCYC /htKHJNKfmjAO6qS+Lbi5a++yXSFQGz10F/a+XEeWF3wI0n7k+GGe0MqZgTPVWqH8Rj7hCN3lRf 8l2HVAqItZHHicA== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski We'll be extending the functionality of that C extension with other OS-level helpers so change its name to 'system'. Signed-off-by: Bartosz Golaszewski --- bindings/python/MANIFEST.in | 2 +- bindings/python/build_tests.py | 10 +++++----- bindings/python/tests/Makefile.am | 2 +- bindings/python/tests/__main__.py | 4 ++-- bindings/python/tests/{procname => system}/Makefile.am | 0 bindings/python/tests/{procname => system}/__init__.py | 0 bindings/python/tests/{procname => system}/_ext.pyi | 0 bindings/python/tests/{procname => system}/ext.c | 2 +- configure.ac | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bindings/python/MANIFEST.in b/bindings/python/MANIFEST.in index f3a1ee8..dc7daee 100644 --- a/bindings/python/MANIFEST.in +++ b/bindings/python/MANIFEST.in @@ -13,7 +13,7 @@ recursive-include gpiod/ext *.c recursive-include gpiod/ext *.h recursive-include tests/gpiosim *.c -recursive-include tests/procname *.c +recursive-include tests/system *.c recursive-include lib *.c recursive-include lib *.h diff --git a/bindings/python/build_tests.py b/bindings/python/build_tests.py index 1760257..84cedfc 100644 --- a/bindings/python/build_tests.py +++ b/bindings/python/build_tests.py @@ -11,7 +11,7 @@ polluted with artefacts in build/ Builds: tests/gpiosim/_ext..so - tests/procname/_ext..so + tests/system/_ext..so """ @@ -61,9 +61,9 @@ gpiosim_ext = Extension( ], ) -procname_ext = Extension( - "tests.procname._ext", - sources=["tests/procname/ext.c"], +system_ext = Extension( + "tests.system._ext", + sources=["tests/system/ext.c"], define_macros=[("_GNU_SOURCE", "1")], extra_compile_args=["-Wall", "-Wextra"], ) @@ -71,7 +71,7 @@ procname_ext = Extension( dist = Distribution( { "name": "gpiod", - "ext_modules": [gpiosim_ext, procname_ext, gpiod_ext], + "ext_modules": [gpiosim_ext, system_ext, gpiod_ext], "version": __version__, "platforms": ["linux"], } diff --git a/bindings/python/tests/Makefile.am b/bindings/python/tests/Makefile.am index 3118d5f..d6e3ea3 100644 --- a/bindings/python/tests/Makefile.am +++ b/bindings/python/tests/Makefile.am @@ -1,7 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski -SUBDIRS = gpiosim procname +SUBDIRS = gpiosim system EXTRA_DIST = \ helpers.py \ diff --git a/bindings/python/tests/__main__.py b/bindings/python/tests/__main__.py index 8b4260d..318e0df 100644 --- a/bindings/python/tests/__main__.py +++ b/bindings/python/tests/__main__.py @@ -4,7 +4,7 @@ import unittest -from . import procname +from .system import set_process_name from .tests_chip import * from .tests_chip_info import * from .tests_edge_event import * @@ -15,6 +15,6 @@ from .tests_line_request import * from .tests_line_settings import * from .tests_module import * -procname.set_process_name("python-gpiod") +set_process_name("python-gpiod") unittest.main() diff --git a/bindings/python/tests/procname/Makefile.am b/bindings/python/tests/system/Makefile.am similarity index 100% rename from bindings/python/tests/procname/Makefile.am rename to bindings/python/tests/system/Makefile.am diff --git a/bindings/python/tests/procname/__init__.py b/bindings/python/tests/system/__init__.py similarity index 100% rename from bindings/python/tests/procname/__init__.py rename to bindings/python/tests/system/__init__.py diff --git a/bindings/python/tests/procname/_ext.pyi b/bindings/python/tests/system/_ext.pyi similarity index 100% rename from bindings/python/tests/procname/_ext.pyi rename to bindings/python/tests/system/_ext.pyi diff --git a/bindings/python/tests/procname/ext.c b/bindings/python/tests/system/ext.c similarity index 96% rename from bindings/python/tests/procname/ext.c rename to bindings/python/tests/system/ext.c index bf7d2fe..e7c1cc4 100644 --- a/bindings/python/tests/procname/ext.c +++ b/bindings/python/tests/system/ext.c @@ -32,7 +32,7 @@ static PyMethodDef module_methods[] = { static PyModuleDef module_def = { PyModuleDef_HEAD_INIT, - .m_name = "procname._ext", + .m_name = "system._ext", .m_methods = module_methods, }; diff --git a/configure.ac b/configure.ac index 97fc83f..78a6670 100644 --- a/configure.ac +++ b/configure.ac @@ -371,7 +371,7 @@ AC_CONFIG_FILES([Makefile bindings/python/examples/Makefile bindings/python/tests/Makefile bindings/python/tests/gpiosim/Makefile - bindings/python/tests/procname/Makefile + bindings/python/tests/system/Makefile bindings/rust/libgpiod-sys/src/Makefile bindings/rust/libgpiod-sys/Makefile bindings/rust/libgpiod/src/Makefile From patchwork Wed Nov 20 13:18:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 844974 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E6752AD00 for ; Wed, 20 Nov 2024 13:18:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732108725; cv=none; b=oN7mD8ec1cUjF9wVrcHdXFmiwY/IhUGxzSln5WR6OJI4b5Q/l56znYEUn0xHU9Aprhb2ZgfI2hNGJnBuDM6WCussxL6Wh5TNVyMpV5Za2h4+2w0H4o0qp4n1EF9/wuI6x9/ZYBkiiYVT5xkTxb0YDyPuuygHZWzFFnMgGlIDrac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732108725; c=relaxed/simple; bh=62YQGSyI89J7vC2iJB9r9HU/zhCbSQ/RnJOg54pUxJw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ApBNf0+M4EchdpFZLXrtOsYusDXrX2dbNauYT+N+ST+7he+uKWwiTbrC1lAJ8m+w+fO5qHk3PT7vAyz6jN/mRJ6S/gl/Xm4nvX8ydZT7qVEtqrUDDr2lK75FKNE8XYD+WhI8aQId7IBXArsMrsTUsfGDgsV42uCPK+U3xNuSwqE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=U/XpkS6E; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="U/XpkS6E" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-3824aef833bso2270298f8f.0 for ; Wed, 20 Nov 2024 05:18:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1732108722; x=1732713522; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=X/JBQicLHaOhD1kC5E6qUZNFZFyAgxZrSTsNJDYxERw=; b=U/XpkS6EEUT8/nJCSQcemDolNu2o029a1k4LAn12Yelaw40JwPYqzA5CM301MLm4L1 bgRWA0YFcpi7HyBUl4b9kXPd1spNT6+C0NtvBgDfyvH9Sobi6kTo9e2m/Fz7TOwcjp+S OYgSAfkFQFOVcFZUPbjbh2fvZoVp1Dk07Qvt5qEs9ZnQjORFW1R9TzNuWc6PmYmJdl65 GbIPM5aAQ/lzF1imctgq5aKuZA0Gzcl5Yw9EuAbaOGw7FJfRZJyJ8IsH2RpwBgdOYS5Q Nf69ZahrMnTK5r2KFpnRTc9o0RoFYln6brLFzQAvol0EqBB/kNyFT6ql6pHhyzdYdnhs uV4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732108722; x=1732713522; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X/JBQicLHaOhD1kC5E6qUZNFZFyAgxZrSTsNJDYxERw=; b=NRPngUP2xQNn7AbJbCk2N1lfz/qDlwoqs0jPEd3qxCibPKdzugknNn1VrYdOsS5Ucz pz88Jodqgae6+YUA9Ej8UgGfjRx8gxt2UYVbnOnJ3Ru5vdssSGM1PBJrvTgblatXIcVf RQFRTW6idvqqb9sleTNkYv0ZF8L673YIKZLC/FmEDEhnS/4NksqzyfKcZsg+tJVHq8EY JyVeOETDGBCLHZXzOj6CVp4UMwkBf+sj3MLZCzLpHqUL85zp9ZTaNqMRHLppY1q+LGlt W9ba3DAJyesM2A3NcrUaBUMXOecdv3/n7nLSPImnKKuhyrm9eVfUNP03QWc12Z6NVJBf DL/Q== X-Forwarded-Encrypted: i=1; AJvYcCXPHFcbbuE/W8t2r2ajaDuga8EeAVfqc2jSD6GM55XuoXvQ/Ve4NdVWHHSj4svIrz1tcjvJlkSunP6Q@vger.kernel.org X-Gm-Message-State: AOJu0YyvsEia6a6kZj8JpyQ/Fhj5BsQ3G1M+sLTBYEXZjatnOJ5O5XEs voNbs8zjbLegPrUJXuEBpCjzjHG5WDIJRCIyCyzMgCuAZ0rIon5CUk1DyvdNPM+8Ywbu72itsuw m X-Google-Smtp-Source: AGHT+IHibnAAxmEUnohymQfPjeIMUuf690kAUFBypPIh9MUANto6qsLFzh074hnBiTnLt3Nff2tcLg== X-Received: by 2002:a05:6000:1541:b0:382:5177:3a4f with SMTP id ffacd0b85a97d-38254b21313mr2163684f8f.49.1732108721694; Wed, 20 Nov 2024 05:18:41 -0800 (PST) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:e93c:902f:82f5:7ce8]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825493ee48sm2040188f8f.98.2024.11.20.05.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 05:18:41 -0800 (PST) From: Bartosz Golaszewski Date: Wed, 20 Nov 2024 14:18:20 +0100 Subject: [PATCH 3/3] bindings: python: tests: provide and use system.check_kernel_version() Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241120-drop-distutils-v1-3-7498e8b3babe@linaro.org> References: <20241120-drop-distutils-v1-0-7498e8b3babe@linaro.org> In-Reply-To: <20241120-drop-distutils-v1-0-7498e8b3babe@linaro.org> To: Vincent Fazio , Phil Howard , Kent Gibson , Linus Walleij Cc: Bartosz Golaszewski , linux-gpio@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=4754; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=kO26J6grBHQ7Skc0uLR5oJOBXkTROWyWPkuR+0//ilg=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBnPeGum5owo1EshfxUlyJ/Rp4MDoBA9+GPFcSqZ yMI2YuVzACJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZz3hrgAKCRARpy6gFHHX ciruD/4kfwvjdQlGvAjdc4rV4DHsrUnXhoE/4ve7X313wPJwjsqKw+/kwGhJsnkj09dlqjreQdh FZX9tQ77H9OvSkjOjb0/qSaRr3Jesnj89A/Rhh0JaYe/I1pRmVzgG32AcZGHm8DEEmKe+aTiQhg 3zJfG2Y+FrtTNhY7v+7pE1ov1Y9nqsnVgDScknHGinKrrw9/KM/IramJm9OawV2UTnCZ9ZPl1Qj ocUPzGG7/565OJEqhAZOHtA3Oj048B7Xyw8zGaCsbSfPpRDn8qdI9AlhZeyzJs51ux+2UjVPIVC ETbUvhergSTrUN3LPKty/Wx4VGze7PlXtM6bSPM+NXoyGWWUlaTbjMI4WHk1hXHyQvAPWYaBd7y d0wsY+mq9YWRoRCHNxs1rvT2FsQnQumqAe/zC4Y4ZeIOpix/S1C6agojhjPCP5ArLxgPf/VfZfo /hA9pyyzqzOsfE/5ckvvuRBqsaGd99NMdDJz4Z2rkBreC+sDXedjiitGr7q3C1rGkW1V1STrWcs 8qk+phA+43NbvJrwFnBDygE4fuZV9mXrRKDji5g6gDQZd2FiWZ3yC1jWqfOOYIUjSzOw/+ZXjPc 7FETHWNBbl6Et+eBC4aNOPG/rF0PjbDpue7x9dgJnfo2XykUQroi0AAOWYU6XW3d6YhsJJ8pe+Y MFtcO2dPDgqvf7Q== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski We claim that libgpiod python bindings have no dependencies other than the python standard library but this is not true - the tests do depend on deprecated distutils for kernel version parsing. As distutils is deprecated, the recommended improvement is to use the Version class from packaging.version but this would too entail pulling in an external module. Let's instead implement the kernel version check in C using uname() and put it into the tests.system extension. This allows us to entirely drop the distutils import. Signed-off-by: Bartosz Golaszewski --- bindings/python/tests/__init__.py | 11 +++++----- bindings/python/tests/system/__init__.py | 4 ++-- bindings/python/tests/system/_ext.pyi | 1 + bindings/python/tests/system/ext.c | 37 ++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/bindings/python/tests/__init__.py b/bindings/python/tests/__init__.py index a0f22ae..3eb13f7 100644 --- a/bindings/python/tests/__init__.py +++ b/bindings/python/tests/__init__.py @@ -1,13 +1,12 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski +# SPDX-FileCopyrightText: 2024 Bartosz Golaszewski -import os -from distutils.version import LooseVersion +from .system import check_kernel_version -required_kernel_version = LooseVersion("5.19.0") -current_version = LooseVersion(os.uname().release.split("-")[0]) +_required_kernel_version = (5, 19, 0) -if current_version < required_kernel_version: +if not check_kernel_version(*_required_kernel_version): raise NotImplementedError( - f"linux kernel version must be at least {required_kernel_version} - got {current_version}" + f"linux kernel version must be at least v{'.'.join([str(i) for i in _required_kernel_version])}" ) diff --git a/bindings/python/tests/system/__init__.py b/bindings/python/tests/system/__init__.py index 436ff40..cba9b92 100644 --- a/bindings/python/tests/system/__init__.py +++ b/bindings/python/tests/system/__init__.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-or-later # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski -from ._ext import set_process_name +from ._ext import check_kernel_version, set_process_name -__all__ = ["set_process_name"] +__all__ = ["check_kernel_version", "set_process_name"] diff --git a/bindings/python/tests/system/_ext.pyi b/bindings/python/tests/system/_ext.pyi index df8bb15..0a19d6c 100644 --- a/bindings/python/tests/system/_ext.pyi +++ b/bindings/python/tests/system/_ext.pyi @@ -2,3 +2,4 @@ # SPDX-FileCopyrightText: 2024 Vincent Fazio def set_process_name(name: str) -> None: ... +def check_kernel_version(major: int, minor: int, release: int) -> bool: ... diff --git a/bindings/python/tests/system/ext.c b/bindings/python/tests/system/ext.c index e7c1cc4..c982fa6 100644 --- a/bindings/python/tests/system/ext.c +++ b/bindings/python/tests/system/ext.c @@ -1,8 +1,11 @@ // SPDX-License-Identifier: LGPL-2.1-or-later // SPDX-FileCopyrightText: 2022 Bartosz Golaszewski +// SPDX-FileCopyrightText: 2024 Bartosz Golaszewski #include +#include #include +#include static PyObject * module_set_process_name(PyObject *Py_UNUSED(self), PyObject *args) @@ -21,12 +24,46 @@ module_set_process_name(PyObject *Py_UNUSED(self), PyObject *args) Py_RETURN_NONE; } +static PyObject * +module_check_kernel_version(PyObject *Py_UNUSED(self), PyObject *args) +{ + unsigned int req_maj, req_min, req_rel, curr_maj, curr_min, curr_rel; + struct utsname un; + int ret; + + ret = PyArg_ParseTuple(args, "III", &req_maj, &req_min, &req_rel); + if (!ret) + return NULL; + + ret = uname(&un); + if (ret) + return PyErr_SetFromErrno(PyExc_OSError); + + ret = sscanf(un.release, "%u.%u.%u", &curr_maj, &curr_min, &curr_rel); + if (ret != 3) { + PyErr_SetString(PyExc_RuntimeError, + "invalid linux version read from the kernel"); + return NULL; + } + + if (KERNEL_VERSION(curr_maj, curr_min, curr_rel) < + KERNEL_VERSION(req_maj, req_min, req_rel)) + Py_RETURN_FALSE; + + Py_RETURN_TRUE; +} + static PyMethodDef module_methods[] = { { .ml_name = "set_process_name", .ml_meth = (PyCFunction)module_set_process_name, .ml_flags = METH_VARARGS, }, + { + .ml_name = "check_kernel_version", + .ml_meth = (PyCFunction)module_check_kernel_version, + .ml_flags = METH_VARARGS, + }, { } };