From 42be3324c983dbfcca6690375e33a734995694cd Mon Sep 17 00:00:00 2001 From: jiasli <4003950+jiasli@users.noreply.github.com> Date: Fri, 17 Sep 2021 14:24:43 +0800 Subject: [PATCH] Only install colorama on Windows --- knack/cli.py | 2 +- setup.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/knack/cli.py b/knack/cli.py index 9b90e79..dda8a44 100644 --- a/knack/cli.py +++ b/knack/cli.py @@ -98,7 +98,7 @@ def __init__(self, self.only_show_errors = self.config.getboolean('core', 'only_show_errors', fallback=False) self.enable_color = self._should_enable_color() # Init colorama only in Windows legacy terminal - self._should_init_colorama = self.enable_color and os.name == 'nt' and not is_modern_terminal() + self._should_init_colorama = self.enable_color and sys.platform == 'win32' and not is_modern_terminal() @staticmethod def _should_show_version(args): diff --git a/setup.py b/setup.py index 606956b..430c0af 100644 --- a/setup.py +++ b/setup.py @@ -5,21 +5,24 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from codecs import open -from setuptools import setup, find_packages +import sys +from setuptools import setup VERSION = '0.8.2' DEPENDENCIES = [ 'argcomplete', - 'colorama', 'jmespath', 'pygments', 'pyyaml', 'tabulate' ] -with open('README.rst', 'r', encoding='utf-8') as f: +# On Windows, colorama is required for legacy terminals. +if sys.platform == 'win32': + DEPENDENCIES.append('colorama') + +with open('README.rst', 'r') as f: README = f.read() setup(