Skip to content

Commit bdb9c34

Browse files
committed
{Packaging} Fix crash when another Python is installed on the system
The scripts are installed in <base>/Scripts, but PYTHONPATH was set to <scripts>/src, although this directory doesn't even exist. I guess the deployment used to be in src, but this is no longer the case. Setting PYTHONPATH is done to avoid conflicts with other installations of Python on the same machine. When it is set incorrectly, Python tend to crash on startup (typically when loading incompatible ctypes). Fixes #28004, #29630, #30517, #30536, #30594, #30700, #30792.
1 parent a00a332 commit bdb9c34

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/azure-cli/az

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
import os
55

6-
dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'src')
6+
dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
77

88
if os.environ.get('PYTHONPATH') is None:
99
os.environ['PYTHONPATH'] = dir

src/azure-cli/az.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
@echo off
22
setlocal
33

4-
SET PYTHONPATH=%~dp0\src;%PYTHONPATH%
4+
SET PYTHONPATH=%~dp0\..;%PYTHONPATH%
55
SET AZ_INSTALLER=PIP
66

7-
IF EXIST "%~dp0\python.exe" (
8-
"%~dp0\python.exe" -m azure.cli %*
7+
IF EXIST "%~dp0\..\python.exe" (
8+
"%~dp0\..\python.exe" -m azure.cli %*
99
) ELSE (
1010
python -m azure.cli %*
1111
)

0 commit comments

Comments
 (0)