Skip to content

Commit da94377

Browse files
Stop relying on ${PATH} for wineserver location
Co-authored-by: Shaw Drastin <168159404+showier-drastic@users.noreply.github.com>
1 parent c68ce39 commit da94377

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ So what is shared with the application by default then?
151151
- `${PATH}` (with known-unavailable entries removed)
152152
- `${TERM}`
153153
- `${USER}`
154+
- `${wineserver}` (lowercase, with the path to command `wineserver`)
154155

155156

156157
**sandwine** features include:

sandwine/_main.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@ def create_bwrap_argv(config):
552552

553553
# Filter ${PATH}
554554
candidate_paths = os.environ["PATH"].split(os.pathsep)
555-
candidate_paths.append("/usr/lib/wine") # for wineserver on e.g. Debian
556555
available_paths = []
557556
for candidate_path in candidate_paths:
558557
candidate_path = os.path.realpath(candidate_path)
@@ -569,6 +568,7 @@ def create_bwrap_argv(config):
569568
", dropped from ${PATH}."
570569
)
571570
env_tasks["PATH"] = os.pathsep.join(available_paths)
571+
env_tasks["wineserver"] = which_wineserver()
572572

573573
# Create environment (meaning environment variables)
574574
argv.add("--clearenv")
@@ -583,7 +583,11 @@ def create_bwrap_argv(config):
583583

584584
# Wrap with wineserver (for clean shutdown, it defaults to 3 seconds timeout)
585585
if config.with_wine:
586-
argv.add("sh", "-c", 'wineserver -p0 && "$0" "$@" ; ret=$? ; wineserver -k ; exit ${ret}')
586+
argv.add(
587+
"sh",
588+
"-c",
589+
'"${wineserver}" -p0 && "$0" "$@" ; ret=$? ; "${wineserver}" -k ; exit ${ret}',
590+
)
587591

588592
# Add winecfg
589593
if run_winecfg and config.with_wine:
@@ -598,7 +602,7 @@ def create_bwrap_argv(config):
598602
# Add Wine
599603
inner_argv = []
600604
if config.with_wine:
601-
inner_argv.append("wine")
605+
inner_argv.append(which_wine())
602606
inner_argv.append(config.argv_0)
603607
inner_argv.extend(config.argv_1_plus)
604608

@@ -633,14 +637,16 @@ def which_wine() -> str | None:
633637

634638

635639
def which_wineserver() -> str | None:
636-
extra = [
640+
candidates = [
637641
os.path.dirname(which_wine()),
638642
]
639643

640644
if (multiarch := sysconfig.get_config_var("MULTIARCH")) is not None:
641-
extra.append(f"/usr/lib/{multiarch}/wine/wineserver") # e.g. Debian sid and Ubuntu resolute
645+
candidates.append(
646+
f"/usr/lib/{multiarch}/wine/wineserver"
647+
) # e.g. Debian sid and Ubuntu resolute
642648

643-
with patch.object(sys, "path", [*sys.path, *extra]):
649+
with patch.object(sys, "path", candidates):
644650
return shutil.which("wineserver")
645651

646652

0 commit comments

Comments
 (0)