From f61574e7fec2b7118fee5a59de61a8a734459ca1 Mon Sep 17 00:00:00 2001 From: onelivesleft Date: Wed, 24 Nov 2021 14:32:14 +0000 Subject: [PATCH] v1.2.25 Fixes #44 --- CHANGELIST.md | 5 +++++ pretty_errors/__init__.py | 2 +- pretty_errors/__main__.py | 11 ++++++++--- setup.py | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 5ed2a21..3cd74ed 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -1,3 +1,8 @@ +# v1.2.25 + +* Fixed problem installing into virtualenv paths. + + # v1.2.24 * Fixed problem when running in container which reports a terminal width of 0 diff --git a/pretty_errors/__init__.py b/pretty_errors/__init__.py index 6901325..6f07e0e 100644 --- a/pretty_errors/__init__.py +++ b/pretty_errors/__init__.py @@ -4,7 +4,7 @@ terminal_is_interactive = sys.stderr.isatty() name = "pretty_errors" -__version__ = "1.2.24" # remember to update version in setup.py! +__version__ = "1.2.25" # remember to update version in setup.py! active = 'PYTHON_PRETTY_ERRORS' not in os.environ or os.environ['PYTHON_PRETTY_ERRORS'] != '0' interactive_tty_only = 'PYTHON_PRETTY_ERRORS_ISATTY_ONLY' in os.environ and os.environ['PYTHON_PRETTY_ERRORS_ISATTY_ONLY'] != '0' diff --git a/pretty_errors/__main__.py b/pretty_errors/__main__.py index a3bdded..5e755ef 100644 --- a/pretty_errors/__main__.py +++ b/pretty_errors/__main__.py @@ -39,9 +39,14 @@ # in virtualenv, `site` has no attribute `getsitepackages` or `getusersitepackages` if in_virtualenv: def getsitepackages(): - sep = "\\\\" if os.path.sep == "\\" else os.path.sep - pattern1 = re.compile(r'^%s$' % sep.join([os.environ['VIRTUAL_ENV'], 'lib', 'python[0-9.]+', 'site-packages'])) - pattern2 = re.compile(r'^%s$' % sep.join([os.environ['VIRTUAL_ENV'], 'lib', 'site-packages'])) + if os.path.sep == "\\": + sep = "\\\\" + env_path = os.environ['VIRTUAL_ENV'].replace("\\", "\\\\") + else: + sep = os.path.sep + env_path = os.environ['VIRTUAL_ENV'] + pattern1 = re.compile(r'^%s$' % sep.join([env_path, 'lib', 'python[0-9.]+', 'site-packages'])) + pattern2 = re.compile(r'^%s$' % sep.join([env_path, 'lib', 'site-packages'])) paths = [path for path in set(sys.path) if pattern1.search(path) or pattern2.search(path)] return paths diff --git a/setup.py b/setup.py index 39abf70..23cf740 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="pretty_errors", - version="1.2.24", # remember to also update __version__ in __init__.py! + version="1.2.25", # remember to also update __version__ in __init__.py! author="Iain King", author_email="iain.king@gmail.com", description="Prettifies Python exception output to make it legible.",