Пример #1
0
class TestChain2(unittest.TestCase):

    repos = {}
    c = Chain(verbose=0)
    for name in 'open', 'runner', 'epd':
        repo = 'file://%s/%s/' % (abspath(dirname(__file__)), name)
        c.add_repo(repo, 'index-7.1.txt')
        repos[name] = repo

    def test_flat_recur1(self):
        d1 = self.c.install_sequence(Req('openepd'), mode='flat')
        d2 = self.c.install_sequence(Req('openepd'), mode='recur')
        self.assertEqual(d1, d2)
        d3 = self.c.install_sequence(Req('foo'), mode='recur')
        self.assertEqual(d2[:-1], d3[:-1])

    def test_flat_recur2(self):
        for rs in 'epd 7.0', 'epd 7.0-1', 'epd 7.0-2':
            d1 = self.c.install_sequence(Req(rs), mode='flat')
            d2 = self.c.install_sequence(Req(rs), mode='recur')
            self.assertEqual(d1, d2)

    def test_multiple_reqs(self):
        lst = self.c.install_sequence(Req('ets'))
        self.assert_(self.repos['epd'] + 'numpy-1.5.1-2.egg' in lst)
Пример #2
0
class TestChain0(unittest.TestCase):

    c = Chain(verbose=0)
    for fn in ['index-add.txt', 'index-5.1.txt', 'index-5.0.txt']:
        c.add_repo('file://%s/' % abspath(dirname(__file__)), fn)

    def test_25(self):
        requirement.PY_VER = '2.5'
        self.assertEqual(eggs_rs(self.c, 'SciPy 0.8.0.dev5698'), [
            'freetype-2.3.7-1.egg', 'libjpeg-7.0-1.egg', 'numpy-1.3.0-1.egg',
            'PIL-1.1.6-4.egg', 'scipy-0.8.0.dev5698-1.egg'
        ])

        self.assertEqual(eggs_rs(self.c, 'SciPy'),
                         ['numpy-1.3.0-1.egg', 'scipy-0.8.0-1.egg'])

        self.assertEqual(eggs_rs(self.c, 'epdcore'), [
            'AppInst-2.0.4-1.egg', 'numpy-1.3.0-1.egg', 'scipy-0.8.0-1.egg',
            'EPDCore-1.2.5-1.egg'
        ])

    def test_26(self):
        requirement.PY_VER = '2.6'

        self.assertEqual(eggs_rs(self.c, 'SciPy'),
                         ['numpy-1.3.0-2.egg', 'scipy-0.8.0-2.egg'])

        self.assertEqual(
            eggs_rs(self.c, 'epdcore'),
            ['numpy-1.3.0-2.egg', 'scipy-0.8.0-2.egg', 'EPDCore-2.0.0-1.egg'])
Пример #3
0
def main():
    welcome()
    info = get_info()
    curr_ver = dist_naming.split_eggname(info['egg_name'])[1]
    print "Currently installed version:  %s" % curr_ver
    print "               installed on:  %s" % info['mtime']
    print

    conf = config.read()
    c = Chain(conf['IndexedRepos'])
    versions = c.list_versions(name)
    if len(versions) == 0:
        print "Error: no versions of %r available" % name
        quit()

    while True:
        print "Available versions:"
        print ', '.join(versions)
        print """
You have the following options:
  - press return to update to the latest available version %s
  - enter the version to update (or downgrade) to, e.g. %r
  - enter 'q' to quit (without changing anything)
""" % (versions[-1], versions[0])
        inp = raw_input('> ').strip()
        if inp.lower() in ('q', 'quit'):
            sys.exit()

        update_to = inp or versions[-1]
        if update_to in versions:
            print "Updating to: %s" % update_to
            check_call([enpkg_bin, '--sys-config', name, update_to])
            quit()
        print "You have entered %r, which is not an available version" % inp
Пример #4
0
    def setUp(self):
        c = Chain(verbose=0)
        for fn in ['index-add.txt', 'index-5.1.txt', 'index-5.0.txt']:
            repo = "{0}/".format(path_to_uri(HERE_DIR))
            c.add_repo(repo, fn)

        self.c = c
Пример #5
0
 def setUp(self):
     repos = {}
     c = Chain(verbose=0)
     for name in 'open', 'runner', 'epd':
         repo = "{0}/".format(path_to_uri(posixpath.join(HERE_DIR, name)))
         c.add_repo(repo, 'index-7.1.txt')
         repos[name] = repo
     self.c = c
     self.repos = repos
