Skip to contentSkip to conversation

package/crudini: make it Python3 compatible

PATCH New Titouan Christophe 2 participants 7 messages Feb 5, 2020

lore
Share & tools
lore
#0 lore raw

cover package/crudini: make it Python3 compatible

This small series bumps the version of crudini and its dependency iniparse, such as it can now run on Python3 based systems.

It also adds a runtime test that performs a basic use-case run of the crudini tool, for both Python2 and Python3.

Titouan Christophe (3):
package/python-iniparse: bump to version 0.5 package/crudini: bump to version 0.9.3 support/testing: add runtime test for Crudini (py2 and py3)

 .gitlab-ci.yml                                |  2 +
 package/crudini/Config.in                     |  2 +-
 package/crudini/crudini.hash                  |  5 +--
 package/crudini/crudini.mk                    |  4 +-
 package/python-iniparse/Config.in             |  3 +-
 package/python-iniparse/python-iniparse.hash  |  6 +--
 package/python-iniparse/python-iniparse.mk    |  4 +-
 support/testing/tests/package/test_crudini.py | 40 +++++++++++++++++++
 8 files changed, 53 insertions(+), 13 deletions(-)
 create mode 100644 support/testing/tests/package/test_crudini.py
Signature · 1 line
2.24.1
#1 lore raw

PATCH 1/3 package/python-iniparse: bump to version 0.5

Also, iniparse now requires six.
This has been detected thanks to the runtime tests.

---
 package/python-iniparse/Config.in            | 3 ++-
 package/python-iniparse/python-iniparse.hash | 6 +++---
 package/python-iniparse/python-iniparse.mk   | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)
package/python-iniparse/Config.in +2 -1
index 65c1064927..8a9c5954c8 100644
@@ -1,6 +1,7 @@
 config BR2_PACKAGE_PYTHON_INIPARSE
 	bool "python-iniparse"
-	depends on BR2_PACKAGE_PYTHON
+	depends on BR2_PACKAGE_PYTHON || BR2_PACKAGE_PYTHON3
+	select BR2_PACKAGE_PYTHON_SIX # runtime
 	help
 	  iniparse is an INI parser for Python which is API compatible
 	  with the standard library's ConfigParser, preserves
package/python-iniparse/python-iniparse.hash +3 -3
index b843025521..238d41e06d 100644
@@ -1,7 +1,7 @@
-# md5 from https://pypi.python.org/pypi?:action=show_md5&digest=5e573e9e9733d97623881ce9bbe5eca6
-md5 5e573e9e9733d97623881ce9bbe5eca6 iniparse-0.4.tar.gz
+# From https://pypi.org/project/iniparse/#copy-hash-modal-5fdd923b-0592-4d2d-8b49-03472f948290
+md5 2054bab923df21107652d009f2373789 iniparse-0.5.tar.gz
+sha256  932e5239d526e7acb504017bb707be67019ac428a6932368e6851691093aa842  iniparse-0.5.tar.gz
 
 # sha256 locally computed
-sha256  abc1ee12d2cfb2506109072d6c21e40b6c75a3fe90a9c924327d80bc0d99c054  iniparse-0.4.tar.gz
 sha256  ff45637d8a96adc414179e502fbed40160e57205bf2e302140e79a0c71eceaa7  LICENSE
 sha256  9b02e3dfe433ccd2bd94636ef6eb08638b5a54deafe5f87a3d9d9104356c48e0  LICENSE-PSF
package/python-iniparse/python-iniparse.mk +2 -2
index 5c4e03c88c..d31a490bd8 100644
@@ -4,11 +4,11 @@
 #
 ################################################################################
 
-PYTHON_INIPARSE_VERSION = 0.4
+PYTHON_INIPARSE_VERSION = 0.5
 PYTHON_INIPARSE_SOURCE = iniparse-$(PYTHON_INIPARSE_VERSION).tar.gz
 PYTHON_INIPARSE_SITE = https://pypi.python.org/packages/source/i/iniparse
 PYTHON_INIPARSE_LICENSE = Python-2.0, MIT
 PYTHON_INIPARSE_LICENSE_FILES = LICENSE-PSF LICENSE
-PYTHON_INIPARSE_SETUP_TYPE = distutils
+PYTHON_INIPARSE_SETUP_TYPE = setuptools
 
 $(eval $(python-package))
