Azure / Azure/azure-cli-dev-tools

`azdev extension remove` does not clear its corresponding source code path in `sys.path` when its package name is not its folder name

Aperta
#519 1 commento 1 reazione 1 assegnatario Rivendicata da @AllyW Vedi su GitHub
Lingua principale
Python
Stelle
91
Fork
134
Merge medio
2h 51m
PR unite (30g)
1

Descrizione

Reproduce step:
```
1. azdev extension add network-manager
2. azdev extension remove network-manager
3. python -c "import sys; print(sys.path)"
```

It would interfere module loading afterwards using `az extension add -s virtual-network-manager.whl -y`

The root cause is `azdev extension add` installs python package using `pip install -e module-folder` which added its real package name into `sys.path` (check `easy_install.pth` in venv).

While `azdev extension remove` calls `pip uninstall module-folder` to remove it and when its package name is different from its module name(folder name under `azure-cli-extensions/src`), `azdev extension remove` does not remove its package name in `sys.path`, it only removed the `*egg-info` folder under its module.

Another issues is when loading dev extensions from `az extension list`, this cmd reads in the `*egg-info` folder package info and check it with its folder name and when it's different, then metadata cannot be loaded from `*egg-info`, which will lost module version and preview info, as below:

![Image](https://github.com/user-attachments/assets/dbd0387f-8d27-4d67-80e4-c3a8ddb270db)

What we can do has three options:
1. this usage scenario is quite rare, remove the source code when loading module from `whl` after adding and removing it from `azdev`
2. fix the `azdev extension remove` logic
3. adjust the network-manager folder to be the same as its package name `virtual-network-manager`

My suggestion is option 3. This scenario has caused too many special logic codes and breaks in execution, and we need to avoid it.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.