Coder Social home page Coder Social logo

cav71 / depsolver Goto Github PK

View Code? Open in Web Editor NEW

This project forked from teoliphant/depsolver

0.0 3.0 0.0 480 KB

A SAT-based dependency solver in python strongly inspired by Composer

Home Page: https://depsolver.readthedocs.org/en/latest/

License: Other

Python 98.37% Shell 1.63%

depsolver's Introduction

REMOTE .. image:: https://secure.travis-ci.org/enthought/depsolver.png?branch=master

target:https://travis-ci.org/enthought/depsolver

depsolver is a package dependency solver in python.

Examples:

# Simple scenario: nothing installed, install numpy, 2 versions available
# in the repository
from depsolver import PackageInfo, Pool, Repository, Request, Requirement, Solver

numpy_1_6_1 = PackageInfo.from_string("numpy-1.6.1")
numpy_1_7_0 = PackageInfo.from_string("numpy-1.7.0")

repo = Repository([numpy_1_6_1, numpy_1_7_0])
installed_repo = Repository()
pool = Pool([repo, installed_repo])

# only one operation here: install numpy (most recent available version
# automatically picked up)
request = Request(pool)
request.install(Requirement.from_string("numpy"))
for operation in Solver(pool, installed_repo).solve(request):
    print operation

A more complex scenario which currently fails with pip (pypa/pip#174):

#  - A requires B and C
#  - B requires D <= 1.1
#  - C requires D <= 0.9

a_1_0_0 = PackageInfo.from_string("A-1.0.0; depends (B, C)")
b_1_0_0 = PackageInfo.from_string("B-1.0.0; depends (D <= 1.1.0)")
c_1_0_0 = PackageInfo.from_string("C-1.0.0; depends (D <= 0.9.0)")
d_1_1_0 = PackageInfo.from_string("D-1.1.0")
d_0_9_0 = PackageInfo.from_string("D-0.9.0")

repo = Repository([a_1_0_0, b_1_0_0, c_1_0_0, d_1_1_0, d_0_9_0])
installed_repo = Repository()
pool = Pool([repo, installed_repo])

# despolver resolves each dependency 'globally', and does not install
# D-1.1.0 as pip currently does
request = Request(pool)
request.install(Requirement.from_string("A"))
for operation in Solver(pool, installed_repo).solve(request):
    print operation

Its main features:

  • pure python. Both >= 2.5 and >= 3.2 are supported from a single codebase.
  • only depends on the six library
  • use SAT solver to solve dependencies
  • handle dependencies, provides, conflict and replaces
  • supports multiple version formats (semver semantic versions RFC and debian formats currently supported)
  • reasonably well tested (> 90 % coverage)

It is still experimental, and subject to arbitrary changes.

The design is strongly inspired from PHP Composer packager, itself started as a port of libsolver.

Thanks to Enthought to let me open source this project !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.