diff --git a/.travis.yml b/.travis.yml index f4aeeac..dcd2f0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,25 +4,17 @@ language: python -# These environments have to be spelled -# out so that libselinux bindings get -# the right Python version. -matrix: - include: - - python: "2.7" - env: TOX_ENV=py27 - - python: "3.3" - env: TOX_ENV=py33 - - python: "3.4" - env: TOX_ENV=py34 - - python: "3.3" - env: TOX_ENV=coverage - - env: TOX_ENV=pep8 - - env: TOX_ENV=lint +env: + - TOX_ENV=py27 + - TOX_ENV=py33 + - TOX_ENV=py34 + - TOX_ENV=pep8 + - TOX_ENV=coverage + - TOX_ENV=lint +matrix: allow_failures: - - python: "3.3" - env: TOX_ENV=coverage + - env: TOX_ENV=coverage before_install: - lsb_release -a @@ -58,9 +50,6 @@ before_install: # error: declaration of 'index' shadows a global declarationo - sudo make CFLAGS="-O2 -pipe -fPIC -Wall" -C selinux-src install - # Install libselinux Python bindings. - - sudo make CFLAGS="-O2 -pipe -fPIC -Wall" -C selinux-src/libselinux install-pywrap - # Ubuntu 12.04's flex generates a redundant decl in libqpol - sed -i -e "/Wwrite-strings/s/,/, '-Wno-redundant-decls',/" setup.py diff --git a/README.md b/README.md index 8d7e840..2e4e0f5 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ To run SETools, the following packages are required: * Python 2.7 or 3.3+ * NetworkX 1.8+ * setuptools -* libselinux (including Python bindings) +* libselinux (Python bindings optional but recommended) * libbz2 To build SETools, the following development packages are required, in diff --git a/setools/policyrep/__init__.py b/setools/policyrep/__init__.py index 15d25e1..b22e07b 100644 --- a/setools/policyrep/__init__.py +++ b/setools/policyrep/__init__.py @@ -26,7 +26,10 @@ import logging from itertools import chain from errno import ENOENT -import selinux +try: + import selinux +except ImportError: + pass from . import qpol @@ -82,7 +85,10 @@ class SELinuxPolicy(object): if policyfile: self._load_policy(policyfile) else: - self._load_running_policy() + try: + self._load_running_policy() + except NameError: + raise RuntimeError("Loading the running policy requires libselinux Python bindings") def __repr__(self): return "".format(self.filename)