[diffoscope] 01/03: Move from the deprecated platform.linux_distribution() to the external package distro
Mattia Rizzolo
mattia at debian.org
Fri Jul 14 12:01:50 CEST 2017
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to branch master
in repository diffoscope.
commit c8927db98131a129c5d7354bfe8a6b0886ca66f8
Author: Mattia Rizzolo <mattia at debian.org>
Date: Fri Jul 14 03:09:29 2017 +0200
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 at debian.org>
---
debian/control | 2 ++
diffoscope/exc.py | 5 +++++
diffoscope/external_tools.py | 2 +-
diffoscope/tools.py | 12 ++++++++----
setup.py | 3 +++
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
diff --git a/setup.py b/setup.py
index 6bee89e..b173e05 100644
--- a/setup.py
+++ b/setup.py
@@ -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'
}
)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list