diff options
| author | Mattia Rizzolo <mattia@debian.org> | 2017-07-14 01:09:29 (GMT) |
|---|---|---|
| committer | Mattia Rizzolo <mattia@debian.org> | 2017-07-14 01:12:07 (GMT) |
| commit | c8927db98131a129c5d7354bfe8a6b0886ca66f8 (patch) | |
| tree | f62e741d79e7e35001e747fee7ae99229b764855 | |
| parent | 51c801f9c4683781d3c68a8d10b51e3b7371a58c (diff) | |
Move from the deprecated platform.linux_distribution() to the external package distro
platform.linux_distribution() has been deprecated some time ago, and the
only viable alternative seems to be this external package.
Add it as an optioanl dependency, as without it distribution detection
(i.e. `diffoscope --list-tools`) won't work.
Also add it as a Debian dependency, as it's a very lightway package, and
the usefulness it brings are great.
Signed-off-by: Mattia Rizzolo <mattia@debian.org>
| -rw-r--r-- | debian/control | 2 | ||||
| -rw-r--r-- | diffoscope/exc.py | 5 | ||||
| -rw-r--r-- | diffoscope/external_tools.py | 2 | ||||
| -rw-r--r-- | diffoscope/tools.py | 12 | ||||
| -rw-r--r-- | setup.py | 3 | ||||
| -rw-r--r-- | tests/comparators/test_binary.py | 2 |
6 files changed, 20 insertions, 6 deletions
diff --git a/debian/control b/debian/control index a464f77..6cd947e 100644 --- a/debian/control +++ b/debian/control @@ -45,6 +45,7 @@ Build-Depends: python-argcomplete, python3-all, python3-debian <!nocheck>, + python3-distro <!nocheck>, python3-docutils, python3-guestfs <!nocheck>, python3-libarchive-c, @@ -77,6 +78,7 @@ Breaks: Replaces: debbindiff (<< 29), Depends: + python3-distro, python3-pkg-resources, ${misc:Depends}, ${python3:Depends}, diff --git a/diffoscope/exc.py b/diffoscope/exc.py index 64c5810..95fe791 100644 --- a/diffoscope/exc.py +++ b/diffoscope/exc.py @@ -18,6 +18,11 @@ # You should have received a copy of the GNU General Public License # along with diffoscope. If not, see <https://www.gnu.org/licenses/>. +try: + import distro +except ImportError: + distro = None + from .tools import get_current_os from .external_tools import EXTERNAL_TOOLS diff --git a/diffoscope/external_tools.py b/diffoscope/external_tools.py index adab119..9bfd1ab 100644 --- a/diffoscope/external_tools.py +++ b/diffoscope/external_tools.py @@ -24,7 +24,7 @@ EXTERNAL_TOOLS = { 'bsdtar': { 'debian': 'libarchive-tools', 'arch': 'libarchive', - 'Fedora': 'bsdtar', + 'fedora': 'bsdtar', 'FreeBSD': 'libarchive', }, 'bzip2': { diff --git a/diffoscope/tools.py b/diffoscope/tools.py index 7ffb603..148758b 100644 --- a/diffoscope/tools.py +++ b/diffoscope/tools.py @@ -18,8 +18,13 @@ # along with diffoscope. If not, see <https://www.gnu.org/licenses/>. import collections -import platform import functools +import platform + +try: + import distro +except ImportError: + distro = None from distutils.spawn import find_executable @@ -73,7 +78,6 @@ def tool_required(command): def get_current_os(): system = platform.system() if system == "Linux": - # FIXME: Will break under Python 3.7, see: - # https://docs.python.org/3/library/platform.html#platform.linux_distribution - return platform.linux_distribution()[0] + if distro: + return distro.id() return system # noqa @@ -45,6 +45,9 @@ setup( 'python-magic', 'libarchive-c', ], + extras_require={ + 'distro_detection': ['distro'], + }, classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers', diff --git a/tests/comparators/test_binary.py b/tests/comparators/test_binary.py index 865bbc2..d9e0bf7 100644 --- a/tests/comparators/test_binary.py +++ b/tests/comparators/test_binary.py @@ -167,7 +167,7 @@ def test_with_compare_details_and_tool_not_found(monkeypatch): { 'debian': 'some-package', 'arch': 'some-package', - 'Fedora': 'some-package', + 'fedora': 'some-package', 'FreeBSD': 'some-package' } ) |
