Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/azure-cli/az.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@echo off
setlocal

SET PYTHONPATH=%~dp0/src;%PYTHONPATH%
python -m azure.cli %*
IF EXIST "%~dp0\python.exe" (
"%~dp0\python.exe" -m azure.cli %*
) ELSE (
SET PYTHONPATH=%~dp0/src;%PYTHONPATH%

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think PYTHONPATH is not necessary anymore. By showing it with echo %PYTHONPATH%:

D:\cli\env38\Scripts\/src;

This is not a valid path.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also path separator / is not valid on Windows.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix the path separator.

PYTHONPATH is not needed for normal cli run, but let's leave it there for the convenience of using additional custom Python libraries that users do not want to install in the global default location (i.e., the site-packages directory).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if there is a historical reason. As far as I can find, the only possible operation for src to exist is installing via pip install -e <VCS>: pip install -e "git+https://github.com/Azure/azure-sdk-for-python/#egg=azure-mgmt-eventgrid&subdirectory=sdk\eventgrid\azure-mgmt-eventgrid"

Even in that case src should be under %~dp0\... The path to azure-mgmt-eventgrid is added to sys.path via env\Lib\site-packages\azure-mgmt-eventgrid.egg-link.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree %~dp0\.. is a better location to put src as %~dp0 is the Scripts directory (or bin directory on Linux). I would consider changing it together with the Linux script when we have more knowledge about the real uses cases and history for this PYTHONPATH setting.

python -m azure.cli %*
)