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

Revert Only pass --build-option to bdist_wheel in build_meta #4218

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions newsfragments/4218.bugfix.rst
@@ -0,0 +1,2 @@
Revert Only pass --build-option to bdist_wheel in build_meta
change which broke ability to pass args to all commands.
8 changes: 3 additions & 5 deletions setuptools/build_meta.py
Expand Up @@ -289,6 +289,7 @@ def _get_build_requires(self, config_settings, requirements):
*sys.argv[:1],
*self._global_args(config_settings),
"egg_info",
*self._arbitrary_args(config_settings),
]
try:
with Distribution.patch():
Expand Down Expand Up @@ -376,14 +377,14 @@ def _build_with_temp_dir(
# Build in a temporary directory, then copy to the target.
os.makedirs(result_directory, exist_ok=True)
temp_opts = {"prefix": ".tmp-", "dir": result_directory}

with tempfile.TemporaryDirectory(**temp_opts) as tmp_dist_dir:
sys.argv = [
*sys.argv[:1],
*self._global_args(config_settings),
*setup_command,
"--dist-dir",
tmp_dist_dir,
*self._arbitrary_args(config_settings),
]
with no_install_setup_requires():
self.run_setup()
Expand All @@ -402,10 +403,7 @@ def build_wheel(
):
with suppress_known_deprecation():
return self._build_with_temp_dir(
['bdist_wheel', *self._arbitrary_args(config_settings)],
'.whl',
wheel_directory,
config_settings,
['bdist_wheel'], '.whl', wheel_directory, config_settings
)

def build_sdist(self, sdist_directory, config_settings=None):
Expand Down
28 changes: 27 additions & 1 deletion setuptools/tests/test_build_meta.py
Expand Up @@ -706,6 +706,25 @@ def _assert_link_tree(self, parent_dir):
for file in files:
assert file.is_symlink() or os.stat(file).st_nlink > 0

@pytest.mark.filterwarnings("ignore::setuptools.SetuptoolsDeprecationWarning")
# Since the backend is running via a process pool, in some operating systems
# we may have problems to make assertions based on warnings/stdout/stderr...
# So the best is to ignore them for the time being.
def test_editable_with_global_option_still_works(self, tmpdir_cwd):
"""The usage of --global-option is now discouraged in favour of --build-option.
This is required to make more sense of the provided scape hatch and align with
previous pip behaviour. See pypa/setuptools#1928.
"""
path.build({**self._simple_pyproject_example, '_meta': {}})
build_backend = self.get_build_backend()
assert not Path("build").exists()

cfg = {"--global-option": ["--mode", "strict"]}
build_backend.prepare_metadata_for_build_editable("_meta", cfg)
build_backend.build_editable("temp", cfg, "_meta")

self._assert_link_tree(next(Path("build").glob("__editable__.*")))

def test_editable_without_config_settings(self, tmpdir_cwd):
"""
Sanity check to ensure tests with --mode=strict are different from the ones
Expand All @@ -720,7 +739,14 @@ def test_editable_without_config_settings(self, tmpdir_cwd):
build_backend.build_editable("temp")
assert not Path("build").exists()

@pytest.mark.parametrize("config_settings", [{"editable-mode": "strict"}])
@pytest.mark.parametrize(
"config_settings",
[
{"--build-option": ["build_ext", "--inplace"]},
{"--build-option": ["--mode", "strict"]},
{"editable-mode": "strict"},
],
)
def test_editable_with_config_settings(self, tmpdir_cwd, config_settings):
path.build({**self._simple_pyproject_example, '_meta': {}})
assert not Path("build").exists()
Expand Down