From 07e451f4cc4c418cdcc523bdfbd4a4624bc81353 Mon Sep 17 00:00:00 2001 From: Jiashuo Li <4003950+jiasli@users.noreply.github.com> Date: Thu, 4 Nov 2021 10:41:40 +0800 Subject: [PATCH] Only install colorama on Windows (#249) --- 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 db40d67..0fd8963 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(