Skip to content

Commit f1fe18e

Browse files
marstrtjprescott
authored andcommitted
Update setup command to use platform appropriate requirements.txt file. (#102)
* Rewriting _install_cli * Fix typo * Fixing extra check that should have been deleted
1 parent dbc4dac commit f1fe18e

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

azdev/operations/setup.py

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import os
88
from shutil import copytree, rmtree
99
import time
10+
import sys
11+
import warnings
1012

1113
from knack.log import get_logger
1214
from knack.util import CLIError
@@ -71,37 +73,37 @@ def _install_cli(cli_path):
7173
)
7274
pip_cmd("install -q {}".format(whl_list), "Installing private whl files...")
7375

74-
# install general requirements
75-
pip_cmd(
76-
"install -q -r {}/requirements.txt".format(cli_path),
77-
"Installing `requirements.txt`..."
78-
)
79-
80-
# command modules have dependency on azure-cli-core so install this first
81-
pip_cmd(
82-
"install -q -e {}/src/azure-cli-nspkg".format(cli_path),
83-
"Installing `azure-cli-nspkg`..."
84-
)
85-
pip_cmd(
86-
"install -q -e {}/src/azure-cli-telemetry".format(cli_path),
87-
"Installing `azure-cli-telemetry`..."
88-
)
89-
pip_cmd(
90-
"install -q -e {}/src/azure-cli-core".format(cli_path),
91-
"Installing `azure-cli-core`..."
92-
)
93-
94-
# azure cli has dependencies on the above packages so install this one last
95-
pip_cmd("install -q -e {}/src/azure-cli".format(cli_path), "Installing `azure-cli`...")
96-
pip_cmd(
97-
"install -q -e {}/src/azure-cli-testsdk".format(cli_path),
98-
"Installing `azure-cli-testsdk`..."
99-
)
100-
101-
# Ensure that the site package's azure/__init__.py has the old style namespace
102-
# package declaration by installing the old namespace package
103-
pip_cmd("install -q -I azure-nspkg==1.0.0", "Installing `azure-nspkg`...")
104-
pip_cmd("install -q -I azure-mgmt-nspkg==1.0.0", "Installing `azure-mgmt-nspkg`...")
76+
src_path = '{}/src/'.format(cli_path)
77+
local_distributables = ' '.join(
78+
root
79+
for root, dirs, files in os.walk(src_path)
80+
if 'setup.py' in files)
81+
82+
python_major_version = sys.version_info[0]
83+
84+
if sys.platform.startswith('darwin'):
85+
requirements_file = "{}/src/azure-cli/requirements.py{}.Darwin.txt".format(cli_path, python_major_version)
86+
elif sys.platform.startswith('win32'):
87+
requirements_file = "{}/src/azure-cli/requirements.py{}.Windows.txt".format(cli_path, python_major_version)
88+
elif sys.platform.startswith('linux'):
89+
requirements_file = "{}/src/azure-cli/requirements.py{}.Linux.txt".format(cli_path, python_major_version)
90+
91+
if requirements_file:
92+
pip_cmd(
93+
"install -q --no-deps -e {}".format(local_distributables),
94+
"Installing packages found in this repository..."
95+
)
96+
97+
pip_cmd(
98+
"install -q -r {}".format(requirements_file),
99+
"Installing external dependencies...",
100+
)
101+
else:
102+
warnings.warn('platform {} does not have pinned dependencies, using latest compatible from PyPI.')
103+
pip_cmd(
104+
"install -q -e {}".format(local_distributables),
105+
"Installing all packages...",
106+
)
105107

106108

107109
def _copy_config_files():

0 commit comments

Comments
 (0)