Signature · 1 line
2.24.1
#2 lore raw

PATCH 1/3 package/python-iniparse: bump to version 0.5

Quoted 2 lines · On Wed, 5 Feb 2020 15:11:47 +0100 Titouan Christophe…

Also, iniparse now requires six.
This has been detected thanks to the runtime tests.

It would have been good to mention in the commit log that it now supports Python 3.

package/python-iniparse/Config.in line 3

Quoted 4 lines

config BR2_PACKAGE_PYTHON_INIPARSE

package/python-iniparse/Config.in +1 -1
 	bool "python-iniparse"
-	depends on BR2_PACKAGE_PYTHON
+	depends on BR2_PACKAGE_PYTHON || BR2_PACKAGE_PYTHON3

This is not needed when both are supported, since Python modules Config.in files are only included when python || python3, from package/Config.in.

Applied with the above issues fixed. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH 2/3 package/crudini: bump to version 0.9.3

In reply to Titouan Christophe

This release hasn't been published to pypi, so we switch to the Github release archive instead.

---
 package/crudini/Config.in    | 2 +-
 package/crudini/crudini.hash | 5 +----
 package/crudini/crudini.mk   | 4 ++--
 3 files changed, 4 insertions(+), 7 deletions(-)
package/crudini/Config.in +1 -1
index e4e26e52da..240848dffc 100644
@@ -1,6 +1,6 @@
 config BR2_PACKAGE_CRUDINI
 	bool "crudini"
-	depends on BR2_PACKAGE_PYTHON
+	depends on BR2_PACKAGE_PYTHON || BR2_PACKAGE_PYTHON3
 	select BR2_PACKAGE_PYTHON_INIPARSE # runtime
 	help
 	  A utility for handling ini files from the command line and
package/crudini/crudini.hash +1 -4
index 6c08223b83..6f2563dfdd 100644
@@ -1,6 +1,3 @@
-# md5 from https://pypi.python.org/pypi?:action=show_md5&digest=9b8500c90467f0a61c714fbe852c2a66
-md5    9b8500c90467f0a61c714fbe852c2a66 crudini-0.9.tar.gz
-
 # locally computed
-sha256  10512a5a2f7b54b42e48a1d00f0c6398947c2ba6c264b9fdef86677f0e949fd3  crudini-0.9.tar.gz
+sha256  e1b8125ac4373ece3bb0bb047ba9336e5bd55ed5d56b9729968058c9385ab546  crudini-0.9.3.tar.gz
 sha256  8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643  COPYING
package/crudini/crudini.mk +2 -2
index c03f55c374..7141e2b2a0 100644
@@ -4,8 +4,8 @@
 #
 ################################################################################
 
-CRUDINI_VERSION = 0.9
-CRUDINI_SITE = https://pypi.python.org/packages/b5/65/5588903472f30fa01ca4951be00c03a317b27bac4cd1e945bd16b2c1b6d3
+CRUDINI_VERSION = 0.9.3
+CRUDINI_SITE = $(call github,pixelb,crudini,$(CRUDINI_VERSION))
 CRUDINI_SETUP_TYPE = setuptools
 CRUDINI_LICENSE = GPL-2.0
 CRUDINI_LICENSE_FILES = COPYING
Signature · 1 line
2.24.1
#4 lore raw

PATCH 2/3 package/crudini: bump to version 0.9.3

Quoted 4 lines · On Wed, 5 Feb 2020 15:11:48 +0100 Titouan Christophe…

This release hasn't been published to pypi, so we switch to the Github release archive instead.

I've amended the commit log to mention that it now supports Python 3.x and applied.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

PATCH 3/3 support/testing: add runtime test for Crudini (py2 and py3)

In reply to Titouan Christophe

This also adds the new tests to the gitlab CI configuration.

---
 .gitlab-ci.yml                                |  2 +
 support/testing/tests/package/test_crudini.py | 40 +++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 support/testing/tests/package/test_crudini.py
.gitlab-ci.yml +2 -0
index c0140527db..aa64bb5fee 100644
@@ -375,6 +375,8 @@ tests.init.test_systemd.TestInitSystemSystemdRwFull: { extends: .runtime_test }
 tests.init.test_systemd.TestInitSystemSystemdRwIfupdown: { extends: .runtime_test }
 tests.init.test_systemd.TestInitSystemSystemdRwNetworkd: { extends: .runtime_test }
 tests.package.test_atop.TestAtop: { extends: .runtime_test }
