コード例 #1
0
    def test_provides(self):

        self.assertEqual(
            Provision('foo'),
            {'foo': None}
        )

        self.assertEqual(
            Provision('foo,bar'),
            {'foo': None, 'bar': None}
        )

        self.assertEqual(
            Provision('foo=1'),
            {'foo': Version('1')}
        )

        self.assertEqual(
            Provision('foo=bar'),
            {'foo': Version('bar')}
        )

        self.assertEqual(
            Provision('foo=1,bar=2'),
            {'foo': Version('1'), 'bar': Version('2')}
        )

        # Git things go weird
        p = Provision()
        p['version'] = '01234567'
        self.assertEqual(str(p), 'version=01234567')
        self.assertEqual(str(p['version']), '01234567')
コード例 #2
0
ファイル: test_semver.py プロジェクト: immersionroom/vee
    def test_release(self):

        v = Version('1.0.0')
        self.assertEqual(v.release, (1, 0, 0))
        self.assertEqual(str(v), '1.0.0')

        v = Version('0.5')
        self.assertEqual(v.release, (0, 5))
        self.assertEqual(str(v), '0.5')
コード例 #3
0
ファイル: test_semver.py プロジェクト: immersionroom/vee
    def test_pep_epoch(self):

        v = Version('1.0.0')
        self.assertEqual(v.epoch, 0)
        self.assertEqual(str(v), '1.0.0')

        v = Version('123!1.0.0')
        self.assertEqual(v.epoch, 123)
        self.assertEqual(str(v), '123!1.0.0')
コード例 #4
0
ファイル: test_semver.py プロジェクト: immersionroom/vee
    def test_build_metadata(self):

        v = Version('0.5-alpha+abcdef')
        self.assertEqual(v.release, (0, 5))
        self.assertEqual(v.build_metadata, ('abcdef', ))
        self.assertEqual(str(v), '0.5-alpha+abcdef')

        v = Version('0.5-alpha+abcdef.20150325')
        self.assertEqual(v.release, (0, 5))
        self.assertEqual(v.build_metadata, ('abcdef', 20150325))
        self.assertEqual(str(v), '0.5-alpha+abcdef.20150325')
コード例 #5
0
ファイル: test_semver.py プロジェクト: immersionroom/vee
    def test_sem_pre_release(self):

        v = Version('0.5-alpha')
        self.assertEqual(v.release, (0, 5))
        self.assertEqual(v.sem_pre_release, ('alpha', ))
        self.assertEqual(str(v), '0.5-alpha')

        v = Version('0.5-alpha.1')
        self.assertEqual(v.release, (0, 5))
        self.assertEqual(v.sem_pre_release, ('alpha', 1))
        self.assertEqual(str(v), '0.5-alpha.1')
コード例 #6
0
ファイル: test_semver.py プロジェクト: immersionroom/vee
    def test_git_rev(self):

        v = Version('abcdef')
        self.assertEqual(v.release, None)
        self.assertEqual(v.build_metadata, ('abcdef', ))
        self.assertEqual(v.git_rev, 'abcdef')
        self.assertEqual(str(v), 'abcdef')
コード例 #7
0
ファイル: test_semver.py プロジェクト: immersionroom/vee
    def test_pep_pre_release(self):

        v = Version('0.5b1')
        self.assertEqual(v.release, (0, 5))
        self.assertEqual(v.pep_pre_release, ('b', 1))
        self.assertEqual(str(v), '0.5b1')

        v = Version('0.5beta1')
        self.assertEqual(v.release, (0, 5))
        self.assertEqual(v.pep_pre_release, ('beta', 1))
        self.assertEqual(str(v), '0.5beta1')

        v = Version('0.5rc6')
        self.assertEqual(v.release, (0, 5))
        self.assertEqual(v.pep_pre_release, ('rc', 6))
        self.assertEqual(str(v), '0.5rc6')
コード例 #8
0
ファイル: test_semver.py プロジェクト: immersionroom/vee
    def test_comparisons(self):

        a = Version('1.0.0')
        b = Version('1.0.0')

        self.assertTrue(a == b)
        self.assertFalse(a != b)

        a = Version('1.0')
        b = Version('2.0')

        self.assertTrue(a != b)
        self.assertTrue(a <= b)
        self.assertTrue(a < b)
        self.assertFalse(a == b)
        self.assertFalse(a >= b)
        self.assertFalse(a > b)

        a = Version('1.0.0a')
        b = Version('1.0.0')

        self.assertTrue(a != b)
        self.assertTrue(a <= b)
        self.assertTrue(a < b)
        self.assertFalse(a == b)
        self.assertFalse(a >= b)
        self.assertFalse(a > b)
