Skip to content
Draft
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 src/azure-cli-core/azure/cli/core/extension/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@

def _run_pip(pip_exec_args, extension_path=None):
cmd = [sys.executable, '-m', 'pip'] + pip_exec_args + ['--disable-pip-version-check', '--no-cache-dir']
env = os.environ.copy()
env.pop('PIP_REQUIRE_VIRTUALENV', None)
logger.debug('Running: %s', cmd)
try:
log_output = check_output(cmd, stderr=STDOUT, universal_newlines=True)
log_output = check_output(cmd, stderr=STDOUT, universal_newlines=True, env=env)
logger.debug(log_output)
returncode = 0
except CalledProcessError as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ def test_add_extension_verify_no_pip_proxy(self):
if '--proxy' in pip_cmd:
raise AssertionError("proxy parameter in check_output args although no proxy specified")

def test_add_extension_unset_pip_require_virtualenv(self):
extension_name = MY_EXT_NAME
computed_extension_sha256 = _compute_file_hash(MY_EXT_SOURCE)
with mock.patch.dict(os.environ, {'PIP_REQUIRE_VIRTUALENV': 'true', 'DUMMY_ENV_VAR': 'dummy-value'}), \
mock.patch('azure.cli.core.extension.operations.resolve_from_index', return_value=(MY_EXT_SOURCE, computed_extension_sha256)), \
mock.patch('azure.cli.core.extension.operations.shutil'), \
mock.patch('azure.cli.core.extension.operations.check_output') as check_output:
add_extension(cmd=self.cmd, extension_name=extension_name)
kwargs = check_output.call_args[1]
self.assertNotIn('PIP_REQUIRE_VIRTUALENV', kwargs['env'])
self.assertEqual(kwargs['env'].get('DUMMY_ENV_VAR'), 'dummy-value')

def test_add_extension_with_specific_version(self):
extension_name = MY_EXT_NAME
extension1 = 'myfirstcliextension-0.0.3+dev-py2.py3-none-any.whl'
Expand Down