Skip to contentSkip to conversation

lib/oe/distro_check: use vendored bs4

PATCH New Tim Orling 1 participant 1 message Nov 22

lore
Share & tools
lore

Tim Orling

author
#0 lore raw

PATCH 1/1 lib/oe/distro_check: use vendored bs4

bitbake moved its bundled bs4 to bb._vendor.bs4 (4b4b9c60f "lib:
Vendorize bundled third-party libraries under bb._vendor"), so "from bs4 import" only works if the host has its own bs4 installed. Without it, get_links_from_url() fails, and the selftest added in cc911c5eae ("lib/oe/distro_check: fix the openSUSE Leap package lists") skips itself. Import from bb._vendor.bs4, as bb.fetch.wget does, and drop the skip.

Tested with "python3 -m unittest oeqa.selftest.cases.oelib.distro_check" on a host without bs4: the test is no longer skipped and passes.

AI-Generated: Uses Claude Code (Claude Opus 5.5)

---
 meta/lib/oe/distro_check.py                        | 2 +-
 meta/lib/oeqa/selftest/cases/oelib/distro_check.py | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)
meta/lib/oe/distro_check.py +1 -1
index d8e487318c..74862bdd8f 100644
@@ -17,7 +17,7 @@ def create_socket(url, d):
 def get_links_from_url(url, d):
     "Return all the href links found on the web location"
 
-    from bs4 import BeautifulSoup, SoupStrainer
+    from bb._vendor.bs4 import BeautifulSoup, SoupStrainer
 
     soup = BeautifulSoup(create_socket(url,d), "html.parser", parse_only=SoupStrainer("a"))
     hyperlinks = []
meta/lib/oeqa/selftest/cases/oelib/distro_check.py +0 -4
index d783384251..583e5dcbf6 100644
@@ -62,10 +62,6 @@ class TestOpenSUSE(TestCase):
 <a href="./15.6/">15.6/</a> <a href="./16.0/">16.0/</a> <a href="./42.3/">42.3/</a>"""
 
     def test_links_relative_to_current_directory(self):
-        try:
-            from bs4 import BeautifulSoup, SoupStrainer
-        except ImportError:
-            self.skipTest("bs4 is not available")
         with mock.patch.object(oe.distro_check, "create_socket", return_value=io.BytesIO(self.LISTING)):
             links = oe.distro_check.get_links_from_url("http://example.com/leap/", None)
         self.assertEqual(links, ["..", "15.0-Current", "15.6", "16.0", "42.3"])
Signature · 1 line
2.47.3