From 6d86c805e395f395d7059d283327b35d9eb25ee6 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Sun, 21 Mar 2021 10:12:59 +0000 Subject: [PATCH 1/4] Add failing test for issue gh-399 --- .../tests/samples/inclusion/LICENSES/README | 2 ++ flit_core/flit_core/tests/test_wheel.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 flit_core/flit_core/tests/samples/inclusion/LICENSES/README create mode 100644 flit_core/flit_core/tests/test_wheel.py diff --git a/flit_core/flit_core/tests/samples/inclusion/LICENSES/README b/flit_core/flit_core/tests/samples/inclusion/LICENSES/README new file mode 100644 index 00000000..63de8568 --- /dev/null +++ b/flit_core/flit_core/tests/samples/inclusion/LICENSES/README @@ -0,0 +1,2 @@ +This directory will match the LICENSE* glob which Flit uses to add license +files to wheel metadata. diff --git a/flit_core/flit_core/tests/test_wheel.py b/flit_core/flit_core/tests/test_wheel.py new file mode 100644 index 00000000..2c422b33 --- /dev/null +++ b/flit_core/flit_core/tests/test_wheel.py @@ -0,0 +1,12 @@ +from pathlib import Path + +from testpath import assert_isfile + +from flit_core.wheel import make_wheel_in + +samples_dir = Path(__file__).parent / 'samples' + +def test_licenses_dir(tmp_path): + # Smoketest for https://github.com/takluyver/flit/issues/399 + info = make_wheel_in(samples_dir / 'inclusion' / 'pyproject.toml', tmp_path) + assert_isfile(info.file) From c9b346069579366532efbca34adfb690f5ffef9f Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Sun, 21 Mar 2021 10:15:08 +0000 Subject: [PATCH 2/4] Only add COPYING* & LICENSE* matches if they are files Closes gh-399 --- flit_core/flit_core/wheel.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/flit_core/flit_core/wheel.py b/flit_core/flit_core/wheel.py index 388a5352..811ddd7d 100644 --- a/flit_core/flit_core/wheel.py +++ b/flit_core/flit_core/wheel.py @@ -197,8 +197,11 @@ def write_metadata(self): common.write_entry_points(self.entrypoints, f) for base in ('COPYING', 'LICENSE'): - for path in sorted(glob(str(self.directory / (base + '*')))): - self._add_file(path, '%s/%s' % (self.dist_info, osp.basename(path))) + for path in sorted(self.directory.glob(base + '*')): + if path.is_file(): + self._add_file( + path, '%s/%s' % (self.dist_info, osp.basename(path)) + ) with self._write_to_zip(self.dist_info + '/WHEEL') as f: _write_wheel_file(f, supports_py2=self.metadata.supports_py2) From c8b20680da1a92235804647f709bd0ad76973023 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Sun, 21 Mar 2021 10:18:35 +0000 Subject: [PATCH 3/4] Fix path handling for Python < 3.6 --- flit_core/flit_core/wheel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flit_core/flit_core/wheel.py b/flit_core/flit_core/wheel.py index 811ddd7d..7b55bf49 100644 --- a/flit_core/flit_core/wheel.py +++ b/flit_core/flit_core/wheel.py @@ -200,7 +200,7 @@ def write_metadata(self): for path in sorted(self.directory.glob(base + '*')): if path.is_file(): self._add_file( - path, '%s/%s' % (self.dist_info, osp.basename(path)) + path, '%s/%s' % (self.dist_info, path.name) ) with self._write_to_zip(self.dist_info + '/WHEEL') as f: From 8f50a6717b6448aa31e48e2a8cd3eca3e41ea77d Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Sun, 21 Mar 2021 10:20:46 +0000 Subject: [PATCH 4/4] This fits on one line again --- flit_core/flit_core/wheel.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/flit_core/flit_core/wheel.py b/flit_core/flit_core/wheel.py index 7b55bf49..afb752cf 100644 --- a/flit_core/flit_core/wheel.py +++ b/flit_core/flit_core/wheel.py @@ -199,9 +199,7 @@ def write_metadata(self): for base in ('COPYING', 'LICENSE'): for path in sorted(self.directory.glob(base + '*')): if path.is_file(): - self._add_file( - path, '%s/%s' % (self.dist_info, path.name) - ) + self._add_file(path, '%s/%s' % (self.dist_info, path.name)) with self._write_to_zip(self.dist_info + '/WHEEL') as f: _write_wheel_file(f, supports_py2=self.metadata.supports_py2)