Skip to content

Commit 5c5a6de

Browse files
committed
pip: Add the runtime install location scope to flatpak_cmd
If it is installed in multiple locations it will fail when run non interactively
1 parent 997de3a commit 5c5a6de

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pip/flatpak-pip-generator.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,21 @@ def fprint(string: str) -> None:
263263
print(separator)
264264

265265

266+
def get_flatpak_runtime_scope(runtime: str) -> str:
267+
for scope in ("--user", "--system"):
268+
try:
269+
subprocess.run(
270+
["flatpak", "info", scope, runtime],
271+
stdout=subprocess.DEVNULL,
272+
stderr=subprocess.DEVNULL,
273+
check=True,
274+
)
275+
return scope
276+
except subprocess.CalledProcessError:
277+
continue
278+
sys.exit(f"Runtime {runtime} not found for user or system")
279+
280+
266281
packages = []
267282
if opts.requirements_file:
268283
requirements_file_input = os.path.expanduser(opts.requirements_file)
@@ -358,6 +373,7 @@ def fprint(string: str) -> None:
358373

359374
flatpak_cmd = [
360375
"flatpak",
376+
get_flatpak_runtime_scope(opts.runtime),
361377
"--devel",
362378
"--share=network",
363379
"--filesystem=/tmp",

0 commit comments

Comments
 (0)