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

Support build isolation using setuptools/pyproject.toml requirement files #1727

Merged
merged 4 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
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