Skip to content

Commit

Permalink
Add file lock when searching xbuildenvs
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Sep 24, 2024
1 parent 09af46f commit 66999cb
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions cibuildwheel/pyodide.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,28 @@ def install_emscripten(tmp: Path, version: str) -> Path:

def search_xbuildenv(env: dict[str, str]) -> list[str]:
"""Searches for the compatible xbuildenvs for the current pyodide-build version"""
xbuildenvs = call(
"pyodide",
"xbuildenv",
"search",
"--json",
"--all",
env=env,
cwd=CIBW_CACHE_PATH,
capture_stdout=True,
).strip()
xbuildenvs_dict = json.loads(xbuildenvs)
compatible_xbuildenvs = [
env["version"] for env in xbuildenvs_dict["environments"] if env["compatible"]
]
# Fetch just the "stable" versions
compatible_xbuildenvs_filtered = [
version for version in compatible_xbuildenvs if not any(_ in version for _ in "abc")
]
# TODO: possibly remove that? Since this won't allow testing the unstable/dev versions

return compatible_xbuildenvs_filtered
with FileLock(CIBW_CACHE_PATH / "xbuildenv.lock"):
xbuildenvs = call(
"pyodide",
"xbuildenv",
"search",
"--json",
"--all",
env=env,
cwd=CIBW_CACHE_PATH,
capture_stdout=True,
).strip()
xbuildenvs_dict = json.loads(xbuildenvs)
compatible_xbuildenvs = [
env["version"] for env in xbuildenvs_dict["environments"] if env["compatible"]
]
# Fetch just the "stable" versions
compatible_xbuildenvs_filtered = [
version for version in compatible_xbuildenvs if not any(_ in version for _ in "abc")
]
# TODO: possibly remove that? Since this won't allow testing the unstable/dev versions

return compatible_xbuildenvs_filtered


# The xbuildenv version is brought in sync with the pyodide-build version in build-platforms.toml,
Expand Down

0 comments on commit 66999cb

Please sign in to comment.