Simplesat

0.9.2 · maintenance · verified Fri Apr 17

Simplesat is a Python library providing a prototype for SAT-based dependency handling, designed for resolving package and software dependencies using satisfiability algorithms. It is currently at version 0.9.2. The release cadence is irregular, with recent updates primarily focusing on Python version compatibility and bug fixes rather than rapid feature additions. The API is explicitly stated as being subject to change.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define solvables (e.g., software packages), create a repository, add constraints, and use the solver to find a compatible set of solvables.

from simplesat.constraints import EQ, GE
from simplesat.repository import Repository, Solvable
from simplesat.solver import Solver

# Define some solvables (e.g., packages and their versions)
foo_1_0 = Solvable("foo", "1.0")
foo_1_1 = Solvable("foo", "1.1")
bar_1_0 = Solvable("bar", "1.0")

# Create a repository of available solvables
repo = Repository([foo_1_0, foo_1_1, bar_1_0])

# Initialize the solver with the repository
solver = Solver(repo)

# Add constraints to the solver
solver.add_constraint(EQ("foo", "1.0")) # Require 'foo' version '1.0'
solver.add_constraint(GE("bar", "1.0")) # Require 'bar' version '1.0' or greater

# Solve the problem
try:
    solution = solver.solve()
    print(f"Solution found: {solution}")
except Exception as e:
    print(f"Failed to find a solution: {e}")

view raw JSON →