Skip to content

Commit

Permalink
Fix metadata tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
stealthycoin committed Oct 25, 2022
1 parent 9b05024 commit 69a7f45
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 7 additions & 3 deletions backends/build_system/awscli_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
7 changes: 4 additions & 3 deletions tests/backends/build_system/functional/test_aws_cli_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 contextlib
import json
import re
import os
import sys
Expand Down Expand Up @@ -87,17 +88,17 @@ def _python_version(self) -> str:
return f"python{info[0]}.{info[1]}"

def _site_packages_dir(self, venv_path: pathlib.PurePath) -> str:
site_path = (
site_path = [path for path in json.loads(
subprocess.check_output(
[
venv_path / BIN_DIRNAME / PYTHON_EXE_NAME,
"-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

@skip_if_windows("Posix virtualenv")
Expand Down

0 comments on commit 69a7f45

Please sign in to comment.