UV abused for your pleasure
Project description
uvlpy
A light package for constraint solving by levereging uv's dependency resolver
Example
Example of some basic code to show the features would be:
from uvlpy.uvlpy import System
sys = System()
a, b, c = sys.make_vars([0, 1], [2, 3, 4], list(range(0,9)))
a.val_constr(1, b == 2)
c.constr(b > 1)
sys.constr(a > 0, c < 9, b.to_constr())
print(sys.execute(a, b, c))
Where we:
- Create 3 variables with given possible values
- Constrain
a = 1to requireb = 2 - Constrain all values of
cto requireb > 1 - Constrain the result to require a positive
a,c < 9, and to includeb - After execution the output is e.g. [1, 2, 8], a and b can only be 1 and 2, but c can be any of its possible values
You can see the sudoku_example.py for a sudoku solver,
which uses lists directly instead of destructuring them into variables like here.
Install
You can build it locally with uv build and use the wheel as you see fit.
Note that uv being installed and visible on PATH is required for this library to function.
Why
Can be done.
uvlpy uses uv's solver, which should be reliable. The performance is not great, but sufficient.
However, note that the library creates a lot temporary files and packages to utilize uv, and as such, should be used with care and within reason.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uvlpy-0.1.1.tar.gz.
File metadata
- Download URL: uvlpy-0.1.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a76474d90e1e5f1e0153830326c4cf8498b2cc870a0118b0f37f8551261b2f74
|
|
| MD5 |
fa2f8f671ef774d728fe84f2f7727922
|
|
| BLAKE2b-256 |
bfb31733476b9c0ddb2259c37e3198225f78d0169b6e720a98331a11ecba1292
|
File details
Details for the file uvlpy-0.1.1-py3-none-any.whl.
File metadata
- Download URL: uvlpy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c0143e762c9cae836d92c0c8eb76681adb06305d06c7c3aaab04a697cdfa1c5
|
|
| MD5 |
06ee5294d9cdda2c6be40e61bc6257b3
|
|
| BLAKE2b-256 |
cb76e60d54c70dedd0f58c08da64863f759bd57c0bf1927dcd262be92a94b080
|