summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnderson Bravalheri <andersonbravalheri+github@gmail.com>2022-10-20 13:53:00 +0100
committerGitHub <noreply@github.com>2022-10-20 15:53:00 +0300
commiteaa09fc98065a023699f36bb6a127b86cdde90c3 (patch)
tree9b3ddc6bd50cb7973914104f910f8ff3e09f62f2
parent048b2ced1ad2ac1726ea556ed8049318b3e40b33 (diff)
downloadwheel-git-eaa09fc98065a023699f36bb6a127b86cdde90c3.tar.gz
Add support for `license_files` specified in `setup.py` (#466)
Wheel now leans on setuptools to provide the necessary information.
-rw-r--r--docs/news.rst3
-rw-r--r--setup.cfg2
-rw-r--r--src/wheel/bdist_wheel.py35
-rw-r--r--tests/test_bdist_wheel.py47
4 files changed, 29 insertions, 58 deletions
diff --git a/docs/news.rst b/docs/news.rst
index aa46010..d348b87 100644
--- a/docs/news.rst
+++ b/docs/news.rst
@@ -6,6 +6,9 @@ Release Notes
- Dropped support for Python < 3.7
- Updated vendored ``packaging`` to 21.3
- Replaced all uses of ``distutils`` with ``setuptools``
+- The handling of ``license_files`` (including glob patterns and default
+ values) is now delegated to ``setuptools>=57.0.0`` (#466).
+ The package dependencies were updated to reflect this change.
**0.37.1 (2021-12-22)**
diff --git a/setup.cfg b/setup.cfg
index 1b71a18..75079a2 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -31,7 +31,7 @@ package_dir=
= src
packages = find:
python_requires = >=3.7
-install_requires = setuptools >= 45.2.0
+install_requires = setuptools >= 57.0.0
zip_safe = False
[options.packages.find]
diff --git a/src/wheel/bdist_wheel.py b/src/wheel/bdist_wheel.py
index 929864e..7cbd140 100644
--- a/src/wheel/bdist_wheel.py
+++ b/src/wheel/bdist_wheel.py
@@ -15,7 +15,6 @@ import sysconfig
import warnings
from collections import OrderedDict
from email.generator import BytesGenerator, Generator
-from glob import iglob
from io import BytesIO
from shutil import rmtree
from sysconfig import get_config_var
@@ -432,38 +431,8 @@ class bdist_wheel(Command):
@property
def license_paths(self):
- metadata = self.distribution.get_option_dict("metadata")
- files = set()
- patterns = sorted(
- {option for option in metadata.get("license_files", ("", ""))[1].split()}
- )
-
- if "license_file" in metadata:
- warnings.warn(
- 'The "license_file" option is deprecated. Use '
- '"license_files" instead.',
- DeprecationWarning,
- )
- files.add(metadata["license_file"][1])
-
- if "license_file" not in metadata and "license_files" not in metadata:
- patterns = ("LICEN[CS]E*", "COPYING*", "NOTICE*", "AUTHORS*")
-
- for pattern in patterns:
- for path in iglob(pattern):
- if path.endswith("~"):
- log.debug(
- f'ignoring license file "{path}" as it looks like a ' f"backup"
- )
- continue
-
- if path not in files and os.path.isfile(path):
- log.info(
- f'adding license file "{path}" (matched pattern "{pattern}")'
- )
- files.add(path)
-
- return files
+ metadata = self.distribution.metadata
+ return sorted(metadata.license_files or [])
def egg2dist(self, egginfo_path, distinfo_path):
"""Convert an .egg-info directory into a .dist-info directory"""
diff --git a/tests/test_bdist_wheel.py b/tests/test_bdist_wheel.py
index 981a21f..5ed9a41 100644
--- a/tests/test_bdist_wheel.py
+++ b/tests/test_bdist_wheel.py
@@ -34,21 +34,20 @@ OTHER_IGNORED_FILES = {
"LICENSE~",
"AUTHORS~",
}
-
-
-@pytest.fixture
-def dummy_dist(tmpdir_factory):
- basedir = tmpdir_factory.mktemp("dummy_dist")
- basedir.join("setup.py").write(
- """\
+SETUPPY_EXAMPLE = """\
from setuptools import setup
setup(
name='dummy_dist',
- version='1.0'
+ version='1.0',
)
"""
- )
+
+
+@pytest.fixture
+def dummy_dist(tmpdir_factory):
+ basedir = tmpdir_factory.mktemp("dummy_dist")
+ basedir.join("setup.py").write(SETUPPY_EXAMPLE)
for fname in DEFAULT_LICENSE_FILES | OTHER_IGNORED_FILES:
basedir.join(fname).write("")
@@ -83,21 +82,21 @@ def test_licenses_default(dummy_dist, monkeypatch, tmpdir):
assert set(wf.namelist()) == DEFAULT_FILES | license_files
-def test_licenses_deprecated(dummy_dist, monkeypatch, tmpdir):
- dummy_dist.join("setup.cfg").write("[metadata]\nlicense_file=licenses/DUMMYFILE")
- monkeypatch.chdir(dummy_dist)
- subprocess.check_call(
- [sys.executable, "setup.py", "bdist_wheel", "-b", str(tmpdir), "--universal"]
- )
- with WheelFile("dist/dummy_dist-1.0-py2.py3-none-any.whl") as wf:
- license_files = {"dummy_dist-1.0.dist-info/DUMMYFILE"}
- assert set(wf.namelist()) == DEFAULT_FILES | license_files
-
-
-def test_licenses_override(dummy_dist, monkeypatch, tmpdir):
- dummy_dist.join("setup.cfg").write(
- "[metadata]\nlicense_files=licenses/*\n LICENSE"
- )
+@pytest.mark.parametrize(
+ "config_file, config",
+ [
+ ("setup.cfg", "[metadata]\nlicense_files=licenses/*\n LICENSE"),
+ ("setup.cfg", "[metadata]\nlicense_files=licenses/*, LICENSE"),
+ (
+ "setup.py",
+ SETUPPY_EXAMPLE.replace(
+ ")", " license_files=['licenses/DUMMYFILE', 'LICENSE'])"
+ ),
+ ),
+ ],
+)
+def test_licenses_override(dummy_dist, monkeypatch, tmpdir, config_file, config):
+ dummy_dist.join(config_file).write(config)
monkeypatch.chdir(dummy_dist)
subprocess.check_call(
[sys.executable, "setup.py", "bdist_wheel", "-b", str(tmpdir), "--universal"]