Skip to content

Desktop: find PYTHONHOME beside a native-image executable, and stage it there #246

Closed

Description

@b-re-w

A GraalVM native image has no java.home, no Compose resources directory and no launcher to set PYTHONHOME, so a packaged native image finds no CPython prefix unless its environment names one (found in #242; needed for #191's first milestone). The sample's native demo works only because its Gradle run task sets PYTHONHOME.

Change (SPEC L-9):

  • Run time. PackagedPythonHome.resolve adds a fourth source after the existing three. Inside a native image (org.graalvm.nativeimage.imagecode is runtime), it uses <directory of the executable>/python-multiplatform-home when that directory exists. On a JVM the executable is java, so the rule does not apply there. The rest is unchanged: the environment still wins, and the prefix goes through L-3's check, Py_SetPythonHome and the libpython lookup like the other packaged sources.
  • Build. The Gradle plugin registers stageNativeImagePythonHome, a Sync. It copies the same pruned prefix as Compose packaging (stdlib and shared library; no headers, bin/, Tcl/Tk or __pycache__) into <pythonBindings.nativeImageDirectory>/python-multiplatform-home, and does nothing unless that directory is set.

Completion: PM/desktopTest/.../PackagedPythonHomeTest pins the new resolution step (red first); GP/PackagedPythonHomeTest pins the task's wiring and its no-op default; the existing tests are unchanged.

Activity

  1. added a commit that references this issue on Oct 17, 2026
  2. b-re-w commented on Oct 17, 2026

    @b-re-w
    MemberAuthor

    Landed in develop via #247

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions