Skip to content

Commit

Permalink
Get version of python for installed library
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Aug 22, 2024
1 parent fac4cd7 commit e9b2742
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
16 changes: 10 additions & 6 deletions ramalama.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ def main(args):
if host != port:
port = host.rsplit(':', 1)[1]

syspath = '/usr/share/ramalama/python'
sys.path.insert(0, syspath)

if conman:
home = os.path.expanduser('~')
cwd = os.getcwd()
wd = os.path.join(cwd, "ramalama")
if not os.path.exists(wd):
wd = "/usr/lib/python3.12/site-packages/podman"
libpath = "/usr/lib/python3.12/site-packages/ramalama"
wd = "ramalama"
for p in sys.path:
target = p+"ramalama"
if os.path.exists(target):
wd = target
break
conman_args = [conman, "run",
"--rm",
"-it",
Expand All @@ -44,7 +48,7 @@ def main(args):
f"-v{home}:{home}",
"-v/tmp:/tmp",
f"-v{sys.argv[0]}:/usr/bin/ramalama",
f"-v{wd}:{libpath}",
f"-v{wd}:{syspath}",
"-e", "RAMALAMA_HOST",
"-p", f"{host}:{port}",
"quay.io/ramalama/ramalama:latest", __file__] + args
Expand Down
7 changes: 0 additions & 7 deletions ramalama/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,6 @@ def create_store():
return store


def in_container():
if os.path.exists("/run/.containerenv") or os.path.exists("/.dockerenv") or os.getenv("container"):
return True

return False


funcDict = {}
funcDict["list"] = list_cli
funcDict["ls"] = list_cli
Expand Down
9 changes: 8 additions & 1 deletion ramalama/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@
x = False


def in_container():
if os.path.exists("/run/.containerenv") or os.path.exists("/.dockerenv") or os.getenv("container"):
return True

return False


def container_manager():
if sys.platform == "darwin":
if in_container() or sys.platform == "darwin":
return ""

if sys.platform != "linux":
Expand Down

0 comments on commit e9b2742

Please sign in to comment.