Skip to content

Enable configuration of additional paths when detecting system pythons #9506

@Stealthii

Description

@Stealthii

The high level ask here is to provide a setting configuration option to provide additional paths to search when resolving system Pythons.


On Enterprise Linux systems, it's common for additional packages to support products to be installed on non-system paths (such as /opt/). To use a public example, on CentOS 7 (and other RHEL7 derivatives) the Software Collections List (CentOS, RHEL) provides a build of Python 3.8 (RPM: rh-python38) that has an interpreter path of /opt/rh/rh-python38/root/bin/python among its supporting files.

uv can be packaged and installed as an RPM with supporting config for the environment (such as internal PyPI mirrors or python-preference = "only-system") at /etc/uv/uv.toml, however there are no provisions to provide additional paths to discover "system" Python installations. To enable interpreter auto-discovery without overriding PATH for an environment, a shim can be used (to replace uv and uvx):

#!/bin/sh
# uv shim script

# Add known internal Python versions to PATH if they exist
[ -d /opt/company/python311/bin ] && export PATH="/opt/company/python311/bin:${PATH}"
[ -d /opt/company/python39/bin ] && export PATH="/opt/company/python39/bin:${PATH}"
[ -d /opt/rh/rh-python38/root/bin ] && export PATH="/opt/rh/rh-python38/root/bin:${PATH}"

# Determine the actual binary to execute based on the name this script was called with
if [ "$(basename "$0")" = "uvx" ]; then
	exec /usr/lib/company-uv/bin/uvx "$@"
else
	exec /usr/lib/company-uv/bin/uv "$@"
fi

Rather than shim, and to avoid PATH overrides for autodiscovery, it would be nice to be able to provide additional (or override) paths when resolving available system Python installations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    configurationSettings and suchwishNot on the immediate roadmap

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions