mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
dont allow using no_use_wheel for pip 10.0.0 or newer
The --no-use-wheel flag has been deprecated in pip 10.0.0
This commit is contained in:
parent
f913a7859c
commit
b71e3d8a04
4 changed files with 116 additions and 31 deletions
|
@ -391,7 +391,8 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
|
|||
use_vt=False,
|
||||
trusted_host=None,
|
||||
no_cache_dir=False,
|
||||
cache_dir=None):
|
||||
cache_dir=None,
|
||||
no_binary=None):
|
||||
'''
|
||||
Install packages with pip
|
||||
|
||||
|
@ -417,7 +418,12 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
|
|||
Prefer wheel archives (requires pip>=1.4)
|
||||
|
||||
no_use_wheel
|
||||
Force to not use wheel archives (requires pip>=1.4)
|
||||
Force to not use wheel archives (requires pip>=1.4,<10.0.0)
|
||||
|
||||
no_binary
|
||||
Force to not use binary packages (requires pip >= 7.0.0)
|
||||
Accepts either :all: to disable all binary packages, :none: to empty the set,
|
||||
or one or more package names with commas between them
|
||||
|
||||
log
|
||||
Log file where a complete (maximum verbosity) record will be kept
|
||||
|
@ -589,29 +595,48 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
|
|||
|
||||
if use_wheel:
|
||||
min_version = '1.4'
|
||||
max_version = '9.0.3'
|
||||
cur_version = __salt__['pip.version'](bin_env)
|
||||
if not salt.utils.compare_versions(ver1=cur_version, oper='>=',
|
||||
ver2=min_version):
|
||||
too_low = salt.utils.compare_versions(ver1=cur_version, oper='<', ver2=min_version)
|
||||
too_high = salt.utils.compare_versions(ver1=cur_version, oper='>', ver2=max_version)
|
||||
if too_low or too_high:
|
||||
logger.error(
|
||||
('The --use-wheel option is only supported in pip {0} and '
|
||||
'newer. The version of pip detected is {1}. This option '
|
||||
'will be ignored.'.format(min_version, cur_version))
|
||||
('The --use-wheel option is only supported in pip between {0} and '
|
||||
'{1}. The version of pip detected is {2}. This option '
|
||||
'will be ignored.'.format(min_version, max_version, cur_version))
|
||||
)
|
||||
else:
|
||||
cmd.append('--use-wheel')
|
||||
|
||||
if no_use_wheel:
|
||||
min_version = '1.4'
|
||||
max_version = '9.0.3'
|
||||
cur_version = __salt__['pip.version'](bin_env)
|
||||
if not salt.utils.compare_versions(ver1=cur_version, oper='>=',
|
||||
ver2=min_version):
|
||||
too_low = salt.utils.compare_versions(ver1=cur_version, oper='<', ver2=min_version)
|
||||
too_high = salt.utils.compare_versions(ver1=cur_version, oper='>', ver2=max_version)
|
||||
if too_low or too_high:
|
||||
logger.error(
|
||||
('The --no-use-wheel option is only supported in pip {0} and '
|
||||
('The --no-use-wheel option is only supported in pip between {0} and '
|
||||
'{1}. The version of pip detected is {2}. This option '
|
||||
'will be ignored.'.format(min_version, max_version, cur_version))
|
||||
)
|
||||
else:
|
||||
cmd.append('--no-use-wheel')
|
||||
|
||||
if no_binary:
|
||||
min_version = '7.0.0'
|
||||
cur_version = __salt__['pip.version'](bin_env)
|
||||
too_low = salt.utils.compare_versions(ver1=cur_version, oper='<', ver2=min_version)
|
||||
if too_low:
|
||||
logger.error(
|
||||
('The --no-binary option is only supported in pip {0} and '
|
||||
'newer. The version of pip detected is {1}. This option '
|
||||
'will be ignored.'.format(min_version, cur_version))
|
||||
)
|
||||
else:
|
||||
cmd.append('--no-use-wheel')
|
||||
if isinstance(no_binary, list):
|
||||
no_binary = ','.join(no_binary)
|
||||
cmd.extend(['--no-binary', no_binary])
|
||||
|
||||
if log:
|
||||
if os.path.isdir(log):
|
||||
|
|
|
@ -321,7 +321,8 @@ def installed(name,
|
|||
use_vt=False,
|
||||
trusted_host=None,
|
||||
no_cache_dir=False,
|
||||
cache_dir=None):
|
||||
cache_dir=None,
|
||||
no_binary=None):
|
||||
'''
|
||||
Make sure the package is installed
|
||||
|
||||
|
@ -356,6 +357,25 @@ def installed(name,
|
|||
no_use_wheel : False
|
||||
Force to not use wheel archives (requires pip>=1.4)
|
||||
|
||||
no_binary
|
||||
Force to not use binary packages (requires pip >= 7.0.0)
|
||||
Accepts either :all: to disable all binary packages, :none: to empty the set,
|
||||
or a list of one or more packages
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
django:
|
||||
pip.installed:
|
||||
- no_binary: ':all:'
|
||||
|
||||
flask:
|
||||
pip.installed:
|
||||
- no_binary:
|
||||
- itsdangerous
|
||||
- click
|
||||
|
||||
log
|
||||
Log file where a complete (maximum verbosity) record will be kept
|
||||
|
||||
|
@ -598,23 +618,39 @@ def installed(name,
|
|||
# Check that the pip binary supports the 'use_wheel' option
|
||||
if use_wheel:
|
||||
min_version = '1.4'
|
||||
max_version = '9.0.3'
|
||||
cur_version = __salt__['pip.version'](bin_env)
|
||||
if not salt.utils.compare_versions(ver1=cur_version, oper='>=',
|
||||
ver2=min_version):
|
||||
too_low = salt.utils.compare_versions(ver1=cur_version, oper='<', ver2=min_version)
|
||||
too_high = salt.utils.compare_versions(ver1=cur_version, oper='>', ver2=max_version)
|
||||
if too_low or too_high:
|
||||
ret['result'] = False
|
||||
ret['comment'] = ('The \'use_wheel\' option is only supported in '
|
||||
'pip {0} and newer. The version of pip detected '
|
||||
'was {1}.').format(min_version, cur_version)
|
||||
'pip between {0} and {1}. The version of pip detected '
|
||||
'was {2}.').format(min_version, max_version, cur_version)
|
||||
return ret
|
||||
|
||||
# Check that the pip binary supports the 'no_use_wheel' option
|
||||
if no_use_wheel:
|
||||
min_version = '1.4'
|
||||
max_version = '9.0.3'
|
||||
cur_version = __salt__['pip.version'](bin_env)
|
||||
if not salt.utils.compare_versions(ver1=cur_version, oper='>=',
|
||||
ver2=min_version):
|
||||
too_low = salt.utils.compare_versions(ver1=cur_version, oper='<', ver2=min_version)
|
||||
too_high = salt.utils.compare_versions(ver1=cur_version, oper='>', ver2=max_version)
|
||||
if too_low or too_high:
|
||||
ret['result'] = False
|
||||
ret['comment'] = ('The \'no_use_wheel\' option is only supported in '
|
||||
'pip between {0} and {1}. The version of pip detected '
|
||||
'was {2}.').format(min_version, max_version, cur_version)
|
||||
return ret
|
||||
|
||||
# Check that the pip binary supports the 'no_binary' option
|
||||
if no_binary:
|
||||
min_version = '7.0.0'
|
||||
cur_version = __salt__['pip.version'](bin_env)
|
||||
too_low = salt.utils.compare_versions(ver1=cur_version, oper='<', ver2=min_version)
|
||||
if too_low:
|
||||
ret['result'] = False
|
||||
ret['comment'] = ('The \'no_binary\' option is only supported in '
|
||||
'pip {0} and newer. The version of pip detected '
|
||||
'was {1}.').format(min_version, cur_version)
|
||||
return ret
|
||||
|
@ -730,6 +766,7 @@ def installed(name,
|
|||
bin_env=bin_env,
|
||||
use_wheel=use_wheel,
|
||||
no_use_wheel=no_use_wheel,
|
||||
no_binary=no_binary,
|
||||
log=log,
|
||||
proxy=proxy,
|
||||
timeout=timeout,
|
||||
|
|
|
@ -57,7 +57,8 @@ def managed(name,
|
|||
pip_pkgs=None,
|
||||
pip_no_cache_dir=False,
|
||||
pip_cache_dir=None,
|
||||
process_dependency_links=False):
|
||||
process_dependency_links=False,
|
||||
no_binary=None):
|
||||
'''
|
||||
Create a virtualenv and optionally manage it with pip
|
||||
|
||||
|
@ -103,6 +104,11 @@ def managed(name,
|
|||
no_use_wheel: False
|
||||
Force to not use wheel archives (requires pip>=1.4)
|
||||
|
||||
no_binary
|
||||
Force to not use binary packages (requires pip >= 7.0.0)
|
||||
Accepts either :all: to disable all binary packages, :none: to empty the set,
|
||||
or a list of one or more packages
|
||||
|
||||
pip_upgrade: False
|
||||
Pass `--upgrade` to `pip install`.
|
||||
|
||||
|
@ -222,27 +228,44 @@ def managed(name,
|
|||
elif venv_exists:
|
||||
ret['comment'] = 'virtualenv exists'
|
||||
|
||||
# Check that the pip binary supports the 'use_wheel' option
|
||||
if use_wheel:
|
||||
min_version = '1.4'
|
||||
max_version = '9.0.3'
|
||||
cur_version = __salt__['pip.version'](bin_env=name)
|
||||
if not salt.utils.compare_versions(ver1=cur_version, oper='>=',
|
||||
ver2=min_version):
|
||||
too_low = salt.utils.compare_versions(ver1=cur_version, oper='<', ver2=min_version)
|
||||
too_high = salt.utils.compare_versions(ver1=cur_version, oper='>', ver2=max_version)
|
||||
if too_low or too_high:
|
||||
ret['result'] = False
|
||||
ret['comment'] = ('The \'use_wheel\' option is only supported in '
|
||||
'pip {0} and newer. The version of pip detected '
|
||||
'was {1}.').format(min_version, cur_version)
|
||||
'pip between {0} and {1}. The version of pip detected '
|
||||
'was {2}.').format(min_version, max_version, cur_version)
|
||||
return ret
|
||||
|
||||
# Check that the pip binary supports the 'no_use_wheel' option
|
||||
if no_use_wheel:
|
||||
min_version = '1.4'
|
||||
max_version = '9.0.3'
|
||||
cur_version = __salt__['pip.version'](bin_env=name)
|
||||
if not salt.utils.compare_versions(ver1=cur_version, oper='>=',
|
||||
ver2=min_version):
|
||||
too_low = salt.utils.compare_versions(ver1=cur_version, oper='<', ver2=min_version)
|
||||
too_high = salt.utils.compare_versions(ver1=cur_version, oper='>', ver2=max_version)
|
||||
if too_low or too_high:
|
||||
ret['result'] = False
|
||||
ret['comment'] = ('The \'no_use_wheel\' option is only supported '
|
||||
'in pip {0} and newer. The version of pip '
|
||||
'detected was {1}.').format(min_version,
|
||||
cur_version)
|
||||
ret['comment'] = ('The \'no_use_wheel\' option is only supported in '
|
||||
'pip between {0} and {1}. The version of pip detected '
|
||||
'was {2}.').format(min_version, max_version, cur_version)
|
||||
return ret
|
||||
|
||||
# Check that the pip binary supports the 'no_binary' option
|
||||
if no_binary:
|
||||
min_version = '7.0.0'
|
||||
cur_version = __salt__['pip.version'](bin_env=name)
|
||||
too_low = salt.utils.compare_versions(ver1=cur_version, oper='<', ver2=min_version)
|
||||
if too_low:
|
||||
ret['result'] = False
|
||||
ret['comment'] = ('The \'no_binary\' option is only supported in '
|
||||
'pip {0} and newer. The version of pip detected '
|
||||
'was {1}.').format(min_version, cur_version)
|
||||
return ret
|
||||
|
||||
# Populate the venv via a requirements file
|
||||
|
@ -275,6 +298,7 @@ def managed(name,
|
|||
bin_env=name,
|
||||
use_wheel=use_wheel,
|
||||
no_use_wheel=no_use_wheel,
|
||||
no_binary=no_binary,
|
||||
user=user,
|
||||
cwd=cwd,
|
||||
index_url=index_url,
|
||||
|
|
|
@ -4,6 +4,5 @@
|
|||
- user: issue-1959
|
||||
{%- if grains.get('pythonversion')[0] != 2 %}
|
||||
{#- wheels are disabled because the pip cache dir will not be owned by the above issue-1959 user. Need to check this ASAP #}
|
||||
- use_wheel: False
|
||||
- no_use_wheel: True
|
||||
- no_binary: ':all:'
|
||||
{%- endif %}
|
||||
|
|
Loading…
Add table
Reference in a new issue