コード例 #9
0
ファイル: test_semver.py プロジェクト: immersionroom/vee
    def test_gitrev_expr(self):

        commits = ('deadbeef', 'deadbeef01234', 'deadbe')
        for a in commits:
            expr = VersionExpr(a)
            for b in commits:
                self.assertTrue(expr.eval(b))

        expr = VersionExpr('deadbeef1')
        self.assertFalse(expr.eval('deadb'))
        self.assertFalse(expr.eval('deadbeef2'))

        self.assertTrue(VersionExpr('986b416').eval('986b4161'))

        self.assertTrue(VersionExpr('986b416').eval(Version('986b4161')))
コード例 #10
0
    def fetch(self):

        pkg = self.package
        meta = self._meta()

        all_releases = [(Version(v), rs)
                        for v, rs in meta['releases'].iteritems()]
        all_releases.sort(reverse=True)

        if pkg.revision:
            expr = VersionExpr(pkg.revision)
            matching_releases = [(v, rs) for v, rs in all_releases
                                 if expr.eval(v)]
            log.debug(
                '%s matched %s' %
                (expr, ','.join(str(v)
                                for v, _ in matching_releases) or 'none'))
        else:
            matching_releases = all_releases

        for version, releases in matching_releases:
            release = next(
                (r for r in releases if r['packagetype'] == 'sdist'), None)
            if release:
                break
        else:
            raise ValueError('no sdist %s %s on the PyPI;' %
                             (self.name, expr if pkg.revision else '(any)'))

        pkg.revision = str(version)

        if release.get('md5_digest'):
            pkg.checksum = 'md5:%s' % release['md5_digest']

        pkg.package_name = os.path.join(self.name,
                                        os.path.basename(release['url']))
        pkg._assert_paths(package=True)

        if os.path.exists(pkg.package_path):
            log.info(style_note('Already downloaded', release['url']))
            return
        log.info(style_note('Downloading', release['url']))
        download(release['url'], pkg.package_path)
コード例 #11
0
ファイル: test_semver.py プロジェクト: immersionroom/vee
    def test_unknown(self):

        v = Version('0.5@unknown')
        self.assertEqual(v.release, (0, 5))
        self.assertEqual(v.unknown, ('@unknown', ))
コード例 #12
0
ファイル: test_semver.py プロジェクト: immersionroom/vee
    def test_pep_post_release(self):

        v = Version('1.2.3.post5')
        self.assertEqual(v.release, (1, 2, 3))
        self.assertEqual(v.post_release, ('post', 5))
        self.assertEqual(str(v), '1.2.3.post5')
コード例 #13
0
ファイル: test_semver.py プロジェクト: immersionroom/vee
    def test_ordering(self):

        vs = [
            Version(x) for x in '''

            2.1.1
            1.0.0
            2.0.0
            2.1.0
            0.5.9
            0.5
            1
            2

            1.0.0a
            1.0.0a1
            1.0.0b
            1.0.0rc4
            1.0.0rc1
            1.0.0.dev1
            1.0.0.dev2
            1.0.0.post1

            1.0.0-alpha
            1.0.0-alpha.1
            1.0.0-alpha.beta
            1.0.0-beta
            1.0.0-beta.2
            1.0.0-beta.11
            1.0.0-rc.1

            1.0.0@unknown

        '''.strip().split()
        ]
        vs = [str(v) for v in sorted(vs)]

        self.assertEqual(
            vs, '''
            0.5
            0.5.9
            1
            1.0.0a0
            1.0.0a1
            1.0.0b0
            1.0.0rc1
            1.0.0rc4
            1.0.0.dev1
            1.0.0.dev2
            1.0.0-alpha
            1.0.0-alpha.1
            1.0.0-alpha.beta
            1.0.0-beta
            1.0.0-beta.2
            1.0.0-beta.11
            1.0.0-rc.1
            1.0.0@unknown
            1.0.0
            1.0.0.post1
            2
            2.0.0
            2.1.0
            2.1.1
        '''.strip().split(), '\n'.join(vs))
