Skip to content

Commit cd84fb3

Browse files
committed
BUG: Resolve editable installation egg-links in venvs
Refs: 5ab5739 Refs: #137 (comment) Refs: davidhalter/jedi#532 Thanks @mfrigerio17
1 parent 4ace3f8 commit cd84fb3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pdoc/cli.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,18 @@ def main(_args=None):
421421
except KeyError:
422422
pass # pdoc was not invoked while in a virtual environment
423423
else:
424+
from glob import glob
424425
from distutils.sysconfig import get_python_lib
425-
sys.path.append(get_python_lib(prefix=venv_dir))
426+
libdir = get_python_lib(prefix=venv_dir)
427+
sys.path.append(libdir)
428+
# Resolve egg-links from `setup.py develop` or `pip install -e`
429+
# XXX: Welcome a more canonical approach
430+
for pth in glob(path.join(libdir, '*.egg-link')):
431+
try:
432+
with open(pth) as f:
433+
sys.path.append(path.join(libdir, f.readline().rstrip()))
434+
except IOError:
435+
warn('Invalid egg-link in venv: {!r}'.format(pth))
426436

427437
if args.http:
428438
template_config['link_prefix'] = "/"

0 commit comments

Comments
 (0)