Skip to content

Commit

Permalink
always-install-via-wheel feature
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Jan 9, 2021
1 parent a4291ef commit 7542e74
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/pip/_internal/cli/cmdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ def check_install_build_global(options, check_options=None):
:param check_options: The options to check, if not supplied defaults to
options.
"""
if "always-install-via-wheel" in options.features_enabled:
# In this mode, we accept --global-option and --build-option that are
# passed to setup.py bdist_wheel. --install-option is not allowed at
# all in this mode, since setup.py install will not be used.
return

if check_options is None:
check_options = options

Expand All @@ -82,6 +88,7 @@ def getname(n):
if any(map(getname, names)):
control = options.format_control
control.disallow_binaries()
# TODO this should be a deprecation
warnings.warn(
'Disabling all use of wheels due to the use of --build-option '
'/ --global-option / --install-option.', stacklevel=2,
Expand Down Expand Up @@ -917,7 +924,7 @@ def check_list_path_option(options):
metavar='feature',
action='append',
default=[],
choices=['2020-resolver', 'fast-deps'],
choices=['2020-resolver', 'fast-deps', 'always-install-via-wheel'],
help='Enable new functionality, that may be backward incompatible.',
) # type: Callable[..., Option]

Expand Down
8 changes: 5 additions & 3 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@
logger = logging.getLogger(__name__)


def get_check_binary_allowed(format_control):
# type: (FormatControl) -> BinaryAllowedPredicate
def get_check_binary_allowed(format_control, features_enabled):
# type: (FormatControl, List[str]) -> BinaryAllowedPredicate
def check_binary_allowed(req):
# type: (InstallRequirement) -> bool
if "always-install-via-wheel" in features_enabled:
return True
canonical_name = canonicalize_name(req.name)
allowed_formats = format_control.get_allowed_formats(canonical_name)
return "binary" in allowed_formats
Expand Down Expand Up @@ -331,7 +333,7 @@ def run(self, options, args):
)

check_binary_allowed = get_check_binary_allowed(
finder.format_control
finder.format_control, options.features_enabled
)

reqs_to_build = [
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/wheel_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _should_build(

if not check_binary_allowed(req):
logger.info(
"Skipping wheel build for %s, due to binaries "
"Using legacy 'setup.py install' for %s, due to binaries "
"being disabled for it.", req.name,
)
return False
Expand Down

0 comments on commit 7542e74

Please sign in to comment.