Skip to content
Snippets Groups Projects
Verified Commit c8927db9 authored by Mattia Rizzolo's avatar Mattia Rizzolo
Browse files

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's avatarMattia Rizzolo <mattia@debian.org>
parent 51c801f9
No related branches found
No related tags found
No related merge requests found
......@@ -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},
......
......@@ -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
......
......@@ -24,7 +24,7 @@ EXTERNAL_TOOLS = {
'bsdtar': {
'debian': 'libarchive-tools',
'arch': 'libarchive',
'Fedora': 'bsdtar',
'fedora': 'bsdtar',
'FreeBSD': 'libarchive',
},
'bzip2': {
......
......@@ -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',
......
......@@ -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'
}
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment