From 484cae0cae4ca12d06c4414be891bee017fdc6e0 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Tue, 15 Oct 2019 13:03:07 +0700 Subject: [PATCH] Make distro dependency optional The distro package only supports Linux, and it is only used here to detect Ubuntu. Make it an optional dependency in the code, so that packagers can exclude it when it isnt needed. Closes https://github.com/ofek/userpath/issues/15 --- userpath/shells.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/userpath/shells.py b/userpath/shells.py index 939931d..085ded7 100644 --- a/userpath/shells.py +++ b/userpath/shells.py @@ -1,6 +1,9 @@ from os import path, pathsep -import distro +try: + import distro +except ImportError: + distro = None DEFAULT_SHELLS = ('bash', 'sh') @@ -34,7 +37,7 @@ def config(self, location, front=True): configs = {path.join(self.home, '.bashrc'): contents} # https://github.com/ofek/userpath/issues/3#issuecomment-492491977 - if distro.id() == 'ubuntu': + if distro and distro.id() == 'ubuntu': login_config = path.join(self.home, '.profile') else: # NOTE: If it is decided in future that we want to make a distinction between