Azure / Azure/azure-cli-dev-tools
`azdev setup` fails to call `python` executable from conda environment on win32
- Lenguaje dominante
- Python
- Estrellas
- 91
- Forks
- 134
- Merge medio
- 2 h 51 min
- PR fusionados (30 d)
- 1
Descripción
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)
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Comienza en azdev/utilities/command.py, en la función py_cmd, e inspecciona cómo se selecciona el ejecutable de Python en win32. Reproduce azdev setup desde un entorno conda activado y verifica después que la instalación del paquete invoque el ejecutable de Python funcional del entorno en lugar de la ruta Scripts/python no válida.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- cli, tooling
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 55/100