bindings: python: tests: rename procname to system
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 20 Nov 2024 13:18:19 +0000 (14:18 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 25 Nov 2024 09:03:50 +0000 (10:03 +0100)
We'll be extending the functionality of that C extension with other
OS-level helpers so change its name to 'system'.

Reviewed-by: Vincent Fazio <vfazio@xes-inc.com>
Link: https://lore.kernel.org/r/20241120-drop-distutils-v1-2-7498e8b3babe@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
13 files changed:
bindings/python/MANIFEST.in
bindings/python/build_tests.py
bindings/python/tests/Makefile.am
bindings/python/tests/__main__.py
bindings/python/tests/procname/Makefile.am [deleted file]
bindings/python/tests/procname/__init__.py [deleted file]
bindings/python/tests/procname/_ext.pyi [deleted file]
bindings/python/tests/procname/ext.c [deleted file]
bindings/python/tests/system/Makefile.am [new file with mode: 0644]
bindings/python/tests/system/__init__.py [new file with mode: 0644]
bindings/python/tests/system/_ext.pyi [new file with mode: 0644]
bindings/python/tests/system/ext.c [new file with mode: 0644]
configure.ac

index f3a1ee8b26a5541d9314e4f802957ae3bff37494..dc7daeea0075c0ceb581b1247353ef0c0ebc3917 100644 (file)
@@ -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
index 1760257d5fbf35af5ce14743beccd36f499288dd..84cedfcc3d20449920b2a0daebed401d89ff9740 100644 (file)
@@ -11,7 +11,7 @@ polluted with artefacts in build/
 Builds:
 
     tests/gpiosim/_ext.<target>.so
-    tests/procname/_ext.<target>.so
+    tests/system/_ext.<target>.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"],
     }
index 3118d5f23fd9eef9ad474512e3d729a1272ff468..d6e3ea33c6a3a380b4d36e36a569b3271cf3309e 100644 (file)
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
 
-SUBDIRS = gpiosim procname
+SUBDIRS = gpiosim system
 
 EXTRA_DIST = \
        helpers.py \
index 8b4260dfeeb39495b9b98fb096f8d3559e7ad7d3..318e0df9f15629e7b05c2522e6f8473e644f4ab0 100644 (file)
@@ -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/procname/Makefile.am
deleted file mode 100644 (file)
index dbc8e64..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# SPDX-License-Identifier: LGPL-2.1-or-later
-# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-
-EXTRA_DIST = \
-       _ext.pyi \
-       ext.c \
-       __init__.py
diff --git a/bindings/python/tests/procname/__init__.py b/bindings/python/tests/procname/__init__.py
deleted file mode 100644 (file)
index 436ff40..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-
-from ._ext import set_process_name
-
-__all__ = ["set_process_name"]
diff --git a/bindings/python/tests/procname/_ext.pyi b/bindings/python/tests/procname/_ext.pyi
deleted file mode 100644 (file)
index df8bb15..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# SPDX-License-Identifier: LGPL-2.1-or-later
-# SPDX-FileCopyrightText: 2024 Vincent Fazio <vfazio@gmail.com>
-
-def set_process_name(name: str) -> None: ...
diff --git a/bindings/python/tests/procname/ext.c b/bindings/python/tests/procname/ext.c
deleted file mode 100644 (file)
index bf7d2fe..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-// SPDX-License-Identifier: LGPL-2.1-or-later
-// SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-
-#include <Python.h>
-#include <sys/prctl.h>
-
-static PyObject *
-module_set_process_name(PyObject *Py_UNUSED(self), PyObject *args)
-{
-       const char *name;
-       int ret;
-
-       ret = PyArg_ParseTuple(args, "s", &name);
-       if (!ret)
-               return NULL;
-
-       ret = prctl(PR_SET_NAME, name);
-       if (ret)
-               return PyErr_SetFromErrno(PyExc_OSError);
-
-       Py_RETURN_NONE;
-}
-
-static PyMethodDef module_methods[] = {
-       {
-               .ml_name = "set_process_name",
-               .ml_meth = (PyCFunction)module_set_process_name,
-               .ml_flags = METH_VARARGS,
-       },
-       { }
-};
-
-static PyModuleDef module_def = {
-       PyModuleDef_HEAD_INIT,
-       .m_name = "procname._ext",
-       .m_methods = module_methods,
-};
-
-PyMODINIT_FUNC PyInit__ext(void)
-{
-       return PyModule_Create(&module_def);
-}
diff --git a/bindings/python/tests/system/Makefile.am b/bindings/python/tests/system/Makefile.am
new file mode 100644 (file)
index 0000000..dbc8e64
--- /dev/null
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
+
+EXTRA_DIST = \
+       _ext.pyi \
+       ext.c \
+       __init__.py
diff --git a/bindings/python/tests/system/__init__.py b/bindings/python/tests/system/__init__.py
new file mode 100644 (file)
index 0000000..436ff40
--- /dev/null
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
+
+from ._ext import set_process_name
+
+__all__ = ["set_process_name"]
diff --git a/bindings/python/tests/system/_ext.pyi b/bindings/python/tests/system/_ext.pyi
new file mode 100644 (file)
index 0000000..df8bb15
--- /dev/null
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# SPDX-FileCopyrightText: 2024 Vincent Fazio <vfazio@gmail.com>
+
+def set_process_name(name: str) -> None: ...
diff --git a/bindings/python/tests/system/ext.c b/bindings/python/tests/system/ext.c
new file mode 100644 (file)
index 0000000..e7c1cc4
--- /dev/null
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
+
+#include <Python.h>
+#include <sys/prctl.h>
+
+static PyObject *
+module_set_process_name(PyObject *Py_UNUSED(self), PyObject *args)
+{
+       const char *name;
+       int ret;
+
+       ret = PyArg_ParseTuple(args, "s", &name);
+       if (!ret)
+               return NULL;
+
+       ret = prctl(PR_SET_NAME, name);
+       if (ret)
+               return PyErr_SetFromErrno(PyExc_OSError);
+
+       Py_RETURN_NONE;
+}
+
+static PyMethodDef module_methods[] = {
+       {
+               .ml_name = "set_process_name",
+               .ml_meth = (PyCFunction)module_set_process_name,
+               .ml_flags = METH_VARARGS,
+       },
+       { }
+};
+
+static PyModuleDef module_def = {
+       PyModuleDef_HEAD_INIT,
+       .m_name = "system._ext",
+       .m_methods = module_methods,
+};
+
+PyMODINIT_FUNC PyInit__ext(void)
+{
+       return PyModule_Create(&module_def);
+}
index 97fc83f4c51facad1f00b14a70386e5f48a18137..78a667040882cf7f4720dbdfa71030aeb3f44099 100644 (file)
@@ -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