Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only install and import colorama on Windows. #691

Merged
merged 4 commits into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ dev

- Fixed `pipx list --json` to return valid json with no venvs installed. Previously would return and empty string to stdout. (#681)
- Changed `pipx ensurepath` bash behavior so that only one of {`~/.profile`, `~/.bash\_profile`} is modified with the extra pipx paths, not both. Previously, if a `.bash_profile` file was created where one didn't exist, it could cause problems, e.g. #456. The internal change is to use userpath v1.5.0 or greater. (#684)
* Colorama is now only installed on Windows. (#691)

0.16.2.1

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ include_package_data = true
zip_safe = true
python_requires = >=3.6
install_requires =
colorama>=0.4.4
colorama>=0.4.4;sys_platform=="win32"
userpath>=1.5.0
argcomplete>=1.9.4, <2.0
packaging>=20.0
Expand Down
7 changes: 5 additions & 2 deletions src/pipx/colors.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import sys
from typing import Callable

import colorama # type: ignore
try:
import colorama # type: ignore
except ImportError: # Colorama is Windows only package
colorama = None

PRINT_COLOR = sys.stdout.isatty()

if PRINT_COLOR:
if PRINT_COLOR and colorama:
colorama.init()


Expand Down