From ff1bb2eee097ded0f9b7821b0975465df52d10ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Sat, 30 Oct 2021 17:22:22 +0100 Subject: [PATCH 1/5] metadata: remove Distribution._local MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Importing an external module is anti-pattern and very unexpected behavior. Furthermore, the specific builder implementation we are using will provision an isolated virtual environmnent and perform the build there, which is unwanted in various scenarious. Perhaps there was a time this helper was needed, but we can now remove this in favor of build.util.project_wheel_metadata[1]. [1] https://github.com/pypa/build/blob/82051d509a87124a46f3766134c11fc8aee9b86a/src/build/util.py#L27 Signed-off-by: Filipe LaĆ­ns --- importlib_metadata/__init__.py | 12 ------------ tests/test_integration.py | 7 ------- 2 files changed, 19 deletions(-) diff --git a/importlib_metadata/__init__.py b/importlib_metadata/__init__.py index 95427cb2..1c4df5fe 100644 --- a/importlib_metadata/__init__.py +++ b/importlib_metadata/__init__.py @@ -576,18 +576,6 @@ def _discover_resolvers(): ) return filter(None, declared) - @classmethod - def _local(cls, root='.'): - from pep517 import build, meta - - system = build.compat_system(root) - builder = functools.partial( - meta.build, - source_dir=root, - system=system, - ) - return PathDistribution(zipp.Path(meta.build_as_zip(builder))) - @property def metadata(self) -> _meta.PackageMetadata: """Return the parsed metadata for this Distribution. diff --git a/tests/test_integration.py b/tests/test_integration.py index 00e9021a..a73fad9c 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -44,13 +44,6 @@ def __getattribute__(self, name): _compat.disable_stdlib_finder() -class LocalProjectTests(fixtures.LocalPackage, unittest.TestCase): - def test_find_local(self): - dist = Distribution._local() - assert dist.metadata['Name'] == 'local-pkg' - assert dist.version == '2.0.1' - - class DistSearch(unittest.TestCase): def test_search_dist_dirs(self): """ From 54c0860b9b4fa324ec85507dc6002778fd46000a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 13 Nov 2021 21:20:02 -0500 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=91=B9=20Feed=20the=20hobgoblins=20(d?= =?UTF-8?q?elint).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_integration.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_integration.py b/tests/test_integration.py index a73fad9c..c382a506 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -4,7 +4,6 @@ from . import fixtures from importlib_metadata import ( - Distribution, MetadataPathFinder, _compat, distributions, From eca1c4ca6e104c8add280c721cbb365196f55ac7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 24 Nov 2021 20:38:46 -0500 Subject: [PATCH 3/5] Remove filtered warnings, addressed upstream. --- pytest.ini | 2 -- 1 file changed, 2 deletions(-) diff --git a/pytest.ini b/pytest.ini index 9ecdba49..ec965b24 100644 --- a/pytest.ini +++ b/pytest.ini @@ -5,5 +5,3 @@ doctest_optionflags=ALLOW_UNICODE ELLIPSIS filterwarnings= # Suppress deprecation warning in flake8 ignore:SelectableGroups dict interface is deprecated::flake8 - # Suppress deprecation warning in pypa/packaging#433 - ignore:The distutils package is deprecated::packaging.tags From e59f3b6f5515b1c318cced6ba2deb55aa468c731 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 19 Dec 2021 21:34:28 -0500 Subject: [PATCH 4/5] Remove pep517 dependency and LocalPackage fixture, no longer used. --- setup.cfg | 1 - tests/fixtures.py | 15 --------------- 2 files changed, 16 deletions(-) diff --git a/setup.cfg b/setup.cfg index c9e59571..0b6c9dea 100644 --- a/setup.cfg +++ b/setup.cfg @@ -46,7 +46,6 @@ testing = # local importlib_resources>=1.3; python_version < "3.9" packaging - pep517 pyfakefs flufl.flake8 pytest-perf >= 0.9.2 diff --git a/tests/fixtures.py b/tests/fixtures.py index c6e645f5..5e42c827 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -231,21 +231,6 @@ def setUp(self): build_files(EggInfoFile.files, prefix=self.site_dir) -class LocalPackage: - files: FilesDef = { - "setup.py": """ - import setuptools - setuptools.setup(name="local-pkg", version="2.0.1") - """, - } - - def setUp(self): - self.fixtures = contextlib.ExitStack() - self.addCleanup(self.fixtures.close) - self.fixtures.enter_context(tempdir_as_cwd()) - build_files(self.files) - - def build_files(file_defs, prefix=pathlib.Path()): """Build a set of files/directories, as described by the From 4a2f7d54b75bdd02ab18b726b61bdd5117bec32c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 19 Dec 2021 21:43:41 -0500 Subject: [PATCH 5/5] Update changelog. --- CHANGES.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 7085ef52..b0b4e58c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,13 @@ +v4.9.0 +====== + +* #354: Removed ``Distribution._local`` factory. This + functionality was created as a demonstration of the + possible implementation. Now, the + `pep517 `_ package + provides this functionality directly through + `pep517.meta.load `_. + v4.8.1 ======