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

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


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.1.tar.gz (4.3 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.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

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

Hashes for uvlpy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a76474d90e1e5f1e0153830326c4cf8498b2cc870a0118b0f37f8551261b2f74
MD5 fa2f8f671ef774d728fe84f2f7727922
BLAKE2b-256 bfb31733476b9c0ddb2259c37e3198225f78d0169b6e720a98331a11ecba1292

See more details on using hashes here.

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

Hashes for uvlpy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c0143e762c9cae836d92c0c8eb76681adb06305d06c7c3aaab04a697cdfa1c5
MD5 06ee5294d9cdda2c6be40e61bc6257b3
BLAKE2b-256 cb76e60d54c70dedd0f58c08da64863f759bd57c0bf1927dcd262be92a94b080

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