+tests.package.test_crudini.TestCrudiniPy2: {extends: .runtime_test}
+tests.package.test_crudini.TestCrudiniPy3: {extends: .runtime_test}
 tests.package.test_docker_compose.TestDockerCompose: { extends: .runtime_test }
 tests.package.test_dropbear.TestDropbear: { extends: .runtime_test }
 tests.package.test_glxinfo.TestGlxinfo: { extends: .runtime_test }
support/testing/tests/package/test_crudini.py new file +40 -0
new file mode 100644
index 0000000000..498c5982cc
@@ -0,0 +1,40 @@
+import os
+from tests.package.test_python import TestPythonPackageBase
+
+
+INI_FILE_CONTENT = """
+[section]
+param = this-is-the-magic-value
+other = dont care
+"""
+
+
+class TestCrudiniBase(TestPythonPackageBase):
+    config = TestPythonPackageBase.config + "\nBR2_PACKAGE_CRUDINI=y"
+
+    def test_run(self):
+        img = os.path.join(self.builddir, "images", "rootfs.cpio")
+        self.emulator.boot(arch="armv5", kernel="builtin",
+                           options=["-initrd", img])
+
+        self.emulator.login()
+
+        # 1. Create some sample .ini file
+        cmd = "echo -e '%s' > config.ini" % INI_FILE_CONTENT
+        _, ret = self.emulator.run(cmd)
+        self.assertEqual(ret, 0)
+
+        # 2. Attempt to get the value
+        out, ret = self.emulator.run("crudini --get config.ini section param")
+        self.assertEqual(ret, 0)
+        self.assertEqual(out, ['this-is-the-magic-value'])
+
+
+class TestCrudiniPy2(TestCrudiniBase):
+    __test__ = True
+    config = TestCrudiniBase.config + "\nBR2_PACKAGE_PYTHON=y"
+
+
+class TestCrudiniPy3(TestCrudiniBase):
+    __test__ = True
+    config = TestCrudiniBase.config + "\nBR2_PACKAGE_PYTHON3=y"
Signature · 1 line
2.24.1
#6 lore raw

PATCH 3/3 support/testing: add runtime test for Crudini (py2 and py3)

Quoted 8 lines · On Wed, 5 Feb 2020 15:11:49 +0100 Titouan Christophe…

This also adds the new tests to the gitlab CI configuration.

---
 .gitlab-ci.yml                                |  2 +
 support/testing/tests/package/test_crudini.py | 40 +++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 support/testing/tests/package/test_crudini.py

We like to have an entry in the DEVELOPERS file for tests so that you receive an e-mail notification when the test fails in our CI.

.gitlab-ci.yml tests.init.test_systemd.TestInitSystemSystemdRwFull: { extends: .runtime_test } · line 379

Quoted 10 lines
.gitlab-ci.yml +2 -0
index c0140527db..aa64bb5fee 100644
@@ -375,6 +375,8 @@ tests.init.test_systemd.TestInitSystemSystemdRwFull: { extends: .runtime_test }
 tests.init.test_systemd.TestInitSystemSystemdRwIfupdown: { extends: .runtime_test }
 tests.init.test_systemd.TestInitSystemSystemdRwNetworkd: { extends: .runtime_test }
 tests.package.test_atop.TestAtop: { extends: .runtime_test }
+tests.package.test_crudini.TestCrudiniPy2: {extends: .runtime_test}
+tests.package.test_crudini.TestCrudiniPy3: {extends: .runtime_test}

You wrote this by hand, but it is auto-generated by "make .gitlab-ci.yml", with a slightly different formatting.

.gitlab-ci.yml tests.init.test_systemd.TestInitSystemSystemdRwFull: { extends: .runtime_test } · line 381

Quoted 2 lines
.gitlab-ci.yml +2 -0
+class TestCrudiniBase(TestPythonPackageBase):
+    config = TestPythonPackageBase.config + "\nBR2_PACKAGE_CRUDINI=y"

We like to use multiline strings to add config options.

I've fixed the above issues and applied to master.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com