canonical / canonical/layer-basic
use_venv breaks charmhelpers.contrib.python.pip_install
- Vorherrschende Sprache
- Python
- Sterne
- 10
- Forks
- 42
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Per the layer-basic docs, `wheelhouse.txt` is intended only for **charm** dependencies. Payload dependencies should be installed separately.
For installing Python packages, this has traditionally been accomplished via `charmhelpers.contrib.python.pip_install`. The default use of venv has created a side-effect that breaks this pattern.
Internally, [pip_install](https://github.com/juju/charm-helpers/blob/master/charmhelpers/contrib/python/packages.py#L29) import's pip and execute's it's main:
```python
def pip_execute(*args, **kwargs):
[...]
try:
_path = sys.path
try:
from pip import main as _pip_execute
except ImportError:
apt_update()
if six.PY2:
apt_install('python-pip')
else:
apt_install('python3-pip')
from pip import main as _pip_execute
_pip_execute(*args, **kwargs)
finally:
sys.path = _path
```
This will use the pip installed inside the venv, installing the package(s) there rather than to the system and the payload will fail due to missing dependencies.
I'm not sure if we want to patch charmhelpers.contrib.python, if it's feasible to do something within layer:basic, or if we should instead create a new layer in the spirit of layer:apt to install packages in a way that's fully compatible with a charm-centric venv.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne mit der layer-basic-Dokumentation rund um `wheelhouse.txt` und untersuche `charmhelpers.contrib.python.packages.py`, insbesondere `pip_execute`. Vergleiche, wie `use_venv` die pip-Auflösung und Installationspfade verändert, und kläre anschließend, welche Schicht oder welcher Helper die Installation der Payload-Abhängigkeiten übernehmen sollte. Als erledigt gilt, wenn das dokumentierte Muster zur Payload-Installation funktioniert, ohne dass Abhängigkeiten innerhalb der Charm-venv verborgen sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100