Skip to content
Merged
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
2 changes: 1 addition & 1 deletion scripts/release/debian/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ override_dh_install:
${TAB}mkdir -p debian/azure-cli/opt/az
${TAB}cp -a python_env/* debian/azure-cli/opt/az
${TAB}mkdir -p debian/azure-cli/usr/bin/
${TAB}echo "\043!/usr/bin/env bash\nAZ_INSTALLER=DEB /opt/az/bin/python3 -Im azure.cli \"\044\100\"" > debian/azure-cli/usr/bin/az
${TAB}echo "\043!/usr/bin/env bash\nbin_dir=\140cd \"\044(dirname \"\044BASH_SOURCE[0]\")\"; pwd\140\nAZ_INSTALLER=DEB \"\044bin_dir\"/../../opt/az/bin/python3 -Im azure.cli \"\044\100\"" > debian/azure-cli/usr/bin/az
Copy link
Member Author

Choose a reason for hiding this comment

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

The script becomes:

#!/usr/bin/env bash
bin_dir=`cd "$(dirname "$BASH_SOURCE[0]")"; pwd`
AZ_INSTALLER=DEB "$bin_dir"/../../opt/az/bin/python3 -Im azure.cli "$@"

${TAB}chmod 0755 debian/azure-cli/usr/bin/az
${TAB}mkdir -p debian/azure-cli/etc/bash_completion.d/
${TAB}cat ${completion_script} > debian/azure-cli/etc/bash_completion.d/azure-cli
Expand Down
4 changes: 3 additions & 1 deletion scripts/release/rpm/azure-cli.spec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Release: %{release}
Url: https://docs.microsoft.com/cli/azure/install-azure-cli
BuildArch: x86_64
Requires: %{python_cmd}
Prefix: /usr
Prefix: /etc
Comment on lines +29 to +30
Copy link
Member Author

Choose a reason for hiding this comment

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

Add Prefix to support relocatable package.


BuildRequires: gcc, libffi-devel, openssl-devel, perl
BuildRequires: %{python_cmd}-devel
Expand All @@ -52,7 +54,7 @@ for d in %{buildroot}%{cli_lib_dir}/bin/*; do perl -p -i -e "s#%{buildroot}##g"
# Create executable
mkdir -p %{buildroot}%{_bindir}
python_version=$(ls %{buildroot}%{cli_lib_dir}/lib/ | head -n 1)
printf "#!/usr/bin/env bash\nAZ_INSTALLER=RPM PYTHONPATH=%{cli_lib_dir}/lib/${python_version}/site-packages /usr/bin/%{python_cmd} -sm azure.cli \"\$@\"" > %{buildroot}%{_bindir}/az
printf "#!/usr/bin/env bash\nbin_dir=\`cd \"\$(dirname \"\$BASH_SOURCE[0]\")\"; pwd\`\nAZ_INSTALLER=RPM PYTHONPATH=\"\$bin_dir\"/../%{_lib}/az/lib/${python_version}/site-packages %{python_cmd} -sm azure.cli \"\$@\"" > %{buildroot}%{_bindir}/az
Copy link
Member Author

Choose a reason for hiding this comment

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

The script becomes:

#!/usr/bin/env bash
bin_dir=`cd "$(dirname "$BASH_SOURCE[0]")"; pwd`
AZ_INSTALLER=RPM PYTHONPATH="$bin_dir"/../lib64/az/lib/python3.6/site-packages python3 -sm azure.cli "$@"

Copy link
Member Author

@fengzhou-msft fengzhou-msft Mar 31, 2021

Choose a reason for hiding this comment

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

Use python3 instead of hard-coded /usr/bin/python3. This gives users flexibility to use any installed python3 by manipulating the PATH environment variable.

Copy link
Member

@jiasli jiasli Dec 1, 2021

Choose a reason for hiding this comment

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

%{_lib} causes problem on Mariner as it is different from that on Fedora/CentOS/RedHat:

> docker run -it --rm fedora rpm --eval '%{_lib}'
lib64

> docker run -it --rm centos rpm --eval '%{_lib}'
lib64

> docker run -it --rm redhat/ubi8-minimal rpm --eval '%{_lib}'
lib64

> docker run -it --rm cblmariner.azurecr.io/base/core:1.0 rpm --eval '%{_lib}'
/usr/lib

rm %{buildroot}%{cli_lib_dir}/bin/python* %{buildroot}%{cli_lib_dir}/bin/pip*

# Remove unused Network SDK API versions
Expand Down
4 changes: 2 additions & 2 deletions src/azure-cli-core/azure/cli/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,9 @@ def _get_version_string(name, version_dict):
else:
_print(ext.name.ljust(20) + (ext.version or 'Unknown').rjust(20))
_print()
_print("Python location '{}'".format(sys.executable))
_print("Extensions directory '{}'".format(EXTENSIONS_DIR))
import os
_print("Python location '{}'".format(os.path.abspath(sys.executable)))
Copy link
Member Author

Choose a reason for hiding this comment

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

Use abspath so on Ubuntu the bundle python won't show path like /usr/bin/../../opt/az/bin/python3, instead it will just show /opt/az/bin/python3.

_print("Extensions directory '{}'".format(EXTENSIONS_DIR))
if os.path.isdir(EXTENSIONS_SYS_DIR) and os.listdir(EXTENSIONS_SYS_DIR):
_print("Extensions system directory '{}'".format(EXTENSIONS_SYS_DIR))
if DEV_EXTENSION_SOURCES:
Expand Down