Azure / Azure/azure-cli-dev-tools

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

オープン
#307 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
91
フォーク
134
平均マージ
2時間 51分
マージ済み PR(30日)
1

説明

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)
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

azdev/utilities/command.py の py_cmd 関数から始め、win32 で Python 実行可能ファイルがどのように選択されるかを確認します。アクティブ化した conda 環境から azdev setup を再現し、その後、パッケージのインストールで無効な Scripts/python パスではなく、環境の動作する Python 実行可能ファイルが呼び出されることを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
cli, tooling
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。