You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by "abderrahim (via GitHub)" <gi...@apache.org> on 2025/06/24 09:49:10 UTC

[PR] conftest.py: use importlib.metadata instad of pkg_resources [buildstream]

abderrahim opened a new pull request, #2025:
URL: https://github.com/apache/buildstream/pull/2025

   Follow up to #1948


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@buildstream.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] conftest.py: use importlib.metadata instad of pkg_resources [buildstream]

Posted by "abderrahim (via GitHub)" <gi...@apache.org>.
abderrahim commented on code in PR #2025:
URL: https://github.com/apache/buildstream/pull/2025#discussion_r2173190260


##########
tests/testutils/setuptools.py:
##########
@@ -1,55 +0,0 @@
-#
-#  Licensed under the Apache License, Version 2.0 (the "License");
-#  you may not use this file except in compliance with the License.
-#  You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-#  Unless required by applicable law or agreed to in writing, software
-#  distributed under the License is distributed on an "AS IS" BASIS,
-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#  See the License for the specific language governing permissions and
-#  limitations under the License.
-#
-import os
-import pytest
-import pkg_resources
-
-
-# A mock setuptools dist object.
-class MockDist:
-    def __init__(self, datafiles, module_name):
-        self.datafiles = datafiles
-        self.module_name = module_name
-
-    def get_resource_filename(self, *_args, **_kwargs):
-        return os.path.join(self.datafiles, self.module_name)
-
-
-# A mock setuptools entry object.
-class MockEntry:
-    def __init__(self, datafiles, module_name):
-        self.dist = MockDist(datafiles, module_name)
-        self.module_name = module_name
-
-
-# Patch setuptools.get_entry_info
-#
-# Use result = entry_fixture(datafiles, entry_point, lookup_string) to
-# patch setuptools for external plugin loading.
-#
-@pytest.fixture()
-def entry_fixture(monkeypatch):
-    def patch(datafiles, entry_point, lookup_string):
-        dist, package = lookup_string.split(":")
-
-        def mock_entry(pdist, pentry_point, ppackage):
-            assert pdist == dist
-            assert pentry_point == entry_point
-            assert ppackage == package
-
-            return MockEntry(datafiles, package)
-
-        monkeypatch.setattr(pkg_resources, "get_entry_info", mock_entry)

Review Comment:
   I don't know what's the purpose of this file, but `pkg_resources.get_entry_point()` is no longer used by buildstream (since #1948). I'm deleting it because I think it's unused now, but we might want to replace it if it was doing something useful.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@buildstream.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] tests: use importlib.metadata instad of pkg_resources [buildstream]

Posted by "abderrahim (via GitHub)" <gi...@apache.org>.
abderrahim commented on code in PR #2025:
URL: https://github.com/apache/buildstream/pull/2025#discussion_r2185515119


##########
tests/testutils/setuptools.py:
##########
@@ -1,55 +0,0 @@
-#
-#  Licensed under the Apache License, Version 2.0 (the "License");
-#  you may not use this file except in compliance with the License.
-#  You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-#  Unless required by applicable law or agreed to in writing, software
-#  distributed under the License is distributed on an "AS IS" BASIS,
-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#  See the License for the specific language governing permissions and
-#  limitations under the License.
-#
-import os
-import pytest
-import pkg_resources
-
-
-# A mock setuptools dist object.
-class MockDist:
-    def __init__(self, datafiles, module_name):
-        self.datafiles = datafiles
-        self.module_name = module_name
-
-    def get_resource_filename(self, *_args, **_kwargs):
-        return os.path.join(self.datafiles, self.module_name)
-
-
-# A mock setuptools entry object.
-class MockEntry:
-    def __init__(self, datafiles, module_name):
-        self.dist = MockDist(datafiles, module_name)
-        self.module_name = module_name
-
-
-# Patch setuptools.get_entry_info
-#
-# Use result = entry_fixture(datafiles, entry_point, lookup_string) to
-# patch setuptools for external plugin loading.
-#
-@pytest.fixture()
-def entry_fixture(monkeypatch):
-    def patch(datafiles, entry_point, lookup_string):
-        dist, package = lookup_string.split(":")
-
-        def mock_entry(pdist, pentry_point, ppackage):
-            assert pdist == dist
-            assert pentry_point == entry_point
-            assert ppackage == package
-
-            return MockEntry(datafiles, package)
-
-        monkeypatch.setattr(pkg_resources, "get_entry_info", mock_entry)

Review Comment:
   @juergbi pointed it to me that it was used in a test `tests/plugins/third_party.py`. The test in question was removed in c7f69bcc2d772157cde3a932c0e93f09a329019f, so this is safe to delete.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@buildstream.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] tests: use importlib.metadata instad of pkg_resources [buildstream]

Posted by "abderrahim (via GitHub)" <gi...@apache.org>.
abderrahim merged PR #2025:
URL: https://github.com/apache/buildstream/pull/2025


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@buildstream.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org