Skip to contentSkip to conversation

package/python-nmcli: new package

PATCH In review Alexandre Ondet 2 participants 6 messages Apr 28 – Jun 23

lore
Share & tools
lore
#0 lore raw

PATCH 6/13 package/python-nmcli: new package

---
 package/Config.in                      |  1 +
 package/python-nmcli/Config.in         |  6 ++++++
 package/python-nmcli/python-nmcli.hash |  3 +++
 package/python-nmcli/python-nmcli.mk   | 14 ++++++++++++++
 4 files changed, 24 insertions(+)
 create mode 100644 package/python-nmcli/Config.in
 create mode 100644 package/python-nmcli/python-nmcli.hash
 create mode 100644 package/python-nmcli/python-nmcli.mk
package/Config.in +1 -0
index 754bdee9f4..83c9e0809c 100644
@@ -1261,6 +1261,7 @@ menu "External python modules"
 	source "package/python-netifaces/Config.in"
 	source "package/python-networkmanager/Config.in"
 	source "package/python-networkx/Config.in"
+	source "package/python-nmcli/Config.in"
 	source "package/python-numpy/Config.in"
 	source "package/python-oauthlib/Config.in"
 	source "package/python-opcua-asyncio/Config.in"
package/python-nmcli/Config.in new file +6 -0
new file mode 100644
index 0000000000..acdb6a1423
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_PYTHON_NMCLI
+	bool "python-nmcli"
+	help
+	  Python wrapper for nmcli (NetworkManager).
+
+	  https://github.com/ushiboy/nmcli
\ No newline at end of file
package/python-nmcli/python-nmcli.hash new file +3 -0
new file mode 100644
index 0000000000..d11842e3e8
@@ -0,0 +1,3 @@
+# From https://pypi.org/pypi/nmcli/1.7.0/json
+sha256  4fb17b6c33d276a264a27b7109fa1d70987570536fa8852b51830f9f7732f982  nmcli-1.7.0.tar.gz
+sha256  9dbbc4debacc85f5f5f074614cd9cadd61da09eaa19f98f6bbb5463c34133820  LICENSE.txt
\ No newline at end of file
package/python-nmcli/python-nmcli.mk new file +14 -0
new file mode 100644
index 0000000000..449131974d
@@ -0,0 +1,14 @@
+################################################################################
+#
+# python-nmcli
+#
+################################################################################
+
+PYTHON_NMCLI_VERSION = 1.7.0
+PYTHON_NMCLI_SOURCE = nmcli-$(PYTHON_NMCLI_VERSION).tar.gz
+PYTHON_NMCLI_SITE = https://files.pythonhosted.org/packages/source/n/nmcli
+PYTHON_NMCLI_SETUP_TYPE = setuptools
+PYTHON_NMCLI_LICENSE = MIT
+PYTHON_NMCLI_LICENSE_FILES = LICENSE.txt
+
+$(eval $(python-package))
\ No newline at end of file
Signature · 6 lines
2.53.0.windows.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hi Alexandre,

some comments below.

Quoted 29 lines · Alexandre Ondet
---
  package/Config.in                      |  1 +
  package/python-nmcli/Config.in         |  6 ++++++
  package/python-nmcli/python-nmcli.hash |  3 +++
  package/python-nmcli/python-nmcli.mk   | 14 ++++++++++++++
  4 files changed, 24 insertions(+)

create mode 100644 package/python-nmcli/Config.in create mode 100644 package/python-nmcli/python-nmcli.hash create mode 100644 package/python-nmcli/python-nmcli.mk

package/Config.in +1 -0
index 754bdee9f4..83c9e0809c 100644
@@ -1261,6 +1261,7 @@ menu "External python modules"
  	source "package/python-netifaces/Config.in"
  	source "package/python-networkmanager/Config.in"
  	source "package/python-networkx/Config.in"
+	source "package/python-nmcli/Config.in"
  	source "package/python-numpy/Config.in"
  	source "package/python-oauthlib/Config.in"
  	source "package/python-opcua-asyncio/Config.in"
package/python-nmcli/Config.in new file +0 -0
new file mode 100644
index 0000000000..acdb6a1423

package/python-nmcli/Config.in line 2

Quoted 2 lines
package/python-nmcli/Config.in new file +2 -0
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_PYTHON_NMCLI
+	bool "python-nmcli"

