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

use sys.executable #68

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
6 changes: 1 addition & 5 deletions selinux/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ def add_location(location):

def get_system_sitepackages():
"""Get sitepackage locations from system python"""
# Do not ever use sys.executable here
# See https://github.com/pycontribs/selinux/issues/17 for details
system_python = "/usr/bin/python%s" % ".".join(
[str(item) for item in platform.python_version_tuple()[0:2]]
)
system_python = sys.executable
Copy link
Member

@ssbarnea ssbarnea Mar 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break badly as it will pick a local python when run from within a virtualenv, and it fail to discover the system python, which is likely the only one that might have the _selinux binary extension installed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote a more elaborate fix, is this one acceptable?


system_sitepackages = json.loads(
subprocess.check_output(
Expand Down