[OpenWrt-Devel] python ctypes.util.find_library cannot find libc
Andrew McConachie
andrew at depht.com
Mon Jan 16 14:41:03 EST 2017
Hi Alexandru and 郭涛,
Attached is the Makefile I made for python-iptables. I can work around
this by hardwiring library locations in the source of python-iptables,
but I'd rather do it the correct way. To reproduce this build an OpenWrt
system with this Makefile and then just create a simple Python script
with 'import iptc'.
I am cloning OpenWrt from Github and running make menuconfig;make to
build everything. My Github version is about 6 days old with the last
commit at 5ba298c.
I also found that /proc/sys/kernel/modprobe contains /sbin/modprobe,
while the modprobe binary is at /usr/sbin/modprobe. According to the
Debian man page on proc(5), /proc/sys/kernel/modprobe should point to
the modprobe binary. Googling about seems also to suggest that this file
should contain the location of the modprobe binary. So I would say this
is also a bug.
Thanks!
--Andrew
On 1/16/17 07:23, Alexandru Ardelean wrote:
> Hey Andrew & 郭涛
>
> Sorry I did not answer sooner.
>
> @Andrew: do you have a Makefile for the python-iptables packages ?
> I'd like to try to build it and see the issue. Or, are you just using
> that .py file ?
> Can you give a bit more input on which Python version you're using,
> and which OpenWrt version?
>
> If the issue is still present in the current packages trunk, I'd like to fix it.
> And if 郭涛's fix works, we can apply it to trunk.
>
> Thanks
> Alex
>
>
> On Mon, Jan 16, 2017 at 6:23 AM, 郭涛 <guotao945 at gmail.com> wrote:
>> I also meet this issue.
>> I fixed it using below change
>>
>> https://github.com/gt945/Netgear-D7800-Openwrt-Packages/commit/fab71ca0ebf36d5f7b495b96f14d459e794b7224
>>
>>
>> 2017-01-13 0:43 GMT+08:00 Andrew McConachie <andrew at depht.com>:
>>> Hi OpenWRT Devs,
>>>
>>> I'm building an OpenWRT package for python-iptables for a project I'm
>>> working on and getting this error message when attempting to use it.
>>>
>>> import iptc
>>> File "/usr/lib/python2.7/site-packages/iptc/__init__.py", line 10, in
>>> <module>
>>> from ip4tc import (is_table_available, Table, Chain, Rule, Match,
>>> Target,
>>> File "/usr/lib/python2.7/site-packages/iptc/ip4tc.py", line 13, in
>>> <module>
>>> from xtables import (XT_INV_PROTO, NFPROTO_IPV4, XTablesError, xtables,
>>> File "/usr/lib/python2.7/site-packages/iptc/xtables.py", line 677, in
>>> <module>
>>> _optind = ct.c_long.in_dll(_libc, "optind")
>>> AttributeError: 'NoneType' object has no attribute '_handle'
>>>
>>> You can view xtables.py here if you're curious.
>>> https://github.com/ldx/python-iptables/blob/master/iptc/xtables.py
>>>
>>> The problem is that my python-iptables package cannot find libc functions
>>> using ctypes.util.find_library(). I've tried building OpenWRT using both
>>> musl and eglibc but neither work. I've also tried building OpenWRT with
>>> objdump and ldconfig. When I include ldconfig via 'make menuconfig' it
>>> doesn't actually populate my OpenWRT image with an ldconfig binary. Maybe
>>> this is the problem?
>>>
>>> This bug report looks similar to my problem, but it's about MIPS and marked
>>> as closed.
>>> https://dev.openwrt.org/ticket/20123
>>>
>>> Any help or pointers would be much appreciated.
>>>
>>> Thanks,
>>> Andrew
>>> _______________________________________________
>>> openwrt-devel mailing list
>>> openwrt-devel at lists.openwrt.org
>>> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>> _______________________________________________
>> openwrt-devel mailing list
>> openwrt-devel at lists.openwrt.org
>> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
-------------- next part --------------
#
# Copyright (C) 2017 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=python-iptables
PKG_VERSION:=0.3.0
PKG_RELEASE:=1
PKG_MAINTAINER:=Andrew McConachie <andrew at depht.com>
PKG_LICENSE:=Apache-2.0
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=git://github.com/ldx/python-iptables.git
PKG_SOURCE_VERSION:=0250cebacfbca41b850a3728ec2c10ea21108434
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_DEPENDS:=python python-setuptools
include $(INCLUDE_DIR)/package.mk
$(call include_mk, python-package.mk)
define Package/python-iptables
SECTION:=language-python
CATEGORY:=Languages
SUBMENU:=Python
TITLE:=python-iptables
URL:=https://pypi.python.org/pypi/python-iptables
DEPENDS:=+python
endef
define Package/python-iptables/description
Python-iptables provides a pythonesque wrapper via python bindings to iptables under Linux. Interoperability with iptables is achieved via using the iptables C libraries (libiptc, libxtables, and the iptables extensions), not calling the iptables binary and parsing its output. It is meant primarily for dynamic and/or complex routers and firewalls, where rules are often updated or changed, or Python programs wish to interface with the Linux iptables framework.
endef
define Build/Compile
$(call Build/Compile/PyMod,,\
install --prefix=/usr --root="$(PKG_INSTALL_DIR)" \
)
endef
$(eval $(call PyPackage,python-iptables))
$(eval $(call BuildPackage,python-iptables))
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list