This should depend on BR2_PACKAGE_NETWORK_MANAGER, as it probably doesn't make any sense to have this package without also having network-manager on your device?

And then you can select BR2_PACKAGE_NETWORK_MANAGER_CLI to ensure the nmcli part also gets enabled automatically when you enable python-nmcli.

Quoted 26 lines
package/python-nmcli/Config.in new file +4 -0
+	help
+	  Python wrapper for nmcli (NetworkManager).
+
+	  https://github.com/ushiboy/nmcli
\ No newline at end of file
package/python-nmcli/python-nmcli.hash new file +3 -0
new file mode 100644
index 0000000000..d11842e3e8
@@ -0,0 +1,3 @@
+# From https://pypi.org/pypi/nmcli/1.7.0/json
+sha256  4fb17b6c33d276a264a27b7109fa1d70987570536fa8852b51830f9f7732f982  nmcli-1.7.0.tar.gz
+sha256  9dbbc4debacc85f5f5f074614cd9cadd61da09eaa19f98f6bbb5463c34133820  LICENSE.txt
\ No newline at end of file
package/python-nmcli/python-nmcli.mk new file +5 -0
new file mode 100644
index 0000000000..449131974d
@@ -0,0 +1,14 @@
+################################################################################
+#
+# python-nmcli
+#
+################################################################################

package/python-nmcli/python-nmcli.mk line 14

Quoted 10 lines
package/python-nmcli/python-nmcli.mk new file +9 -0
+
+PYTHON_NMCLI_VERSION = 1.7.0
+PYTHON_NMCLI_SOURCE = nmcli-$(PYTHON_NMCLI_VERSION).tar.gz
+PYTHON_NMCLI_SITE = https://files.pythonhosted.org/packages/source/n/nmcli
+PYTHON_NMCLI_SETUP_TYPE = setuptools
+PYTHON_NMCLI_LICENSE = MIT
+PYTHON_NMCLI_LICENSE_FILES = LICENSE.txt
+
+$(eval $(python-package))
\ No newline at end of file

Please make sure your files all have a newline at the end.

A general note for these type of packages with runtime dependencies (which applies to python packages in general but also for this specifically for the network-manager dependency): it would be really good to add a runtime test together with the package [1]. It helps to test the package when reviewing and ensures it doesn't silently break with some network-manager update.

I've marked this as changes requested in patchwork.

Best,
Marcus

[1] https://nightly.buildroot.org/manual.html#_using_the_runtime_tests_framework
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw

Hi Marcus,

Thanks for the review. Updated patch attached:

- BR2_PACKAGE_NETWORK_MANAGER dependency and BR2_PACKAGE_NETWORK_MANAGER_CLI select
- trailing newlines in all package files
- runtime test exercising nmcli.general.status() with systemd + NetworkManager

Best regards,
Alexandre
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw

PATCH 1/1 package/python-nmcli: fix dependencies and add runtime test

Depend on network-manager and select nmcli support so the Python wrapper can invoke the nmcli binary at runtime. Add a runtime test that boots with systemd and exercises nmcli.general.status().

---
 package/python-nmcli/Config.in                |  4 +++-
 package/python-nmcli/python-nmcli.hash        |  2 +-
 package/python-nmcli/python-nmcli.mk          |  2 +-
 .../tests/package/sample_python_nmcli.py      |  8 +++++++
 .../tests/package/test_python_nmcli.py        | 24 +++++++++++++++++++
 5 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 support/testing/tests/package/sample_python_nmcli.py
 create mode 100644 support/testing/tests/package/test_python_nmcli.py
package/python-nmcli/Config.in +3 -1
index acdb6a1423..ad282f0584 100644
@@ -1,6 +1,8 @@
 config BR2_PACKAGE_PYTHON_NMCLI
 	bool "python-nmcli"
+	depends on BR2_PACKAGE_NETWORK_MANAGER # runtime
+	select BR2_PACKAGE_NETWORK_MANAGER_CLI
 	help
 	  Python wrapper for nmcli (NetworkManager).
 