Пример #6
0
 def setUp(self):
     repos = {None: None}
     c = Chain(verbose=0)
     for name in 'epd', 'gpl':
         # XXX: relying on having a '/' is horrible, but that assumption is made
         # in enough places through the code that we don't want to change it.
         repo = "{0}/".format(path_to_uri(posixpath.join(HERE_DIR, name)))
         c.add_repo(repo, 'index-7.1.txt')
         repos[name] = repo
     self.c = c
     self.repos = repos
Пример #7
0
def get_status():
    # the result is a dict mapping cname to ...
    res = {}
    for cname in egginst.get_installed_cnames(sys.prefix):
        d = defaultdict(str)
        info = get_installed_info(sys.prefix, cname)
        if info is None:
            continue
        d.update(info)
        res[cname] = d

    c = Chain(config.get('IndexedRepos'))

    for cname in c.groups.iterkeys():
        dist = c.get_dist(Req(cname))
        if dist is None:
            continue
        repo, fn = dist_naming.split_dist(dist)
        n, v, b = dist_naming.split_eggname(fn)
        if cname not in res:
            d = defaultdict(str)
            d['name'] = n
            res[cname] = d
        res[cname]['a-egg'] = fn
        res[cname]['a-ver'] = '%s-%d' % (v, b)

    def vb_egg(fn):
        try:
            n, v, b = dist_naming.split_eggname(fn)
            return comparable_version(v), b
        except:
            return None

    for d in res.itervalues():
        if d['egg_name']:  # installed
            if d['a-egg']:
                if vb_egg(d['egg_name']) >= vb_egg(d['a-egg']):
                    d['status'] = 'up-to-date'
                else:
                    d['status'] = 'updateable'
            else:
                d['status'] = 'installed'
        else:  # not installed
            if d['a-egg']:
                d['status'] = 'installable'
    return res
Пример #8
0
class TestChain1(unittest.TestCase):

    repos = {None: None}
    c = Chain(verbose=0)
    for name in 'epd', 'gpl':
        repo = 'file://%s/%s/' % (abspath(dirname(__file__)), name)
        c.add_repo(repo, 'index-7.1.txt')
        repos[name] = repo

    def test_get_repo(self):
        for req_string, repo_name in [
            ('MySQL_python', 'gpl'),
            ('bitarray', 'epd'),
            ('foobar', None),
        ]:
            self.assertEqual(self.c.get_repo(Req(req_string)),
                             self.repos[repo_name])

    def test_get_dist(self):
        requirement.PY_VER = '2.7'
        for req_string, dist in [
            ('MySQL_python', self.repos['gpl'] + 'MySQL_python-1.2.3-2.egg'),
            ('numpy', self.repos['epd'] + 'numpy-1.6.0-3.egg'),
            ('swig', self.repos['epd'] + 'swig-1.3.40-2.egg'),
            ('swig 1.3.36', self.repos['epd'] + 'swig-1.3.36-3.egg'),
            ('swig 1.3.40-1', self.repos['epd'] + 'swig-1.3.40-1.egg'),
            ('swig 1.3.40-2', self.repos['epd'] + 'swig-1.3.40-2.egg'),
            ('foobar', None),
        ]:
            self.assertEqual(self.c.get_dist(Req(req_string)), dist)

    def test_reqs_dist(self):
        dist = self.repos['epd'] + 'FiPy-2.1-1.egg'
        self.assertEqual(
            self.c.reqs_dist(dist),
            set([
                Req('distribute'),
                Req('scipy'),
                Req('numpy'),
                Req('pysparse 1.2.dev203')
            ]))

    def test_root(self):
        self.assertEqual(
            self.c.install_sequence(Req('numpy 1.5.1'), mode='root'),
            [self.repos['epd'] + 'numpy-1.5.1-2.egg'])

        self.assertEqual(
            self.c.install_sequence(Req('numpy 1.5.1-1'), mode='root'),
            [self.repos['epd'] + 'numpy-1.5.1-1.egg'])

    def test_order1(self):
        self.assertEqual(self.c.install_sequence(Req('numpy')), [
            self.repos['epd'] + egg
            for egg in 'MKL-10.3-1.egg', 'numpy-1.6.0-3.egg'
        ])

    def test_order2(self):
        self.assertEqual(self.c.install_sequence(Req('scipy')), [
            self.repos['epd'] + egg for egg in 'MKL-10.3-1.egg',
            'numpy-1.5.1-2.egg', 'scipy-0.9.0-1.egg'
        ])