Azure / Azure/azure-cli-dev-tools

`azdev setup` fails to call `python` executable from conda environment on win32

Aperta
#307 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
91
Fork
134
Merge medio
2h 51m
PR unite (30g)
1

Descrizione

When running `azdev setup` from within a conda environment on win32, the `py_cmd` function in `azdev/utilities/command.py` attempts to run `Scripts/python` from within the current conda env, rather than the `python` executable in the root of the environment:

```
(base) PS> conda activate az-dev
(az-dev) PS> azdev setup --cli --repo

=======================
| Azure CLI Dev Setup |
=======================

Azure CLI:

Azure CLI extension repos:

Installing packages
=====================

Upgrading pip...
Command `C:\Users\\AppData\Local\Continuum\anaconda3\envs\az-dev\Scripts\python -m pip install --upgrade pip` failed with exit code 1:
'C:\Users\\AppData\Local\Continuum\anaconda3\envs\az-dev\Scripts\python' is not recognized as an internal or external command,
operable program or batch file.
```

As a workaround, modifying `py_cmd` to call `sys.executable` rather than using `env_path` seems to work:

```python
def py_cmd(command, message=False, show_stderr=True, raise_error=False, is_module=True, **kwargs):
""" Run a script or command with Python.
:param command: The arguments to run python with.
:param message: A custom message to display, or True (bool) to use a default.
:param show_stderr: On error, display the contents of STDERR.
:param raise_error: On error, raise CommandError.
:param is_module: Run a Python module as a script with -m.
:param kwargs: Any kwargs supported by subprocess.Popen
:returns: CommandResultItem object.
"""
from azdev.utilities import get_env_path
env_path = get_env_path()
python_bin = sys.executable
if is_module:
command = '{} -m {}'.format(python_bin, command)
else:
command = '{} {}'.format(python_bin, command)
return cmd(command, message, show_stderr, raise_error, **kwargs)
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia in azdev/utilities/command.py, nella funzione py_cmd, e verifica come viene selezionato l'eseguibile Python su win32. Riproduci azdev setup da un ambiente conda attivato, quindi verifica che l'installazione del pacchetto richiami l'eseguibile Python funzionante dell'ambiente invece del percorso Scripts/python non valido.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
cli, tooling
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.