selinux
shim selinux module
What it is and what it does
This package is a workaround for a specific virtualenv limitation: selinux normally cannot be imported from inside isolated Python environments even when the system library is installed. The selinux shim bridges that gap by providing a pure-Python wrapper that allows code running in a virtualenv to import selinux.
The shim requires that libselinux Python bindings be present on the host system—it does not replace them, only makes them accessible from within a virtualenv. It has been tested to work both inside, outside virtualenvs without interfering with the original library. The package depends only on distro for runtime operation, supports Python 3.9 or later.
Use it for:
- Importing selinux in isolated Python environments for system administration tasks
- Testing or developing tools that depend on selinux in a containerized or virtualenv-based CI/CD pipeline
- Running code that requires selinux from within a virtualenv without system-level workarounds
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a pure-Python shim for the selinux module that works inside virtualenvs, allowing tools to import selinux without requiring system-level virtualenv configuration.
Yes, if you need to use selinux from inside a virtualenv. The package solves a specific problem with minimal dependencies, no security issues, active maintenance status. The gap since the latest release is a minor concern, but the package remains actively maintained, marked Production/Stable. Install only if you encounter the virtualenv selinux import problem.
Install
selinux on PyPI
pip
pip install selinuxuv
uv add selinuxpoetry
poetry add selinuxInstalling selinux
Before you install
Low install friction with a single runtime dependency (distro). The package is actively maintained with recent commits, though the latest release was over three years ago; it remains marked as Production/Stable with support for current Python versions.
License in practice
MIT license permits unrestricted use, modification, in both open-source, proprietary projects with minimal obligations.
Quickstart
pip install selinux
import selinux
libselinux Python bindings must be installed on the system; the shim bridges access to them from within a virtualenv.
Verify before relying
- Whether the shim works with all selinux functions or only a subset of the API
- Whether it works with selinux versions other than those tested at release time
- Compatibility with Ansible modules specifically
Package facts
| License | MIT license (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — distro |
| Maintenance | actively maintained — 1,329 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,761,246/month — #3,583 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: selinux-0.3.0-py2.py3-none-any.whl
Keywords: selinux, virtualenv
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
rpmProvides access to system RPM Python bindings…
permissive · top 15,000 on PyPI
virtualenv-cloneClones an existing Python virtualenv to a new…
permissive · top 5,000 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
ansible-dev-environmentCreates isolated virtual environments for…
copyleft · top 15,000 on PyPI
nodeenvnodeenv creates isolated Node.js environments…
permissive · top 1,000 on PyPI
ansible-compatProvides compatibility utilities for working…
permissive · top 5,000 on PyPI
notebook-shimProvides a compatibility layer that allows…
permissive · top 1,000 on PyPI
isolateIsolate manages isolated Python environments…
unclear · top 15,000 on PyPI
modal-clientThis package is a deprecated compatibility shim…
unclear · top 15,000 on PyPI
logfire-apilogfire-api provides a no-op shim of the…
permissive · top 1,000 on PyPI