Skip to main content

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 = 1 to require b = 2
  • Constrain all values of c to require b > 1
  • Constrain the result to require a positive a, c < 9, and to include b
  • 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 (uv tends to prefer higher)

You can see the sudoku_example.py for a sudoku solver, which uses lists directly instead of destructuring them into variables like here.

Install

Simply pip install uvlpy, or with uv, uv pip install uvlpy.

Otherwise, 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uvlpy-0.1.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uvlpy-0.1.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file uvlpy-0.1.2.tar.gz.

File metadata

  • Download URL: uvlpy-0.1.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.2

File hashes

Hashes for uvlpy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 83efd8781d0e6e52bb8ed3a69215035365aac443a97e44a15d6d556f0e24ce97
MD5 6682999dd47b5561507dcff1a72e571f
BLAKE2b-256 96cb3325dfacd316e1821745a9ee2d7750bd1878620de468e06ce745c34db5f9

See more details on using hashes here.

File details

Details for the file uvlpy-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: uvlpy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.2

File hashes

Hashes for uvlpy-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1fb877e03a34d8539c1832fec7aa13e0265c5eec16f52f028a7e199ddec55c6b
MD5 d3122e28efd4513f66f761ac64f10347
BLAKE2b-256 0e6136d1c379bb9aeb32e05b92ab0eb74fc5126ebbc479472779204f869a2982

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page