-	  https://github.com/ushiboy/nmcli
\ No newline at end of file
+	  https://github.com/ushiboy/nmcli
package/python-nmcli/python-nmcli.hash +1 -1
index d11842e3e8..5bf087fde9 100644
@@ -1,3 +1,3 @@
 # From https://pypi.org/pypi/nmcli/1.7.0/json
 sha256  4fb17b6c33d276a264a27b7109fa1d70987570536fa8852b51830f9f7732f982  nmcli-1.7.0.tar.gz
-sha256  9dbbc4debacc85f5f5f074614cd9cadd61da09eaa19f98f6bbb5463c34133820  LICENSE.txt
\ No newline at end of file
+sha256  9dbbc4debacc85f5f5f074614cd9cadd61da09eaa19f98f6bbb5463c34133820  LICENSE.txt
package/python-nmcli/python-nmcli.mk +1 -1
index 449131974d..63f258238b 100644
@@ -11,4 +11,4 @@ PYTHON_NMCLI_SETUP_TYPE = setuptools
 PYTHON_NMCLI_LICENSE = MIT
 PYTHON_NMCLI_LICENSE_FILES = LICENSE.txt
 
-$(eval $(python-package))
\ No newline at end of file
+$(eval $(python-package))
support/testing/tests/package/sample_python_nmcli.py new file +8 -0
new file mode 100644
index 0000000000..5fa8dee0c4
@@ -0,0 +1,8 @@
+#!/usr/bin/env python3
+
+import nmcli
+
+general = nmcli.general.status()
+print(general)
+
+assert general.state is not None
support/testing/tests/package/test_python_nmcli.py new file +24 -0
new file mode 100644
index 0000000000..20fffa2356
@@ -0,0 +1,24 @@
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPy3Nmcli(TestPythonPackageBase):
+    __test__ = True
+    # Can't use TestPythonPackageBase.config because we need headers
+    # >= 5.4 for network-manager, so we have to use the bleeding-edge
+    # toolchain.
+    config = \
+        """
+        BR2_arm=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV5_EABI_GLIBC_BLEEDING_EDGE=y
+        BR2_PACKAGE_PYTHON3=y
+        BR2_INIT_SYSTEMD=y
+        BR2_PACKAGE_NETWORK_MANAGER=y
+        BR2_PACKAGE_PYTHON_NMCLI=y
+        BR2_TARGET_ROOTFS_CPIO=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+    sample_scripts = ["tests/package/sample_python_nmcli.py"]
+
+    timeout = 30
Signature · 6 lines
2.53.0.windows.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw
In reply to Alexandre Ondet

Hi Alexandre,

Quoted 3 lines · Alexandre Ondet

Hi Marcus,

Thanks for the review. Updated patch attached:

Thanks for this iteration, but please send a proper v2, not an incremental patch.
See: https://nightly.buildroot.org/manual.html#submitting-patches

Quoted 4 lines

- BR2_PACKAGE_NETWORK_MANAGER dependency and BR2_PACKAGE_NETWORK_MANAGER_CLI select
- trailing newlines in all package files
- runtime test exercising nmcli.general.status() with systemd + NetworkManager

Can you also add yourself to the DEVELOPERS file for the new package and test files you are adding? See https://nightly.buildroot.org/manual.html#DEVELOPERS

Quoted 3 lines

Best regards,
Alexandre

Best,
Marcus
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#5 lore raw

PATCH v2 6/13 package/python-nmcli: new package

---
Changes v1 -> v2:
- depend on network-manager and select nmcli support
- add a runtime test for the python nmcli module
- add DEVELOPERS entries for the package and runtime test
- fix missing trailing newlines in package files

 DEVELOPERS                                    |  5 ++++
 package/Config.in                             |  1 +
 package/python-nmcli/Config.in                |  8 +++++++
 package/python-nmcli/python-nmcli.hash        |  3 +++
 package/python-nmcli/python-nmcli.mk          | 14 +++++++++++
 .../tests/package/sample_python_nmcli.py      |  8 +++++++
 .../tests/package/test_python_nmcli.py        | 24 +++++++++++++++++++
 7 files changed, 63 insertions(+)
 create mode 100644 package/python-nmcli/Config.in
 create mode 100644 package/python-nmcli/python-nmcli.hash
 create mode 100644 package/python-nmcli/python-nmcli.mk
 create mode 100644 support/testing/tests/package/sample_python_nmcli.py
 create mode 100644 support/testing/tests/package/test_python_nmcli.py
DEVELOPERS +5 -0
index c6c228ae91..fb26c25928 100644
@@ -147,6 +147,11 @@ N:	Alexandre Esse <[email protected]>
 F:	package/kvazaar/
 F:	package/v4l2loopback/
 
+N:	Alexandre Ondet <[email protected]>
+F:	package/python-nmcli/
+F:	support/testing/tests/package/sample_python_nmcli.py
+F:	support/testing/tests/package/test_python_nmcli.py
+
 N:	Alexey Brodkin <[email protected]>
 F:	board/cubietech/cubieboard2/
 F:	configs/cubieboard2_defconfig
package/Config.in +1 -0
index 754bdee9f4..83c9e0809c 100644
@@ -1261,6 +1261,7 @@ menu "External python modules"
 	source "package/python-netifaces/Config.in"
 	source "package/python-networkmanager/Config.in"
 	source "package/python-networkx/Config.in"
+	source "package/python-nmcli/Config.in"
 	source "package/python-numpy/Config.in"
 	source "package/python-oauthlib/Config.in"
 	source "package/python-opcua-asyncio/Config.in"
package/python-nmcli/Config.in new file +8 -0
new file mode 100644
index 0000000000..a860f511c4
@@ -0,0 +1,8 @@
+config BR2_PACKAGE_PYTHON_NMCLI
+	bool "python-nmcli"
+	depends on BR2_PACKAGE_NETWORK_MANAGER # runtime
+	select BR2_PACKAGE_NETWORK_MANAGER_CLI # runtime
+	help
+	  Python wrapper for nmcli (NetworkManager).
+
+	  https://github.com/ushiboy/nmcli
package/python-nmcli/python-nmcli.hash new file +3 -0
new file mode 100644
index 0000000000..a93e026dce
@@ -0,0 +1,3 @@
+# From https://pypi.org/pypi/nmcli/1.7.0/json
+sha256  4fb17b6c33d276a264a27b7109fa1d70987570536fa8852b51830f9f7732f982  nmcli-1.7.0.tar.gz
+sha256  9dbbc4debacc85f5f5f074614cd9cadd61da09eaa19f98f6bbb5463c34133820  LICENSE.txt
package/python-nmcli/python-nmcli.mk new file +14 -0
new file mode 100644
index 0000000000..005519f0c1
@@ -0,0 +1,14 @@
+################################################################################
+#
+# python-nmcli
+#
+################################################################################
+
+PYTHON_NMCLI_VERSION = 1.7.0
+PYTHON_NMCLI_SOURCE = nmcli-$(PYTHON_NMCLI_VERSION).tar.gz
+PYTHON_NMCLI_SITE = https://files.pythonhosted.org/packages/source/n/nmcli
+PYTHON_NMCLI_SETUP_TYPE = setuptools
+PYTHON_NMCLI_LICENSE = MIT
+PYTHON_NMCLI_LICENSE_FILES = LICENSE.txt
+
+$(eval $(python-package))
support/testing/tests/package/sample_python_nmcli.py new file +8 -0
new file mode 100644
index 0000000000..5fa8dee0c4
@@ -0,0 +1,8 @@
+#!/usr/bin/env python3
+
+import nmcli
+
+general = nmcli.general.status()
+print(general)
+
+assert general.state is not None
support/testing/tests/package/test_python_nmcli.py new file +24 -0
new file mode 100644
index 0000000000..20fffa2356
@@ -0,0 +1,24 @@
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPy3Nmcli(TestPythonPackageBase):
+    __test__ = True
+    # Can't use TestPythonPackageBase.config because we need headers
+    # >= 5.4 for network-manager, so we have to use the bleeding-edge
+    # toolchain.
+    config = \
+        """
+        BR2_arm=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV5_EABI_GLIBC_BLEEDING_EDGE=y
+        BR2_PACKAGE_PYTHON3=y
+        BR2_INIT_SYSTEMD=y
+        BR2_PACKAGE_NETWORK_MANAGER=y
+        BR2_PACKAGE_PYTHON_NMCLI=y
+        BR2_TARGET_ROOTFS_CPIO=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+    sample_scripts = ["tests/package/sample_python_nmcli.py"]
+
+    timeout = 30
Signature · 6 lines
2.53.0.windows.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot