No folders to install into are found when run in a virtual environment
This issue is the same as #39, unclear why it resurfaced.
When pretty_errors is run as a module inside a pyenv virtualenv to add it to Python startup procedure (python -m pretty_errors), no folders to install into are found.
Updating the regexes should resolve this.
As a workaround I hardcoded the path to site-packages:
vim $(pyenv prefix)/lib/python3.9/site-packages/pretty_errors/__main__.py
# set paths in line 50 to
# paths = ['<$(pyenv prefix)>/lib/python3.9/site-packages']
The contributing guidelines say PR's will probably won't be merged, so I'm not bothering to submit one, but I think this could be a possible fix in main.py's getsitepackages function if anybody ever wants to implement.
My problem was that the venv's lib path is capitalized as "Lib", but the regex uses lowercase. On Windows case doesn't matter, but on Unix it does, thus the conditional case sensitivity flag.
paths_are_case_sensitive = os.path.normcase("Aa") == "Aa"
flags = 0 if paths_are_case_sensitive else re.IGNORECASE
pattern1 = re.compile(r'^%s$' % sep.join([env_path, 'lib', 'python[0-9.]+', 'site-packages']), flags)
pattern2 = re.compile(r'^%s$' % sep.join([env_path, 'lib', 'site-packages']), flags)