Skip to content

extend PyConfig to enable program name to be set via Py_SetProgramName #515

@mike-hunhoff

Description

@mike-hunhoff

Is your feature request related to a problem? Please describe.
I'm attempting to create an environment for Jep that mirrors that of the Python interpreter from which it was installed. This includes sys.prefix, sys.exec_prefix, sys.executable, sys._base_executable, etc. My understanding is that Python derives these and others from the path that is set via Py_SetProgramName. AFAIK Jep does not support configuring Python via Py_SetProgramName. Unfortunately I cannot rely on environment variables to determine how sys.prefix, etc. are set e.g. when running in a virtual environment.

Describe the solution you'd like
I'd like to see PyConfig extended to include protected String programName set via public PyConfig setProgramName(String programName) { ... and passed to Py_SetProgramName before Py_Initialize. This should prompt the embedded Python interpreter to properly set sys.prefix, etc.

Describe alternatives you've considered
I've considered setting sys.prefix, etc. manually from Python after Python has been initialized but it's nuanced and difficult to get the ordering correct. I'm open to suggestions here as well.

Additional context
NA

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