Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions .github/scripts/install_release_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,41 @@
import importlib.metadata
import subprocess
import sys
import time
from collections.abc import Sequence

RELEASE_INSTALL_ATTEMPTS = 31
RELEASE_INSTALL_RETRY_SECONDS = 30


def _pip_install(args: Sequence[str]) -> None:
subprocess.check_call([sys.executable, "-m", "pip", "install", *args])


def _pip_install_with_retries(args: Sequence[str]) -> None:
for attempt in range(1, RELEASE_INSTALL_ATTEMPTS + 1):
try:
_pip_install(args)
return
except subprocess.CalledProcessError:
if attempt == RELEASE_INSTALL_ATTEMPTS:
raise
print(
"Package was not installable yet; retrying in "
f"{RELEASE_INSTALL_RETRY_SECONDS}s "
f"({attempt}/{RELEASE_INSTALL_ATTEMPTS})",
flush=True,
)
time.sleep(RELEASE_INSTALL_RETRY_SECONDS)


def install_package(args: argparse.Namespace) -> None:
package = f"temporalio=={args.version}"
if args.dependency_index_url:
_pip_install(
_pip_install_with_retries(
[
"--prefer-binary",
"--no-cache-dir",
"--index-url",
args.index_url,
"--no-deps",
Expand All @@ -37,7 +59,15 @@ def install_package(args: argparse.Namespace) -> None:
]
)
else:
_pip_install(["--prefer-binary", "--index-url", args.index_url, package])
_pip_install_with_retries(
[
"--prefer-binary",
"--no-cache-dir",
"--index-url",
args.index_url,
package,
]
)

subprocess.check_call([sys.executable, "-m", "pip", "check"])

Expand Down
Loading