mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 02:37:08 +00:00
Ensure PyPI packages can still be installed on high latency connections (#53365)
This commit is contained in:
parent
745314b115
commit
6d493a848c
@ -14,6 +14,7 @@ import homeassistant.util.package as pkg_util
|
|||||||
|
|
||||||
# mypy: disallow-any-generics
|
# mypy: disallow-any-generics
|
||||||
|
|
||||||
|
PIP_TIMEOUT = 60 # The default is too low when the internet connection is satellite or high latency
|
||||||
DATA_PIP_LOCK = "pip_lock"
|
DATA_PIP_LOCK = "pip_lock"
|
||||||
DATA_PKG_CACHE = "pkg_cache"
|
DATA_PKG_CACHE = "pkg_cache"
|
||||||
DATA_INTEGRATIONS_WITH_REQS = "integrations_with_reqs"
|
DATA_INTEGRATIONS_WITH_REQS = "integrations_with_reqs"
|
||||||
@ -169,6 +170,7 @@ def pip_kwargs(config_dir: str | None) -> dict[str, Any]:
|
|||||||
kwargs = {
|
kwargs = {
|
||||||
"constraints": os.path.join(os.path.dirname(__file__), CONSTRAINT_FILE),
|
"constraints": os.path.join(os.path.dirname(__file__), CONSTRAINT_FILE),
|
||||||
"no_cache_dir": is_docker,
|
"no_cache_dir": is_docker,
|
||||||
|
"timeout": PIP_TIMEOUT,
|
||||||
}
|
}
|
||||||
if "WHEELS_LINKS" in os.environ:
|
if "WHEELS_LINKS" in os.environ:
|
||||||
kwargs["find_links"] = os.environ["WHEELS_LINKS"]
|
kwargs["find_links"] = os.environ["WHEELS_LINKS"]
|
||||||
|
@ -63,6 +63,7 @@ def install_package(
|
|||||||
target: str | None = None,
|
target: str | None = None,
|
||||||
constraints: str | None = None,
|
constraints: str | None = None,
|
||||||
find_links: str | None = None,
|
find_links: str | None = None,
|
||||||
|
timeout: int | None = None,
|
||||||
no_cache_dir: bool | None = False,
|
no_cache_dir: bool | None = False,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Install a package on PyPi. Accepts pip compatible package strings.
|
"""Install a package on PyPi. Accepts pip compatible package strings.
|
||||||
@ -73,6 +74,8 @@ def install_package(
|
|||||||
_LOGGER.info("Attempting install of %s", package)
|
_LOGGER.info("Attempting install of %s", package)
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
args = [sys.executable, "-m", "pip", "install", "--quiet", package]
|
args = [sys.executable, "-m", "pip", "install", "--quiet", package]
|
||||||
|
if timeout:
|
||||||
|
args += ["--timeout", str(timeout)]
|
||||||
if no_cache_dir:
|
if no_cache_dir:
|
||||||
args.append("--no-cache-dir")
|
args.append("--no-cache-dir")
|
||||||
if upgrade:
|
if upgrade:
|
||||||
|
@ -38,6 +38,7 @@ async def test_requirement_installed_in_venv(hass):
|
|||||||
assert mock_install.call_args == call(
|
assert mock_install.call_args == call(
|
||||||
"package==0.0.1",
|
"package==0.0.1",
|
||||||
constraints=os.path.join("ha_package_path", CONSTRAINT_FILE),
|
constraints=os.path.join("ha_package_path", CONSTRAINT_FILE),
|
||||||
|
timeout=60,
|
||||||
no_cache_dir=False,
|
no_cache_dir=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ async def test_requirement_installed_in_deps(hass):
|
|||||||
"package==0.0.1",
|
"package==0.0.1",
|
||||||
target=hass.config.path("deps"),
|
target=hass.config.path("deps"),
|
||||||
constraints=os.path.join("ha_package_path", CONSTRAINT_FILE),
|
constraints=os.path.join("ha_package_path", CONSTRAINT_FILE),
|
||||||
|
timeout=60,
|
||||||
no_cache_dir=False,
|
no_cache_dir=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -304,6 +306,7 @@ async def test_install_with_wheels_index(hass):
|
|||||||
"hello==1.0.0",
|
"hello==1.0.0",
|
||||||
find_links="https://wheels.hass.io/test",
|
find_links="https://wheels.hass.io/test",
|
||||||
constraints=os.path.join("ha_package_path", CONSTRAINT_FILE),
|
constraints=os.path.join("ha_package_path", CONSTRAINT_FILE),
|
||||||
|
timeout=60,
|
||||||
no_cache_dir=True,
|
no_cache_dir=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -327,6 +330,7 @@ async def test_install_on_docker(hass):
|
|||||||
assert mock_inst.call_args == call(
|
assert mock_inst.call_args == call(
|
||||||
"hello==1.0.0",
|
"hello==1.0.0",
|
||||||
constraints=os.path.join("ha_package_path", CONSTRAINT_FILE),
|
constraints=os.path.join("ha_package_path", CONSTRAINT_FILE),
|
||||||
|
timeout=60,
|
||||||
no_cache_dir=True,
|
no_cache_dir=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user