Skip to content

Commit

Permalink
Merge pull request #34 from xlab-si/use-distro-package
Browse files Browse the repository at this point in the history
Replace deprecated linux_distribution() method
  • Loading branch information
ssbarnea authored Oct 23, 2019
2 parents b102831 + 6bdbc20 commit dde60d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
13 changes: 3 additions & 10 deletions selinux/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
except ImportError: # py < 34
from imp import reload # type: ignore # noqa

import distro


class add_path(object):
"""Context manager for adding path to sys.path"""
Expand All @@ -45,18 +47,9 @@ def is_selinux_mls_enabled():
return 0


def linux_distribution():
# see https://github.com/easybuilders/easybuild/wiki/OS_flavor_name_version
try:
return platform.linux_distribution()[0].lower()
except Exception:
return "N/A"


def should_have_selinux():
distro = linux_distribution()
if platform.system() == "Linux" and os.path.isfile("/etc/selinux/config"):
if distro not in ["ubuntu", "debian"]:
if distro.id() not in ["ubuntu", "debian"]:
return True
return False

Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
packages = find:
include_package_data = True
zip_safe = True
install_requires =
distro>=1.3.0
setuptools>=39.0

# These are required during `setup.py` run:
setup_requires =
setuptools_scm >= 1.15.0
setuptools_scm_git_archive >= 1.0
[options.packages.find]
where = .
install_requires = setuptools>=39.0

[flake8]
exclude = build .tox
Expand Down

0 comments on commit dde60d0

Please sign in to comment.