Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
*setools-4.7.0 (23 Jun 2026)

* Add MCP server to provide LLMs the ability to analyze policy.
* The source distribution is now a Python sdist and can be installed
using pip.

*setools-4.6.0 (09 Sep 2025)

* Add seinfo option to see roles allowed for a specified type.
Expand Down
43 changes: 25 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To build SETools, the following development packages are required, in
addition to the development packages from the above list:

* gcc
* cython 0.29.14
* cython 0.29.14 (only if regenerating setools/policyrep.c)

To run SETools unit tests, the following packages are required, in
addition to the above dependencies:
Expand Down Expand Up @@ -71,30 +71,39 @@ series is considered stable, and has its own branch, e.g. "4.0" for all

Where `4.0` is the release series. Each release will have a tag.

### Building SETools for Local Use
### Installing SETools

To use SETools locally, without installing it onto the system,
unpack the official distribution or check out the git repository,
and perform the following at the root:
The SETools source distribution is a Python sdist and can be installed using
pip.

```bash
$ python setup.py build_ext -i
$ sudo pip install setools-4.7.0.tar.bz2
```

This will compile the C portion of SETools locally, and then
the tools can be ran from the current directory (e.g. `./seinfo`).
### Regenerating C Extension

### Installing SETools
The SETools policy representation library is implemented as a Python C
extension using Cython. The source distribution includes pre-generated C source
for this extension. To regenerate it and install the package, unpack the
source distribution, install Cython, and run the following commands:

Unpack the official distribution or check out the git repository,
```bash
$ python setup.py clean --all
$ sudo pip install .
```

### Building SETools for Local Use

To use SETools locally, without installing it onto the system,
unpack the official distribution or check out the git repository,
and perform the following at the root:

```bash
$ sudo pip install --use-pep517 .
$ python setup.py build_ext -i
```

This will put the applications in /usr/bin, data files in `/usr/share/setools`,
and libraries in `/usr/lib/pythonX.Y/site-packages/setools`.
This will compile the C portion of SETools locally, and then
the tools can be ran from the current directory (e.g. `./seinfo`).

### Building SETools with a Local Libsepol and Libselinux

Expand All @@ -107,9 +116,7 @@ be compiled.

```bash
$ export USERSPACE_SRC=/home/user/src/selinux
$ python setup.py build_ext
$ python setup.py build
$ python setup.py install
$ pip install --user setools-4.7.0.tar.bz2
```

This feature assumes that the directory structure at `$USERSPACE_SRC` is the
Expand All @@ -121,8 +128,8 @@ using `LD_LIBRARY_PATH` so that the newer versions of the libraries are used.

```bash
$ export LD_LIBRARY_PATH="/home/user/src/selinux/libsepol/src:/home/user/src/selinux/libselinux/src"
$ ./seinfo policy.31
$ ./sesearch -A sysadm_t policy.31
$ seinfo policy.31
$ sesearch -A sysadm_t policy.31
```

### Installation Options
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "setools"
version = "4.7.0.dev"
version = "4.7.0"
description="SELinux policy analysis tools."
authors = [{name = "Chris PeBenito", email="pebenito@ieee.org"}]
license = "LGPL-2.1-only AND GPL-2.0-only"
Expand Down
27 changes: 26 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,36 @@
import sys
import os
import glob
import shutil
from pathlib import Path

from setuptools import Extension, setup
from setuptools import Command, Extension, build_meta, setup
from Cython.Build import cythonize


class CleanCommand(Command):
"""Extend clean --all to delete generated build artifacts."""

build_backend = build_meta
description = "clean build artifacts"
user_options = [('all', 'a', 'remove build artifacts and generated files')]
boolean_options = ['all']
all: bool

def initialize_options(self):
self.all = False

def finalize_options(self):
pass

def run(self):
shutil.rmtree(Path('build'), ignore_errors=True)
shutil.rmtree(Path('dist'), ignore_errors=True)
shutil.rmtree(Path('setools.egg-info'), ignore_errors=True)
if self.all:
Path('setools/policyrep.c').unlink(missing_ok=True)


# Library linkage
lib_dirs: list[str] = ['.', '/usr/lib64', '/usr/lib', '/usr/local/lib']
include_dirs: list[str] = []
Expand Down Expand Up @@ -67,6 +91,7 @@

# see pyproject.toml for most package options.
setup(data_files=installed_data,
cmdclass={'clean': CleanCommand},
ext_modules=cythonize(ext_py_mods, include_path=['setools/policyrep'],
annotate=cython_annotate,
compiler_directives={"language_level": 3,
Expand Down