Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{Packaging} Fix crash when another Python is installed on the system #30801

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion build_scripts/windows/scripts/az
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

AZ_INSTALLER=MSI "$(dirname "${BASH_SOURCE[0]}")/../python.exe" -IBm azure.cli "$@"
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
export PYTHONPATH="$(dirname "$SCRIPT_DIR")"
AZ_INSTALLER=MSI "$SCRIPT_DIR/../python.exe" -IBm azure.cli "$@"
1 change: 1 addition & 0 deletions build_scripts/windows/scripts/az_msi.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
::

@IF EXIST "%~dp0\..\python.exe" (
SET PYTHONPATH=%~dp0\..;%PYTHONPATH%
SET AZ_INSTALLER=MSI
"%~dp0\..\python.exe" -IBm azure.cli %*
) ELSE (
Expand Down
1 change: 1 addition & 0 deletions build_scripts/windows/scripts/az_zip.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
::

@IF EXIST "%~dp0\..\python.exe" (
SET PYTHONPATH=%~dp0\..;%PYTHONPATH%
SET AZ_INSTALLER=ZIP
"%~dp0\..\python.exe" -IBm azure.cli %*
) ELSE (
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/az
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
import os

dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'src')
dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

if os.environ.get('PYTHONPATH') is None:
os.environ['PYTHONPATH'] = dir
Expand Down
6 changes: 3 additions & 3 deletions src/azure-cli/az.bat
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@echo off
setlocal

SET PYTHONPATH=%~dp0\src;%PYTHONPATH%
SET PYTHONPATH=%~dp0\..;%PYTHONPATH%
SET AZ_INSTALLER=PIP

IF EXIST "%~dp0\python.exe" (
"%~dp0\python.exe" -m azure.cli %*
IF EXIST "%~dp0\..\python.exe" (
"%~dp0\..\python.exe" -m azure.cli %*
) ELSE (
python -m azure.cli %*
)