Skip to content

Commit dde60d0

Browse files
authored
Merge pull request #34 from xlab-si/use-distro-package
Replace deprecated linux_distribution() method
2 parents b102831 + 6bdbc20 commit dde60d0

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

selinux/__init__.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
except ImportError: # py < 34
2121
from imp import reload # type: ignore # noqa
2222

23+
import distro
24+
2325

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

4749

48-
def linux_distribution():
49-
# see https://github.com/easybuilders/easybuild/wiki/OS_flavor_name_version
50-
try:
51-
return platform.linux_distribution()[0].lower()
52-
except Exception:
53-
return "N/A"
54-
55-
5650
def should_have_selinux():
57-
distro = linux_distribution()
5851
if platform.system() == "Linux" and os.path.isfile("/etc/selinux/config"):
59-
if distro not in ["ubuntu", "debian"]:
52+
if distro.id() not in ["ubuntu", "debian"]:
6053
return True
6154
return False
6255

setup.cfg

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,16 @@ python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
5858
packages = find:
5959
include_package_data = True
6060
zip_safe = True
61+
install_requires =
62+
distro>=1.3.0
63+
setuptools>=39.0
6164

6265
# These are required during `setup.py` run:
6366
setup_requires =
6467
setuptools_scm >= 1.15.0
6568
setuptools_scm_git_archive >= 1.0
6669
[options.packages.find]
6770
where = .
68-
install_requires = setuptools>=39.0
6971

7072
[flake8]
7173
exclude = build .tox

0 commit comments

Comments
 (0)