From 7b8211482b22fa37f416eb21d036ed3b5c6aa163 Mon Sep 17 00:00:00 2001 From: stealthycoin Date: Mon, 24 Oct 2022 14:42:06 -0700 Subject: [PATCH] Fix metadata tests on windows --- backends/build_system/awscli_venv.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/backends/build_system/awscli_venv.py b/backends/build_system/awscli_venv.py index 793a284595a8..1816a8ed0b16 100644 --- a/backends/build_system/awscli_venv.py +++ b/backends/build_system/awscli_venv.py @@ -11,6 +11,7 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. import os +import json import subprocess import site import sys @@ -133,15 +134,18 @@ def _pip_install(self, args, cwd=None): self._utils.run(args, **run_kwargs) def _site_packages(self) -> str: - site_path = ( + # On windows the getsitepackages can return the root venv dir. + # So instead of just taking the first entry, we need to take the + # first entry that contains the string "site-packages" in the path. + site_path = [path for path in json.loads( subprocess.check_output( [ self.python_exe, "-c", - "import site; print(site.getsitepackages()[0])", + "import site, json; print(json.dumps(site.getsitepackages()))", ] ) .decode() .strip() - ) + ) if "site-packages" in path][0] return site_path