Python 3.11 -P option changes one aspect of nspkg.pth namespace packages
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginnen Sie damit, den gemeldeten Importfehler mit Python 3.11, -P, PYTHONPATH und einem global installierten nspkg.pth-Namespace-Paket wie gezeigt zu reproduzieren. Verfolgen Sie anschließend, wie die Initialisierung des Pfads zu -P und site-packages zusammenspielt, und überprüfen Sie dann, dass der manuell bereitgestellte sphinxcontrib-Paketimport erfolgreich ist, ohne das dokumentierte -P-Verhalten zu beeinträchtigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Bug report
When trying to add the -P flag to Python shebangs in Fedora package, @befeleme discovered that our sphinxcontrib-programoutput fails to build documentation when /usr/bin/sphinx-build has -P in the shebang. After a lot of debugging, I've discovered that -P somewhat breaks the behavior wrt old-school namespace packages with nspkg.pth files.
To reproduce, I needed to install a sphinxcontrib-namespaced package globally to site-packages. Then, importing another sphinxcontrib-namespaced package without nspkg.pth from a manually specified $PYTHONPATH location fails with -P.
$ podman run --rm -ti python:3.11.0b3 /bin/bash
...
root@b881d08fc5f2:/# pip install 'sphinxcontrib-htmlhelp==2.0.0'
...
root@b881d08fc5f2:/# ls -1 /usr/local/lib/python3.11/site-packages
...
sphinxcontrib_htmlhelp-2.0.0-py3.9-nspkg.pth
sphinxcontrib_htmlhelp-2.0.0.dist-info
...
root@b881d08fc5f2:/# cd /tmp
root@b881d08fc5f2:/tmp# mkdir -p build/lib/sphinxcontrib/programoutput/
root@b881d08fc5f2:/tmp# touch build/lib/sphinxcontrib/programoutput/__init__.py
root@b881d08fc5f2:/tmp# PYTHONPATH=build/lib python3.11 -c 'import sphinxcontrib.programoutput'
(success)
root@b881d08fc5f2:/tmp# PYTHONPATH=build/lib python3.11 -P -c 'import sphinxcontrib.programoutput'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'sphinxcontrib.programoutput'
When the import is in a script, it behaves the same:
root@b881d08fc5f2:/tmp# cat > script.py
import sphinxcontrib.programoutput
root@b881d08fc5f2:/tmp# PYTHONPATH=build/lib python3.11 script.py
(success)
root@b881d08fc5f2:/tmp# PYTHONPATH=build/lib python3.11 -P script.py
Traceback (most recent call last):
File "/tmp/script.py", line 1, in <module>
import sphinxcontrib.programoutput
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'sphinxcontrib.programoutput'
Your environment
I wasn't able to reproduce this in venv, only when installing the namespace packages globally to system-wide site-packages. I've reproduced on Fedora as well as in the official python:3.11.0b3 Docker image.
- CPython versions tested on: 3.11.0b3
- Operating system and architecture: Fedora Linux, Debian, x86_64
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 36k
- Ø Merge
- 1 T. 9 Std.
- Gemergte PRs (30 T.)
- 558
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python/cpython
-
docs pending
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
stdlib type-feature
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
stdlib type-feature
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
build type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
stdlib topic-email type-feature
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
bancolombia/sentinel#23 ·
-
test md OffenCI
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100