Return the correct python site packages dir for the image.
(self)
| 553 | return out |
| 554 | |
| 555 | def _py_site_packages(self): |
| 556 | """Return the correct python site packages dir for the image.""" |
| 557 | if self._cached_py_site_packages is not None: |
| 558 | return self._cached_py_site_packages |
| 559 | # use the container image to probe for the correct python site-packages dir |
| 560 | py_vers = ['3.12', '3.11', '3.10', '3.9', '3.8', '3.6'] |
| 561 | valid_site_packages = [ |
| 562 | f'/usr/lib/python{v}/site-packages' for v in py_vers |
| 563 | ] |
| 564 | cmd = [ |
| 565 | self._ctx.engine, |
| 566 | "run", |
| 567 | "--rm", |
| 568 | self._ctx.base_image, |
| 569 | "ls", |
| 570 | "-d", |
| 571 | ] |
| 572 | cmd += valid_site_packages |
| 573 | if self._ctx.root_build: |
| 574 | cmd.insert(0, "sudo") |
| 575 | result = _run(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) |
| 576 | log.debug(f"container output: {result.stdout!r}") |
| 577 | for line in result.stdout.decode("utf8").splitlines(): |
| 578 | pdir = line.strip() |
| 579 | if line.strip() in valid_site_packages: |
| 580 | log.debug(f"found site packages dir: {pdir}") |
| 581 | self._cached_py_site_packages = pdir |
| 582 | return self._cached_py_site_packages |
| 583 | raise ValueError( |
| 584 | "no valid python site-packages dir found in container" |
| 585 | ) |
| 586 | |
| 587 | def _py_mgr_job(self, component): |
| 588 | name = "mgr_plugins.tar" |
no test coverage detected