Skip to content

Commit

Permalink
Support build isolation in setuptools/pyproject.toml requirement files (
Browse files Browse the repository at this point in the history
#1727)

Pass --build-isolation/--no-build-isolation option to metadata builder
when setuptools/pyproject.toml requirement file is used.
  • Loading branch information
atugushev committed Nov 15, 2022
1 parent 3d1e7e4 commit 8447633
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
3 changes: 2 additions & 1 deletion piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ def cli(
setup_file_found = True
try:
metadata = project_wheel_metadata(
os.path.dirname(os.path.abspath(src_file))
os.path.dirname(os.path.abspath(src_file)),
isolated=build_isolation,
)
except BuildBackendException as e:
log.error(str(e))
Expand Down
34 changes: 33 additions & 1 deletion tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,9 @@ def test_cert_option(parse_requirements, runner, option, attr, expected):
(("--build-isolation", True), ("--no-build-isolation", False)),
)
@mock.patch("piptools.scripts.compile.parse_requirements")
def test_build_isolation_option(parse_requirements, runner, option, expected):
def test_parse_requirements_build_isolation_option(
parse_requirements, runner, option, expected
):
"""
A value of the --build-isolation/--no-build-isolation flag
must be passed to parse_requirements().
Expand All @@ -1506,6 +1508,36 @@ def test_build_isolation_option(parse_requirements, runner, option, expected):
assert kwargs["options"].build_isolation is expected


@pytest.mark.parametrize(
("option", "expected"),
(("--build-isolation", True), ("--no-build-isolation", False)),
)
@mock.patch("piptools.scripts.compile.project_wheel_metadata")
def test_project_wheel_metadata_isolation_option(
project_wheel_metadata, runner, option, expected
):
"""
A value of the --build-isolation/--no-build-isolation flag
must be passed to project_wheel_metadata().
"""

with open("setup.py", "w") as package:
package.write(
dedent(
"""\
from setuptools import setup
setup(install_requires=[])
"""
)
)

runner.invoke(cli, [option])

# Ensure the options in project_wheel_metadata has the isolated kwarg
_, kwargs = project_wheel_metadata.call_args
assert kwargs["isolated"] is expected


@mock.patch("piptools.scripts.compile.PyPIRepository")
def test_forwarded_args(PyPIRepository, runner):
"""
Expand Down

0 comments on commit 8447633

Please sign in to comment.