ldx / python-iptables

Python bindings for iptables
730 stars 182 forks source link

Add '.so' as additional shared object suffix #303

Closed frankvanbever closed 4 years ago

frankvanbever commented 4 years ago

EXT_SUFFIX includes a platform information tag starting from Python 3.5 [0] For example:

    >>> sysconfig.get_config_var("EXT_SUFFIX")
    '.cpython-38-aarch64-linux-gnu.so'

This suffix only applies to cpython extensions i.e. not to the iptables shared objects.

Adding '.so' as an additional suffix for shared objects fixes the issue.

Fixes: Issue #301

Signed-off-by: Frank Vanbever frank.vanbever@essensium.com

[0] https://docs.python.org/3/whatsnew/3.5.html#build-and-c-api-changes

ldx commented 4 years ago

The builds fail with these changes:

$ python setup.py build
$ python setup.py install
$ sudo PATH=$PATH setup.py test
/usr/local/lib/python2.7/dist-packages/setuptools/dist.py:475: UserWarning: Normalizing '0.15.0-dev' to '0.15.0.dev0'
  normalized_version,
running test
running egg_info
writing python_iptables.egg-info/PKG-INFO
writing top-level names to python_iptables.egg-info/top_level.txt
writing dependency_links to python_iptables.egg-info/dependency_links.txt
reading manifest file 'python_iptables.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'README'
warning: no files found matching 'test.py'
writing manifest file 'python_iptables.egg-info/SOURCES.txt'
running build_ext
building 'libxtwrapper' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/libxtwrapper
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c libxtwrapper/wrapper.c -o build/temp.linux-x86_64-2.7/libxtwrapper/wrapper.o
creating build/lib.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/libxtwrapper/wrapper.o -o build/lib.linux-x86_64-2.7/libxtwrapper.so
copying build/lib.linux-x86_64-2.7/libxtwrapper.so -> 
Traceback (most recent call last):
  File "setup.py", line 47, in <module>
    license="Apache License, Version 2.0",
  File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python2.7/dist-packages/setuptools/command/test.py", line 228, in run
    self.run_tests()
  File "/usr/local/lib/python2.7/dist-packages/setuptools/command/test.py", line 250, in run_tests
    exit=False,
  File "/usr/lib/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/usr/lib/python2.7/unittest/main.py", line 149, in parseArgs
    self.createTests()
  File "/usr/lib/python2.7/unittest/main.py", line 158, in createTests
    self.module)
  File "/usr/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.7/unittest/loader.py", line 103, in loadTestsFromName
    return self.loadTestsFromModule(obj)
  File "/usr/local/lib/python2.7/dist-packages/setuptools/command/test.py", line 54, in loadTestsFromModule
    tests.append(self.loadTestsFromName(submodule))
  File "/usr/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "/home/travis/build/ldx/python-iptables/tests/test_iptc.py", line 4, in <module>
    import iptc
  File "/home/travis/build/ldx/python-iptables/iptc/__init__.py", line 10, in <module>
    from iptc.ip4tc import (is_table_available, Table, Chain, Rule, Match, Target, Policy, IPTCError)
  File "/home/travis/build/ldx/python-iptables/iptc/ip4tc.py", line 13, in <module>
    from .xtables import (XT_INV_PROTO, NFPROTO_IPV4, XTablesError, xtables,
  File "/home/travis/build/ldx/python-iptables/iptc/xtables.py", line 830, in <module>
    _throw = _lib_xtwrapper.throw_exception
AttributeError: 'NoneType' object has no attribute 'throw_exception'
coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.008%) to 58.493% when pulling 899d25c511c6ce779b7153e9ae2e41055b30b9c5 on essensium-mind:wrong-suffix into be6f5635271337f31be7973dc5103c3f0623ceec on ldx:master.

frankvanbever commented 4 years ago

@ldx thank's for the warning, I made a typo and luckily the tests caught it :smile:

ldx commented 4 years ago

Thanks!