コード例 #14
0
ファイル: pypi.py プロジェクト: immersionroom/vee
    def fetch(self, pkg):

        meta = self._get_meta(pkg)

        all_releases = [(Version(v), rs) for v, rs in meta['releases'].items()]
        all_releases.sort(reverse=True)

        if not all_releases:
            raise ValueError('no releases of {} (any version) on the PyPI'.format(self.name))

        if pkg.version:
            version_expr = VersionExpr(pkg.version)
            matching_releases = [(v, rs) for v, rs in all_releases if version_expr.eval(v)]
            if not matching_releases:
                for v, rs in all_releases:
                    print(v)
                raise ValueError('no releases of {} {} on the PyPI'.format(self.name, pkg.version))

        else:
            matching_releases = all_releases

        supported_tags = get_supported_tags()

        usable_releases = []
        for version, releases in matching_releases:

            for release in releases:

                if release['packagetype'] == 'sdist':
                    usable_releases.append((version, 0, release))
                    continue

                elif release['packagetype'] == 'bdist_wheel':
                    m = re.match(r'^(.+)-([^-]+)-([^-]+)-([^-]+)-([^-]+)\.whl$', release['filename'])
                    if not m:
                        log.warning("Could not parse wheel filename: {}".format(release['filename']))
                    
                    name, version_tag, python_tag, abi_tag, platform_tags = m.groups()

                    # Platform tags can have multiple seperated by dots.
                    for platform_tag in platform_tags.split('.'):
                        tags = (python_tag, abi_tag, platform_tag)
                        if tags in supported_tags:
                            break
                    else:
                        continue

                    usable_releases.append((version, 1, release))

        if not usable_releases:
            raise ValueError('no usable release of %s %s on the PyPI;' % (self.name, expr if pkg.version else '(any version)'))
        usable_releases.sort(key=lambda x: x[:2])

        version, _, release = usable_releases[-1]

        pkg.version = str(version)
        
        if release.get('md5_digest'):
            pkg.checksum = 'md5:%s' % release['md5_digest']

        pkg.package_name = os.path.join(self.name, os.path.basename(release['url']))
        pkg._assert_paths(package=True)

        if os.path.exists(pkg.package_path):
            log.info(style_note('Already downloaded', release['url']))
            return
        
        log.info(style_note('Downloading', release['url']))
        download(release['url'], pkg.package_path)
コード例 #15
0
ファイル: test_semver.py プロジェクト: immersionroom/vee
    def test_pep_dev_release(self):

        v = Version('0.5.dev2')
        self.assertEqual(v.release, (0, 5))
        self.assertEqual(v.dev_release, ('dev', 2))
        self.assertEqual(str(v), '0.5.dev2')
コード例 #16
0
    def resolve_existing(self, env=None, weak=False):
        """Check against the database to see if this was already installed."""

        if self.id is not None:
            raise ValueError('requirement already in database')

        cur = self.home.db.cursor()

        # Dependencies are deferred.
        deferred = self.url.startswith('deferred:')
        if deferred:
            deferred_id = int(self.url.split(':')[1])
            cur.execute('SELECT * from packages WHERE id = ?', [deferred_id])
        
        else:

            clauses = ['install_path IS NOT NULL']
            values = []
            if not weak and self.url:
                clauses.append('url = ?')
                values.append(self.url)
            for name in ('name', 'etag', 'install_name'):
                if getattr(self, name):
                    clauses.append('%s = ?' % name)
                    values.append(getattr(self, name))
            clause = ' AND '.join(clauses)

            # log.debug('SELECT FROM packages WHERE %s' % ' AND '.join('%s = %r' % (c.replace(' = ?', ''), v) for c, v in zip(clauses[1:], values)), verbosity=2)

            if env:
                values.append(env.id_or_persist())
                cur.execute('''
                    SELECT packages.*, links.id as link_id FROM packages
                    LEFT OUTER JOIN links ON packages.id = links.package_id
                    WHERE %s AND links.environment_id = ?
                    ORDER BY links.created_at DESC, packages.created_at DESC
                ''' % clause, values)
            else:
                cur.execute('''
                    SELECT * FROM packages
                    WHERE %s
                    ORDER BY packages.created_at DESC
                ''' % clause, values)

        rev_expr = VersionExpr(self.revision) if self.revision else None
        for row in cur:
            if rev_expr and row['revision'] and not rev_expr.eval(Version(row['revision'])):
                log.debug('Found %s (%d) whose revision %s does not satisfy %s' % (
                    self.name or row['name'],
                    row['id'],
                    row['revision'],
                    rev_expr,
                ), verbosity=2)
                continue
            if not os.path.exists(row['install_path']):
                log.warning('Found %s (%d) does not exist at %s' % (self.name or row['name'], row['id'], row['install_path']))
                continue
            break
        else:

            if deferred:
                raise ValueError('deferred package %d no longer exists; consider `vee gc`' % deferred_id)
            return

        log.debug('Found %s (%d%s%s) at %s' % (
            self.name or row['name'],
            row['id'],
            ' weakly' if weak else '',
            ' in env %d' % env.id if env else '',
            row['install_path'],
        ))

        self.restore_from_row(row, ignore=set(('abstract_requirements', 'concrete_requirement')))
        self.link_id = row.get('link_id')

        if deferred:
            self._init_pipeline()

        self._load_dependencies(cur)

        return True
コード例 #17
0
ファイル: provision.py プロジェクト: immersionroom/vee
 def __setitem__(self, key, value):
     self._data[key] = None if value is None else Version.coerce(value)