Skip to content

--executable option to override sys.executable #257

Closed
@riastradh

Description

@riastradh

python -m installer supports several options for controlling the paths in the output when they don't match the Python system that is running:

  • --destdir puts everything relative to a system root
  • --prefix overrides sys.prefix for the installation prefix within that system root where files are installed

But there appears to be no way to control the path that is stored in #! lines of entry points that installer creates. In contrast, for example, historically with setuptools, python setup.py install would respect [build] executable = '/path/to/python' in setup.cfg; this functionality doesn't appear to be available through installer. It would be nice if python -m installer additionally supported:

  • --executable overrides sys.executable for the Python executable path within that system root used in #! lines generated for entry points

This is important for cross-compilation into a fixed file system layout in the destdir that is independent of where Python happened to be installed on a development machine. For example, if I set up a virtualenv in /home/riastradh/venv for a cross-compilation toolchain, sys.executable will be /home/riastradh/venv/bin/python, but the scripts installed in the destdir need to start with #!/opt/pkg/bin/python -- just like files installed in the destdir need to go under /opt/pkg/lib/python3.12/site-packages according to --prefix, rather than under /home/riastradh/venv/lib/python3.12/site-packages according to sys.prefix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions