Merge pull request #8601 from rouge8/use-feature-requirements-file

This commit is contained in:
Pradyun Gedam 2020-07-27 13:19:51 +05:30 committed by GitHub
commit 7056132f6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 5 deletions

1
news/8601.feature Normal file
View File

@ -0,0 +1 @@
Support ``--use-feature`` in requirements files

View File

@ -100,7 +100,8 @@ def freeze(
'--pre',
'--trusted-host',
'--process-dependency-links',
'--extra-index-url'))):
'--extra-index-url',
'--use-feature'))):
line = line.rstrip()
if line not in emitted_options:
emitted_options.add(line)

View File

@ -62,6 +62,7 @@ SUPPORTED_OPTIONS = [
cmdoptions.require_hashes,
cmdoptions.pre,
cmdoptions.trusted_host,
cmdoptions.use_new_feature,
] # type: List[Callable[..., optparse.Option]]
# options to be passed to requirements
@ -224,12 +225,18 @@ def handle_option_line(
):
# type: (...) -> None
# percolate hash-checking option upward
if options and opts.require_hashes:
options.require_hashes = opts.require_hashes
if options:
# percolate options upward
if opts.require_hashes:
options.require_hashes = opts.require_hashes
if opts.features_enabled:
options.features_enabled.extend(
f for f in opts.features_enabled
if f not in options.features_enabled
)
# set finder options
elif finder:
if finder:
find_links = finder.find_links
index_urls = finder.index_urls
if opts.index_url:

View File

@ -548,6 +548,7 @@ _freeze_req_opts = textwrap.dedent("""\
--extra-index-url http://ignore
--find-links http://ignore
--index-url http://ignore
--use-feature 2020-resolver
""")

View File

@ -47,6 +47,7 @@ def options(session):
isolated_mode=False,
index_url='default_url',
format_control=FormatControl(set(), set()),
features_enabled=[],
)
@ -382,6 +383,13 @@ class TestProcessLine(object):
line_processor("--pre", "file", 1, finder=finder)
assert finder.allow_all_prereleases
def test_use_feature(self, line_processor, options):
"""--use-feature can be set in requirements files."""
line_processor(
"--use-feature=2020-resolver", "filename", 1, options=options
)
assert "2020-resolver" in options.features_enabled
def test_relative_local_find_links(
self, line_processor, finder, monkeypatch, tmpdir
):