pypa / pypa/packaging.python.org
pkg_util leaves broken packages on uninstall
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 1.7k
- Fork
- 1.7k
- Merge medio
- 3g 12h
- PR unite (30g)
- 4
Descrizione
I've just encountered another issue related to pkg_util-based namespace packages on pre-PEP 420 packages. Uninstallation of one package in a namespace breaks the package for all other in that namespace. Consider:
$ virtualenv --python python2.7 env
Running virtualenv with interpreter /usr/local/bin/python2.7
New python executable in /Users/jaraco/env/bin/python2.7
Also creating executable in /Users/jaraco/env/bin/python
Installing setuptools, pip, wheel...done.
$ env/bin/pip install -q backports.unittest_mock backports.datetime_timestamp
$ env/bin/pip uninstall -y backports.datetime_timestamp
Uninstalling backports.datetime-timestamp-1.1:
Successfully uninstalled backports.datetime-timestamp-1.1
$ env/bin/python -c "import backports.unittest_mock"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named backports.unittest_mock
The issue occurs because the uninstallation step causes the removal of the now necessary __init__.py module for the backports package. The issue doesn't occur on late releases of Python 3.3 because the package gets implicitly converted to a PEP 420 namespace package (during the uninstallation step), which in some ways is worse, because the backports package will vacillate between PEP-420 and pkg_util-managed depending on whether the last operation was an install or uninstall.
In some sense, this issue is an issue with pip and the way it installs packages all into the same location, rather than keeping distribution packages somehow separated the way eggs sought to do, but it's also a symptom of using only pkg_util for namespace package management, an issue that was addressed by setuptools' installation of the -nspkg.pth files.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo i comandi virtualenv, pip install e pip uninstall con i due pacchetti backport su Python 2.7. Analizza come i pacchetti namespace di pkg_util e i file setuptools -nspkg.pth gestiscono il init.py condiviso durante la disinstallazione, incluso il comportamento PEP 420 descritto. Il lavoro è completato quando la disinstallazione di un pacchetto lascia l’altro pacchetto importabile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100