Skip to content

Commit

Permalink
Allow --prefer-binary option in requirements file
Browse files Browse the repository at this point in the history
  • Loading branch information
deveshks committed Apr 8, 2020
1 parent 451f5d9 commit 6e048b2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/7693.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow specifying --prefer-binary option in a requirements file
2 changes: 2 additions & 0 deletions src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ def install_requirements(
args.extend(['--trusted-host', host])
if finder.allow_all_prereleases:
args.append('--pre')
if finder.prefer_binary:
args.append('--prefer-binary')
args.append('--')
args.extend(requirements)
with open_spinner(message) as spinner:
Expand Down
9 changes: 9 additions & 0 deletions src/pip/_internal/index/package_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,15 @@ def set_allow_all_prereleases(self):
# type: () -> None
self._candidate_prefs.allow_all_prereleases = True

@property
def prefer_binary(self):
# type: () -> bool
return self._candidate_prefs.prefer_binary

def set_prefer_binary(self):
# type: () -> None
self._candidate_prefs.prefer_binary = True

def make_link_evaluator(self, project_name):
# type: (str) -> LinkEvaluator
canonical_name = canonicalize_name(project_name)
Expand Down
4 changes: 4 additions & 0 deletions src/pip/_internal/req/req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
cmdoptions.find_links,
cmdoptions.no_binary,
cmdoptions.only_binary,
cmdoptions.prefer_binary,
cmdoptions.require_hashes,
cmdoptions.pre,
cmdoptions.trusted_host,
Expand Down Expand Up @@ -269,6 +270,9 @@ def handle_option_line(
if opts.pre:
finder.set_allow_all_prereleases()

if opts.prefer_binary:
finder.set_prefer_binary()

if session:
for host in opts.trusted_hosts or []:
source = 'line {} of {}'.format(lineno, filename)
Expand Down

0 comments on commit 6e048b2

Please sign in to comment.