forked from temporalio/sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_release_package.py
More file actions
84 lines (69 loc) · 2.3 KB
/
Copy pathinstall_release_package.py
File metadata and controls
84 lines (69 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""Install a release package for smoke testing."""
from __future__ import annotations
import argparse
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_with_retries(
[
"--prefer-binary",
"--no-cache-dir",
"--index-url",
args.index_url,
"--no-deps",
package,
]
)
requirements = importlib.metadata.requires("temporalio") or []
if requirements:
_pip_install(
[
"--prefer-binary",
"--index-url",
args.dependency_index_url,
*requirements,
]
)
else:
_pip_install_with_retries(
[
"--prefer-binary",
"--no-cache-dir",
"--index-url",
args.index_url,
package,
]
)
subprocess.check_call([sys.executable, "-m", "pip", "check"])
def main(argv: Sequence[str] | None = None) -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--version", required=True)
parser.add_argument("--index-url", required=True)
parser.add_argument("--dependency-index-url")
install_package(parser.parse_args(argv))
if __name__ == "__main__":
main()