Skip to content

Commit

Permalink
fix(fhempy): Expand Container Check for Kubernetes (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellampert committed Dec 17, 2022
1 parent b1ff91b commit 529f46c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions FHEM/bindings/python/bin/fhempy
Expand Up @@ -69,17 +69,24 @@ def is_virtual_env():
)


def is_docker_env():
"""Return True if we run in a docker env."""
return Path("/.dockerenv").exists()
def is_container_env():
if Path("/.dockerenv").exists():
"""Return True if we run in a docker env."""
container = True
elif Path("/var/run/secrets/kubernetes.io").exists():
"""Return True if we run in a Kubernetes env."""
container = True
else:
container = False
return container


def pip_kwargs(config_dir):
"""Return keyword arguments for PIP install."""
is_docker = is_docker_env()
is_container = is_container_env()
kwargs = {
# "constraints": os.path.join(os.path.dirname(__file__), CONSTRAINT_FILE),
"no_cache_dir": is_docker,
"no_cache_dir": is_container,
}
if "WHEELS_LINKS" in os.environ:
kwargs["find_links"] = os.environ["WHEELS_LINKS"]
Expand Down

0 comments on commit 529f46c

Please sign in to comment.