Skip to content

Commit 5ab5739

Browse files
jlaufersweilerkernc
authored andcommitted
FIX: pdoc cli ignoring virtual environment (#45)
* FIX: pdoc cli ignoring virtual environment fixes: #44 * REF: Simplify handling virtual environment
1 parent 8dbecad commit 5ab5739

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pdoc/cli.py

+9
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,15 @@ def main(_args=None):
396396
# Support loading modules specified as python paths relative to cwd
397397
sys.path.append(os.getcwd())
398398

399+
# Virtual environment handling for pdoc script run from system site
400+
try:
401+
venv_dir = os.environ['VIRTUAL_ENV']
402+
except KeyError:
403+
pass # pdoc was not invoked while in a virtual environment
404+
else:
405+
from distutils.sysconfig import get_python_lib
406+
sys.path.append(get_python_lib(prefix=venv_dir))
407+
399408
if args.http:
400409
template_config['link_prefix'] = "/"
401410

0 commit comments

Comments
 (0)