Skip to content

Commit

Permalink
Re-install azure-nspkg and azure-mgmt-nspkg as the last step of insta…
Browse files Browse the repository at this point in the history
…ll for Docker and curl (#3035)

* Re-install azure-nspkg and azure-mgmt-nspkg as the last step of the install to ensure that site-packages/azure/__init__.py and azure/mgmt/__init__.py are empty (performance).

This is a temporary work-around until we have moved all command packages to only reference other azure packages that include the azure_bdist_wheel extension to handle this for us. Until then, you may end up with a non-empty __init__ file, which will slow down command startup time.

* Address code review feedback - ordering of commands to pip + typo
  • Loading branch information
johanste authored and derekbekoe committed Apr 28, 2017
1 parent f0b492e commit 89b8091
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RUN wget https://github.com/jmespath/jp/releases/download/0.1.2/jp-linux-amd64 -

# 1. Build packages and store in tmp dir
# 2. Install the cli and the other command modules that weren't included
# 3. Temporary fix - install azure-nspkg to remove import of pkg_resources in azure/__init__.py (to improve performance)
RUN /bin/bash -c 'TMP_PKG_DIR=$(mktemp -d); \
for d in src/azure-cli src/azure-cli-core src/azure-cli-nspkg src/azure-cli-command_modules-nspkg src/command_modules/azure-cli-*/; \
do cd $d; python setup.py bdist_wheel -d $TMP_PKG_DIR; cd -; \
Expand All @@ -33,7 +34,8 @@ RUN /bin/bash -c 'TMP_PKG_DIR=$(mktemp -d); \
for f in $TMP_PKG_DIR/*; \
do MODULE_NAMES="$MODULE_NAMES $f"; \
done; \
pip install $MODULE_NAMES;'
pip install $MODULE_NAMES; \
pip install --force-reinstall --upgrade azure-nspkg azure-mgmt-nspkg;'

# Tab completion
RUN echo -e "\
Expand Down
3 changes: 2 additions & 1 deletion packaged_releases/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ RUN /bin/bash -c 'cd /cli-src/*; tmp_pkg_dir=$(mktemp -d); \
for d in src/azure-cli src/azure-cli-core src/azure-cli-nspkg src/azure-cli-command_modules-nspkg src/command_modules/azure-cli-*/; \
do cd $d; python setup.py bdist_wheel -d $tmp_pkg_dir; cd -; \
done; \
pip install azure-cli -f $tmp_pkg_dir;'
pip install azure-cli -f $tmp_pkg_dir; \
pip install --force-reinstall --upgrade azure-nspkg azure-mgmt-nspkg;'
# Tab completion
RUN cat /cli-src/*/az.completion >> ~/.bashrc

Expand Down
4 changes: 4 additions & 0 deletions scripts/curl_install_pypi/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ def install_cli(install_dir, tmp_dir):
path_to_pip = os.path.join(install_dir, 'bin', 'pip')
cmd = [path_to_pip, 'install', '--cache-dir', tmp_dir, 'azure-cli', '--upgrade']
exec_command(cmd)
# Temporary fix to make sure that we have empty __init__.py files for the azure site-packages folder.
# (including the pkg_resources/declare namespace significantly impacts startup perf for the CLI)
fixupcmd = [path_to_pip, 'install', '--cache-dir', tmp_dir, '--upgrade', '--force-reinstall', 'azure-nspkg', 'azure-mgmt-nspkg']
exec_command(fixupcmd)

def create_executable(exec_dir, install_dir):
create_dir(exec_dir)
Expand Down

0 comments on commit 89b8091

Please sign in to comment.