diff --git a/.gitignore b/.gitignore index 007d4c7..8298f14 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.idea /build /dist /setools.egg-info @@ -6,8 +7,7 @@ libqpol/policy_parse.c libqpol/policy_parse.h libqpol/policy_scan.c -setools/policyrep/qpol_wrap.c -setools/policyrep/qpol.py +/setools/policyrep/libpolicyrep.c *.so # Qt Generated Help files diff --git a/MANIFEST.in b/MANIFEST.in index a7d6576..ef886da 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,6 +7,8 @@ include libqpol/include/qpol/*.h include man/* include qhc/* include setools/perm_map +include setools/policyrep/*.pxi +include setools/policyrep/libpolicyrep.pyx include setoolsui/*.ui include setoolsui/apol/*.ui include setoolsui/apol/apol.qhc diff --git a/README.md b/README.md index caf4d0d..1463940 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ addition to the development packages from the above list: * bison * flex * libsepol 2.7+ -* SWIG 2.0.12+ or 3.0+ (3.0.8+ required for Python 3.5) +* cython 0.27+ To run SETools unit tests, the following packages are required, in addition to the above dependencies: diff --git a/setup.py b/setup.py index 87781fc..cc1397e 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,7 @@ import sys import os from os.path import join from contextlib import suppress +from Cython.Build import cythonize class QtHelpCommand(Command): @@ -107,8 +108,8 @@ if sys.platform.startswith('darwin'): else: macros=[] -ext_py_mods = [Extension('setools.policyrep._qpol', - ['setools/policyrep/qpol.i', +ext_py_mods = [Extension('setools.policyrep.libpolicyrep', + ['setools/policyrep/libpolicyrep.pyx', 'libqpol/avrule_query.c', 'libqpol/bool_query.c', 'libqpol/bounds_query.c', @@ -155,14 +156,11 @@ ext_py_mods = [Extension('setools.policyrep._qpol', '-Wnested-externs', '-Wold-style-definition', '-Wpointer-arith', - '-Wredundant-decls', '-Wstrict-prototypes', '-Wunknown-pragmas', '-Wwrite-strings', - '-Wno-missing-field-initializers', # SWIG 3.0.2 generates partially-initialized structs - '-Wno-unused-parameter', # SWIG generates functions with unused parameters + '-Wno-sign-compare', # Bison '-Wno-cast-qual', # libsepol uses const-to-nonconst casts - '-Wno-shadow', # SWIG generates shadow variables '-Wno-unreachable-code', # Bison generates unreachable code '-fno-exceptions'], swig_opts=['-Ilibqpol/include'], @@ -183,7 +181,7 @@ setup(name='setools', scripts=['apol', 'sediff', 'seinfo', 'seinfoflow', 'sesearch', 'sedta'], data_files=[(join(sys.prefix, 'share/man/man1'), glob.glob("man/*.1"))], package_data={'': ['*.ui', '*.qhc', '*.qch'], 'setools': ['perm_map']}, - ext_modules=ext_py_mods, + ext_modules=cythonize(ext_py_mods), test_suite='tests', license='GPLv2+, LGPLv2.1+', classifiers=[ diff --git a/tox.ini b/tox.ini index d3d1fbe..d7d5cc0 100644 --- a/tox.ini +++ b/tox.ini @@ -20,6 +20,7 @@ commands = pep8 --version [testenv:coverage] deps = networkx==2.0 coverage + cython>=0.27 commands = coverage --version coverage erase coverage run setup.py test @@ -28,6 +29,7 @@ commands = coverage --version [testenv:lint] deps = pylint networkx==2.0 + cython>=0.27 commands = {envpython} setup.py build_ext -i pylint --version pylint -E --rcfile .pylintrc setools tests seinfo seinfoflow sedta sesearch sediff @@ -36,5 +38,6 @@ commands = {envpython} setup.py build_ext -i [testenv] deps = networkx==2.0 + cython>=0.27 commands = {envpython} setup.py test recreate = True