]> git.99rst.org Git - openwrt-packages.git/commitdiff
python-pexpect: add package
authorPhilip A. Prindeville <redacted>
Sun, 12 Jul 2026 03:09:05 +0000 (21:09 -0600)
committerPhilip Prindeville <redacted>
Mon, 13 Jul 2026 01:03:48 +0000 (19:03 -0600)
Useful for provisioning devices like modems that present themselves
via a serial device.

Signed-off-by: Philip A. Prindeville <redacted>
lang/python/python-pexpect/Makefile [new file with mode: 0644]
lang/python/python-pexpect/test.sh [new file with mode: 0644]

diff --git a/lang/python/python-pexpect/Makefile b/lang/python/python-pexpect/Makefile
new file mode 100644 (file)
index 0000000..22c9deb
--- /dev/null
@@ -0,0 +1,40 @@
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=python-pexpect
+PKG_VERSION:=4.9.0
+PKG_RELEASE:=1
+
+PYPI_NAME:=pexpect
+PKG_HASH:=ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f
+
+PKG_LICENSE:=ISC
+PKG_LICENSE_FILES:=LICENSE
+PKG_MAINTAINER:=Philip Prindeville <philipp@redfish-solutions.com>, Alexandru Ardelean <alex@shruggie.ro>
+
+PKG_BUILD_DEPENDS:=python-setuptools/host
+
+include ../pypi.mk
+include $(INCLUDE_DIR)/package.mk
+include ../python3-package.mk
+
+define Package/python3-pexpect
+  SECTION:=lang
+  CATEGORY:=Languages
+  SUBMENU:=Python
+  TITLE:=Pexpect is a Pure Python Expect-like module
+  URL:=https://github.com/pexpect/pexpect
+  DEPENDS:=+python3-light +python3-ptyprocess
+endef
+
+define Package/python3-pexpect/description
+  Pexpect is a Pure Python Expect-like module
+
+  Pexpect makes Python a better tool for controlling other applications.
+endef
+
+$(eval $(call Py3Package,python3-pexpect))
+$(eval $(call BuildPackage,python3-pexpect))
+$(eval $(call BuildPackage,python3-pexpect-src))
diff --git a/lang/python/python-pexpect/test.sh b/lang/python/python-pexpect/test.sh
new file mode 100644 (file)
index 0000000..35cb3a3
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+[ "$1" = "python3-pexpect" ] || exit 0
+
+# current installed version from python metadata
+installed_version="$(python3 -c 'import pexpect; print(pexpect.__version__)')"
+
+# use expected version from package metadata/environment
+expected_version="${PKG_VERSION}"
+
+if [ "$installed_version" != "$expected_version" ]; then
+    echo "Wrong version: $installed_version (expected $expected_version)"
+    exit 1
+fi
+
+python3 - << 'EOF'
+import pexpect
+
+pattern = "pexpect-test"
+child = pexpect.spawn('sh', ['-c', 'printf "%s\\n" "pexpect-test"'], encoding='utf-8')
+child.expect_exact(pattern)
+child.expect(pexpect.EOF)
+child.close()
+assert child.exitstatus == 0, f"child exited {child.exitstatus}"
+
+print("python3-pexpect OK")
+EOF
git clone https://git.99rst.org/PROJECT