Open Athanasius opened 5 months ago
Actually, that hacked together pydoc
isn't always working either. Having looked at some of the code I fear that something is undoing the addition to sys.path
.
It works if I .venv/bin/pydoc geoip2.errors
, but not with plain pydoc geoip2.errors
, despite which pydoc
citing that venv path.
Someone else-net has pointed out https://github.com/pypa/virtualenv/pull/265
A workaround is:
cp -p /usr/bin/pydoc<version> .venv/bin
$EDITOR .venv/bin/pydoc<version>
# Change the #! line to be the same as in .venv/bin/pip
# Now one of:
cp -p .venv/bin/pydoc<version> .venv/bin/pydoc
# Or alternatively
cd .venv/bin
ln -s pydoc<version> pydoc
i.e. ensuring the #! line points to the venv
python is sufficient, no need to mess with sys.path
directly.
Bug report
Bug description:
I started a new python project today and naturally did this within a
venv
virtual environment. Hitting some frustration on not seeing any documentation on the web pages for the modules I was utilising I turned topydoc
, but it found nothing. On checking the actual installed files for the modules they did have docstrings.python -m pydoc ...
worked properly.Upon checking
which pydoc
pointed out I was still using the systempydoc
, which would of course have no knowledge of thevenv
library path in order to look inside it for relevant documentation.I found https://github.com/python/cpython/issues/59362 from 2012, which claims to have address this, so this is clearly a regression, but I've no idea when it was introduced.
I'm doing all of this on a Debian bookwork 12.5 system which is up to date. I've rested using a
pyenv
installed Python 3.12.3. I also have no pydoc in<venv>/Scripts
on Windows (with Python from python.org installers)venv
s.pyenv
using latest from https://github.com/pyenv/pyenv.gitpyenv install 3.12.3
pyenv local 3.12.3
and confirm withwhich python
andpython --version
that it's using it.python -m venv venv-no-pydoc
These are the contents:
I've worked around the issue in my project
venv
by setting up.venv/bin/pydoc
with contents:Using the full path on the
#!
line is how the providedpip
script is set up, so there's no reason that the same code that achieves that couldn't also include thesys.path.append(...)
line, or other equivalent to ensurepydoc
knows about the path.CPython versions tested on:
3.12
Operating systems tested on:
Linux