Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Python install path detection #601

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions colcon_core/python_install_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@ def get_python_install_path(name, vars_=()):
"""
kwargs = {}
kwargs['vars'] = dict(vars_)
# Avoid deb_system because it means using --install-layout deb
# which ignores --prefix and hardcodes it to /usr
if 'deb_system' in sysconfig.get_scheme_names() or \
'osx_framework_library' in sysconfig.get_scheme_names():
kwargs['scheme'] = 'posix_prefix'
# The presence of the rpm_prefix scheme indicates that posix_prefix
# has been patched to inject `local` into the installation locations.
# The rpm_prefix scheme is a backup of what posix_prefix was before it was
# patched.
elif 'rpm_prefix' in sysconfig.get_scheme_names():
kwargs['scheme'] = 'rpm_prefix'

install_base = kwargs['vars'].get('base', sysconfig.get_config_var('base'))
if install_base != sysconfig.get_config_var('base'):
# If we are not actually installing to the default location, the
# default path scheme may be inadequate. Check if we need to override.
schemes = sysconfig.get_scheme_names()
if 'deb_system' in schemes or 'osx_framework_library' in schemes:
# Avoid deb_system because it requires using --install-layout deb
# which ignores --prefix and hardcodes it to /usr
kwargs['scheme'] = 'posix_prefix'
elif 'rpm_prefix' in schemes:
# The presence of the rpm_prefix scheme indicates that posix_prefix
# has been patched to inject `local` into the installation
# locations. The rpm_prefix scheme is a backup of what posix_prefix
# was before it was patched.
kwargs['scheme'] = 'rpm_prefix'

return Path(sysconfig.get_path(name, **kwargs))
Loading