Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to allow enabling/disabling build isolation #758

Merged
merged 3 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions piptools/repositories/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ class PyPIRepository(BaseRepository):
config), but any other PyPI mirror can be used if index_urls is
changed/configured on the Finder.
"""
def __init__(self, pip_options, session):
def __init__(self, pip_options, session, build_isolation=False):
self.session = session
self.pip_options = pip_options
self.build_isolation = build_isolation

index_urls = [pip_options.index_url] + pip_options.extra_index_urls
if pip_options.no_index:
Expand Down Expand Up @@ -161,7 +162,7 @@ def resolve_reqs(self, download_dir, ireq, wheel_cache):
'download_dir': download_dir,
'wheel_download_dir': self._wheel_download_dir,
'progress_bar': 'off',
'build_isolation': False
'build_isolation': self.build_isolation,
}
resolver_kwargs = {
'finder': self.finder,
Expand Down
8 changes: 6 additions & 2 deletions piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@
@click.option('--max-rounds', default=10,
help="Maximum number of rounds before resolving the requirements aborts.")
@click.argument('src_files', nargs=-1, type=click.Path(exists=True, allow_dash=True))
@click.option('--build-isolation/--no-build-isolation', is_flag=True, default=False,
help="Enable isolation when building a modern source distribution. "
"Build dependencies specified by PEP 518 must be already installed "
"if build isolation is disabled.")
def cli(verbose, quiet, dry_run, pre, rebuild, find_links, index_url, extra_index_url,
cert, client_cert, trusted_host, header, index, emit_trusted_host, annotate,
upgrade, upgrade_packages, output_file, allow_unsafe, generate_hashes,
src_files, max_rounds):
src_files, max_rounds, build_isolation):
"""Compiles requirements.txt from requirements.in specs."""
log.verbosity = verbose - quiet

Expand Down Expand Up @@ -122,7 +126,7 @@ def cli(verbose, quiet, dry_run, pre, rebuild, find_links, index_url, extra_inde
pip_options, _ = pip_command.parse_args(pip_args)

session = pip_command._build_session(pip_options)
repository = PyPIRepository(pip_options, session)
repository = PyPIRepository(pip_options, session, build_isolation)

upgrade_install_reqs = {}
# Proxy with a LocalRequirementsRepository if --upgrade is not specified
Expand Down
20 changes: 20 additions & 0 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,3 +534,23 @@ def test_cert_option(MockPyPIRepository, runner, option, attr, expected):
for call in MockPyPIRepository.call_args_list:
pip_options = call[0][0]
assert getattr(pip_options, attr) == expected


@pytest.mark.parametrize('option, expected', [
('--build-isolation', True),
('--no-build-isolation', False),
])
@mock.patch('piptools.scripts.compile.PyPIRepository')
def test_build_isolation_option(MockPyPIRepository, runner, option, expected):
"""
A value of the --build-isolation/--no-build-isolation flag must be passed to the PyPIRepository.
"""
with open('requirements.in', 'w'):
pass

runner.invoke(cli, [option])

# Ensure the build_isolation in PyPIRepository has have the expected option
atugushev marked this conversation as resolved.
Show resolved Hide resolved
for call in MockPyPIRepository.call_args_list:
build_isolation = call[0][2]
assert build_isolation is expected
blueyed marked this conversation as resolved.
Show resolved Hide resolved