diff options
| author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2023-04-20 16:48:41 +0100 |
|---|---|---|
| committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2023-05-05 18:26:25 +0100 |
| commit | bb6c6f3082cd55aadf08333a1febd739a6581bfa (patch) | |
| tree | 78b89c6cc8a484a411de1903a3ee523109e270aa | |
| parent | ce9d39651ecc593662ccc3202335b004ebd47469 (diff) | |
| download | python-setuptools-git-bb6c6f3082cd55aadf08333a1febd739a6581bfa.tar.gz | |
Integrate new bdist_wheel command with backend
| -rw-r--r-- | bootstrap.egg-info/entry_points.txt | 1 | ||||
| -rw-r--r-- | setup.cfg | 1 | ||||
| -rw-r--r-- | setuptools/build_meta.py | 11 | ||||
| -rw-r--r-- | setuptools/tests/test_build_meta.py | 42 |
4 files changed, 37 insertions, 18 deletions
diff --git a/bootstrap.egg-info/entry_points.txt b/bootstrap.egg-info/entry_points.txt index a21ca227..be66b73a 100644 --- a/bootstrap.egg-info/entry_points.txt +++ b/bootstrap.egg-info/entry_points.txt @@ -3,6 +3,7 @@ egg_info = setuptools.command.egg_info:egg_info build_py = setuptools.command.build_py:build_py sdist = setuptools.command.sdist:sdist editable_wheel = setuptools.command.editable_wheel:editable_wheel +bdist_wheel = setuptools.command.bdist_wheel:bdist_wheel [distutils.setup_keywords] include_package_data = setuptools.dist:assert_bool @@ -120,6 +120,7 @@ distutils.commands = build_clib = setuptools.command.build_clib:build_clib build_ext = setuptools.command.build_ext:build_ext build_py = setuptools.command.build_py:build_py + bdist_wheel = setuptools.command.bdist_wheel:bdist_wheel develop = setuptools.command.develop:develop dist_info = setuptools.command.dist_info:dist_info easy_install = setuptools.command.easy_install:easy_install diff --git a/setuptools/build_meta.py b/setuptools/build_meta.py index ee8ef13f..5e050ccc 100644 --- a/setuptools/build_meta.py +++ b/setuptools/build_meta.py @@ -338,7 +338,7 @@ class _BuildMetaBackend(_ConfigSettingsTranslator): exec(code, locals()) def get_requires_for_build_wheel(self, config_settings=None): - return self._get_build_requires(config_settings, requirements=['wheel']) + return self._get_build_requires(config_settings, requirements=[]) def get_requires_for_build_sdist(self, config_settings=None): return self._get_build_requires(config_settings, requirements=[]) @@ -412,9 +412,14 @@ class _BuildMetaBackend(_ConfigSettingsTranslator): def build_wheel(self, wheel_directory, config_settings=None, metadata_directory=None): + info_dir = self._get_dist_info_dir(metadata_directory) + cmd = ["bdist_wheel"] + if info_dir: + cmd = ["dist_info", "--use-cached", "--dist-info-dir", info_dir] + cmd with suppress_known_deprecation(): - return self._build_with_temp_dir(['bdist_wheel'], '.whl', - wheel_directory, config_settings) + return self._build_with_temp_dir( + cmd, ".whl", wheel_directory, config_settings + ) def build_sdist(self, sdist_directory, config_settings=None): return self._build_with_temp_dir(['sdist', '--formats', 'gztar'], diff --git a/setuptools/tests/test_build_meta.py b/setuptools/tests/test_build_meta.py index 4db4de65..052cff34 100644 --- a/setuptools/tests/test_build_meta.py +++ b/setuptools/tests/test_build_meta.py @@ -1,19 +1,21 @@ +import contextlib +import importlib import os -import sys +import re import shutil import signal +import sys import tarfile -import importlib -import contextlib from concurrent import futures -import re -from zipfile import ZipFile +from email import message_from_string from pathlib import Path +from zipfile import ZipFile import pytest from jaraco import path from .textwrap import DALS +from setuptools import _reqs SETUP_SCRIPT_STUB = "__import__('setuptools').setup()" @@ -211,7 +213,7 @@ class TestBuildMetaBackend: def test_get_requires_for_build_wheel(self, build_backend): actual = build_backend.get_requires_for_build_wheel() - expected = ['six', 'wheel'] + expected = ['six'] assert sorted(actual) == sorted(expected) def test_get_requires_for_build_sdist(self, build_backend): @@ -404,12 +406,17 @@ class TestBuildMetaBackend: "Summary: This is a Python package", "License: MIT", "Classifier: Intended Audience :: Developers", - "Requires-Dist: appdirs", - "Requires-Dist: tomli (>=1) ; extra == 'all'", - "Requires-Dist: importlib ; (python_version == \"2.6\") and extra == 'all'" ): assert line in metadata + reqs = [ + "appdirs", + "tomli>=1; extra == 'all'", + "importlib; python_version == '2.6' and extra == 'all'", + "pyscaffold<5,>=4; extra == 'all'", + ] + _assert_dependencies(metadata, reqs) + assert metadata.strip().endswith("This is a ``README``") assert epoints.strip() == "[console_scripts]\nfoo = foo.cli:main" @@ -733,17 +740,15 @@ class TestBuildMetaBackend: build_backend = self.get_build_backend() if use_wheel: - base_requirements = ['wheel'] get_requires = build_backend.get_requires_for_build_wheel else: - base_requirements = [] get_requires = build_backend.get_requires_for_build_sdist # Ensure that the build requirements are properly parsed - expected = sorted(base_requirements + requirements) - actual = get_requires() + expected = sorted(requirements) + actual = sorted(get_requires()) - assert expected == sorted(actual) + assert expected == actual def test_setup_requires_with_auto_discovery(self, tmpdir_cwd): # Make sure patches introduced to retrieve setup_requires don't accidentally @@ -767,7 +772,7 @@ class TestBuildMetaBackend: path.build(files) build_backend = self.get_build_backend() setup_requires = build_backend.get_requires_for_build_wheel() - assert setup_requires == ["wheel", "foo"] + assert setup_requires == ["foo"] def test_dont_install_setup_requires(self, tmpdir_cwd): files = { @@ -889,3 +894,10 @@ def test_legacy_editable_install(venv, tmpdir, tmpdir_cwd): cmd = ["pip", "install", "--no-build-isolation", "-e", "."] output = str(venv.run(cmd, cwd=tmpdir, env=env), "utf-8").lower() assert "running setup.py develop for myproj" in output + + +def _assert_dependencies(metadata, reqs): + expected = _reqs.parse(reqs) + message = message_from_string(metadata) + found = _reqs.parse(message.get_all("Requires-Dist")) + assert set(found) == set(expected) |
