diff --git a/DEVELOPERS b/DEVELOPERS index f6621e9670..06d311a085 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1986,6 +1986,7 @@ F: configs/galileo_defconfig N: Nicolas Carrier F: package/php-xdebug/ +F: package/python-augeas/ N: Nicolas Cavallari F: package/libgit2/ @@ -2672,6 +2673,7 @@ F: package/pkg-autotools.mk F: package/pkg-generic.mk F: package/python/ F: package/python3/ +F: package/python-augeas/ F: package/python-mad/ F: package/python-serial/ F: package/qextserialport/ diff --git a/package/Config.in b/package/Config.in index cb8ece4919..35e6d4d493 100644 --- a/package/Config.in +++ b/package/Config.in @@ -908,6 +908,7 @@ menu "External python modules" source "package/python-async-lru/Config.in" source "package/python-async-timeout/Config.in" source "package/python-attrs/Config.in" + source "package/python-augeas/Config.in" source "package/python-autobahn/Config.in" source "package/python-automat/Config.in" source "package/python-avro/Config.in" diff --git a/package/python-augeas/0001-Use-CFFI-in-out-of-line-API-mode-49.patch b/package/python-augeas/0001-Use-CFFI-in-out-of-line-API-mode-49.patch new file mode 100644 index 0000000000..da9093d723 --- /dev/null +++ b/package/python-augeas/0001-Use-CFFI-in-out-of-line-API-mode-49.patch @@ -0,0 +1,101 @@ +From 9de73fefbe83c74840a93c039258845c49271b9b Mon Sep 17 00:00:00 2001 +From: Jeffery To +Date: Sun, 8 Nov 2020 21:51:09 +0800 +Subject: [PATCH] Use CFFI in out-of-line API mode (#49) + +Currently, ffi.py is called during setup to generate augeas.py; this +file would normally be used for out-of-line ABI mode. ffi.py is also +imported at run-time, instead of the generated augeas.py, and used in +in-line ABI mode. + +This changes usage of CFFI to out-of-line API mode (CFFI's "main mode of +usage"): ffi.py is called during setup to generate _augeas.abi3.so (a C +extension module); this generated module is imported at run-time. + +With this change, the headers/development files for augeas (i.e. +libaugeas-dev on Debian, augeas-devel on Fedora, etc.) and the C +compiler are required for build/setup. (These were not necessary +previously.) + +Closes https://github.com/hercules-team/python-augeas/issues/48. + +Upstream: commit 712c2028568df7760bc98d95577e35709078bfea +Signed-off-by: Thomas Petazzoni +--- + augeas/__init__.py | 2 +- + augeas/ffi.py | 27 ++++++++++++++++++++++----- + setup.py | 1 + + 3 files changed, 24 insertions(+), 6 deletions(-) + +diff --git a/augeas/__init__.py b/augeas/__init__.py +index 9bd97bf..1c0f580 100644 +--- a/augeas/__init__.py ++++ b/augeas/__init__.py +@@ -32,7 +32,7 @@ format and the transformation into a tree. + + from sys import version_info as _pyver + +-from augeas.ffi import ffi, lib ++from _augeas import ffi, lib + + __author__ = "Nathaniel McCallum " + __credits__ = """Jeff Schroeder +diff --git a/augeas/ffi.py b/augeas/ffi.py +index a24daf5..1931764 100644 +--- a/augeas/ffi.py ++++ b/augeas/ffi.py +@@ -1,9 +1,28 @@ ++import os ++import subprocess ++ + from cffi import FFI + ++def get_include_dirs(): ++ XML2_CONFIG = os.environ.get('XML2_CONFIG', 'xml2-config') ++ PKG_CONFIG = os.environ.get('PKG_CONFIG', 'pkg-config') ++ try: ++ stdout = subprocess.check_output([XML2_CONFIG, '--cflags']) ++ except (OSError, subprocess.CalledProcessError): ++ try: ++ stdout = subprocess.check_output([PKG_CONFIG, '--cflags', 'libxml-2.0']) ++ except (OSError, subprocess.CalledProcessError): ++ stdout = b'' ++ cflags = stdout.decode('utf-8').split() ++ return [cflag[2:] for cflag in cflags if cflag.startswith('-I')] ++ + ffi = FFI() +-ffi.set_source("augeas", +- None, +- libraries=['augeas']) ++ffi.set_source("_augeas", ++ """ ++ #include ++ """, ++ libraries=['augeas'], ++ include_dirs=get_include_dirs()) + + ffi.cdef(""" + typedef struct augeas augeas; +@@ -44,7 +63,5 @@ const char *aug_error_details(augeas *aug); + void free(void *); + """) + +-lib = ffi.dlopen("augeas") +- + if __name__ == "__main__": + ffi.compile(verbose=True) +diff --git a/setup.py b/setup.py +index 7d55877..17f9516 100755 +--- a/setup.py ++++ b/setup.py +@@ -22,6 +22,7 @@ setup(name=name, + setup_requires=["cffi>=1.0.0"], + cffi_modules=["augeas/ffi.py:ffi"], + install_requires=["cffi>=1.0.0"], ++ zip_safe=False, + url="http://augeas.net/", + classifiers=[ + "Programming Language :: Python :: 2.7", +-- +2.31.1 + diff --git a/package/python-augeas/Config.in b/package/python-augeas/Config.in new file mode 100644 index 0000000000..3503a83b3b --- /dev/null +++ b/package/python-augeas/Config.in @@ -0,0 +1,8 @@ +config BR2_PACKAGE_PYTHON_AUGEAS + bool "python-augeas" + depends on BR2_PACKAGE_AUGEAS + select BR2_PACKAGE_PYTHON_CFFI # runtime + help + Pure python bindings for Augeas. + + https://github.com/hercules-team/python-augeas diff --git a/package/python-augeas/python-augeas.hash b/package/python-augeas/python-augeas.hash new file mode 100644 index 0000000000..f4f4209875 --- /dev/null +++ b/package/python-augeas/python-augeas.hash @@ -0,0 +1,3 @@ +# Locally computed +sha256 1a1d2cdaf2ad4c091ed5ec7976c52d16e14ecfbf40b1bdcaced2465255fb0f87 python-augeas-1.1.0.tar.gz +sha256 dc626520dcd53a22f727af3ee42c770e56c97a64fe3adb063799d8ab032fe551 COPYING diff --git a/package/python-augeas/python-augeas.mk b/package/python-augeas/python-augeas.mk new file mode 100644 index 0000000000..7adaa84f49 --- /dev/null +++ b/package/python-augeas/python-augeas.mk @@ -0,0 +1,21 @@ +################################################################################ +# +# python-augeas +# +################################################################################ + +PYTHON_AUGEAS_VERSION = 1.1.0 +PYTHON_AUGEAS_SITE = $(call github,hercules-team,python-augeas,v$(PYTHON_AUGEAS_VERSION)) +PYTHON_AUGEAS_SETUP_TYPE = setuptools +PYTHON_AUGEAS_LICENSE = LGPL-2.1+ +PYTHON_AUGEAS_LICENSE_FILES = COPYING +PYTHON_AUGEAS_DEPENDENCIES = augeas host-python-cffi host-pkgconf +# This will tell python-augeas to not call xml2-config, and instead +# use pkg-config to find libxml2. libxml2 is an indirect dependency of +# augeas, which is why it's not in our dependencies. It's odd that +# python-augeas searches for libxml2, but that's what it +# does. Question asked in the pull request at +# https://github.com/hercules-team/python-augeas/pull/49. +PYTHON_AUGEAS_ENV = XML2_CONFIG=/bin/false + +$(eval $(python-package))