Exemplo n.º 1
0
Arquivo: freeze.py Projeto: zsmjwk/pip
 def from_dist(cls, dist, dependency_links):
     location = os.path.normcase(os.path.abspath(dist.location))
     comments = []
     from pip.vcs import vcs, get_src_requirement
     if dist_is_editable(dist) and vcs.get_backend_name(location):
         editable = True
         try:
             req = get_src_requirement(dist, location)
         except InstallationError as exc:
             logger.warning(
                 "Error when trying to get requirement for VCS system %s, "
                 "falling back to uneditable format", exc)
             req = None
         if req is None:
             logger.warning('Could not determine repository location of %s',
                            location)
             comments.append(
                 '## !! Could not determine repository location')
             req = dist.as_requirement()
             editable = False
     else:
         editable = False
         req = dist.as_requirement()
         specs = req.specs
         assert len(specs) == 1 and specs[0][0] in ["==", "==="], \
             'Expected 1 spec with == or ===; specs = %r; dist = %r' % \
             (specs, dist)
         version = specs[0][1]
         ver_match = cls._rev_re.search(version)
         date_match = cls._date_re.search(version)
         if ver_match or date_match:
             svn_backend = vcs.get_backend('svn')
             if svn_backend:
                 svn_location = svn_backend().get_location(
                     dist,
                     dependency_links,
                 )
             if not svn_location:
                 logger.warning('Warning: cannot find svn location for %s',
                                req)
                 comments.append(
                     '## FIXME: could not find svn URL in dependency_links '
                     'for this package:')
             else:
                 warnings.warn(
                     "SVN editable detection based on dependency links "
                     "will be dropped in the future.",
                     RemovedInPip11Warning,
                 )
                 comments.append(
                     '# Installing as editable to satisfy requirement %s:' %
                     req)
                 if ver_match:
                     rev = ver_match.group(1)
                 else:
                     rev = '{%s}' % date_match.group(1)
                 editable = True
                 req = '%s@%s#egg=%s' % (svn_location, rev,
                                         cls.egg_name(dist))
     return cls(dist.project_name, req, editable, comments)
Exemplo n.º 2
0
    def from_dist(cls, dist, find_tags=False):
        location = os.path.normcase(os.path.abspath(dist.location))
        comments = []
        from pip.vcs import vcs, get_src_requirement
        if vcs.get_backend_name(location):
            editable = True
            try:
                req = get_src_requirement(dist, location, find_tags)
            except InstallationError as exc:
                logger.warn(
                    "Error when trying to get requirement for VCS system %s, "
                    "falling back to uneditable format" % exc)
                req = None
            if req is None:
                logger.warn('Could not determine repository location of %s' %
                            location)
                comments.append(
                    '## !! Could not determine repository location')
                req = dist.as_requirement()
                editable = False
        else:
            editable = False
            req = dist.as_requirement()
            specs = req.specs
            assert len(specs) == 1 and specs[0][0] == '=='

        return cls(dist.project_name, req, editable, comments)
Exemplo n.º 3
0
 def from_dist(cls, dist, dependency_links, find_tags=False):
     location = os.path.normcase(os.path.abspath(dist.location))
     comments = []
     from pip.vcs import vcs, get_src_requirement
     if vcs.get_backend_name(location):
         editable = True
         try:
             req = get_src_requirement(dist, location, find_tags)
         except InstallationError as exc:
             logger.warning(
                 "Error when trying to get requirement for VCS system %s, "
                 "falling back to uneditable format", exc
             )
             req = None
         if req is None:
             logger.warning(
                 'Could not determine repository location of %s', location
             )
             comments.append(
                 '## !! Could not determine repository location'
             )
             req = dist.as_requirement()
             editable = False
     else:
         editable = False
         req = dist.as_requirement()
         specs = req.specs
    def from_dist(cls, dist, find_tags=False):
        location = os.path.normcase(os.path.abspath(dist.location))
        comments = []
        from pip.vcs import vcs, get_src_requirement
        if vcs.get_backend_name(location):
            editable = True
            try:
                req = get_src_requirement(dist, location, find_tags)
            except InstallationError as exc:
                logger.warn(
                    "Error when trying to get requirement for VCS system %s, "
                    "falling back to uneditable format" % exc
                )
                req = None
            if req is None:
                logger.warn(
                    'Could not determine repository location of %s' % location
                )
                comments.append(
                    '## !! Could not determine repository location'
                )
                req = dist.as_requirement()
                editable = False
        else:
            editable = False
            req = dist.as_requirement()
            specs = req.specs
            assert len(specs) == 1 and specs[0][0] == '=='

        return cls(dist.project_name, req, editable, comments)
Exemplo n.º 5
0
 def from_dist(cls, dist, dependency_links, find_tags=False):
     location = os.path.normcase(os.path.abspath(dist.location))
     comments = []
     from pip.vcs import vcs, get_src_requirement
     if vcs.get_backend_name(location):
         editable = True
         try:
             req = get_src_requirement(dist, location, find_tags)
         except InstallationError:
             ex = sys.exc_info()[1]
             logger.warn(
                 "Error when trying to get requirement for VCS system %s, falling back to uneditable format"
                 % ex)
             req = None
         if req is None:
             logger.warn('Could not determine repository location of %s' %
                         location)
             comments.append(
                 '## !! Could not determine repository location')
             req = dist.as_requirement()
             editable = False
     else:
         editable = False
         req = dist.as_requirement()
         specs = req.specs
         assert len(specs) == 1 and specs[0][0] == '=='
         version = specs[0][1]
         ver_match = cls._rev_re.search(version)
         date_match = cls._date_re.search(version)
         if ver_match or date_match:
             svn_backend = vcs.get_backend('svn')
             if svn_backend:
                 svn_location = svn_backend().get_location(
                     dist, dependency_links)
             if not svn_location:
                 logger.warn('Warning: cannot find svn location for %s' %
                             req)
                 comments.append(
                     '## FIXME: could not find svn URL in dependency_links for this package:'
                 )
             else:
                 comments.append(
                     '# Installing as editable to satisfy requirement %s:' %
                     req)
                 if ver_match:
                     rev = ver_match.group(1)
                 else:
                     rev = '{%s}' % date_match.group(1)
                 editable = True
                 req = '%s@%s#egg=%s' % (svn_location, rev,
                                         cls.egg_name(dist))
     return cls(dist.project_name, req, editable, comments)
Exemplo n.º 6
0
    def from_dist(cls, dist, dependency_links, find_tags=False):
        location = os.path.normcase(os.path.abspath(dist.location))
        comments = []
        from pip.vcs import vcs, get_src_requirement

        if vcs.get_backend_name(location):
            editable = True
            try:
                req = get_src_requirement(dist, location, find_tags)
            except InstallationError as exc:
                logger.warning(
                    "Error when trying to get requirement for VCS system %s, " "falling back to uneditable format", exc
                )
                req = None
            if req is None:
                logger.warning("Could not determine repository location of %s", location)
                comments.append("## !! Could not determine repository location")
                req = dist.as_requirement()
                editable = False
        else:
            editable = False
            req = dist.as_requirement()
            specs = req.specs
            assert len(specs) == 1 and specs[0][0] in [
                "==",
                "===",
            ], "Expected 1 spec with == or ===; specs = %r; dist = %r" % (specs, dist)
            version = specs[0][1]
            ver_match = cls._rev_re.search(version)
            date_match = cls._date_re.search(version)
            if ver_match or date_match:
                svn_backend = vcs.get_backend("svn")
                if svn_backend:
                    svn_location = svn_backend().get_location(dist, dependency_links)
                if not svn_location:
                    logger.warning("Warning: cannot find svn location for %s", req)
                    comments.append("## FIXME: could not find svn URL in dependency_links " "for this package:")
                else:
                    comments.append("# Installing as editable to satisfy requirement %s:" % req)
                    if ver_match:
                        rev = ver_match.group(1)
                    else:
                        rev = "{%s}" % date_match.group(1)
                    editable = True
                    req = "%s@%s#egg=%s" % (svn_location, rev, cls.egg_name(dist))
        return cls(dist.project_name, req, editable, comments)
Exemplo n.º 7
0
    def get(self):
        uname = os.popen("uname -a").read()
        python_version = sys.version.strip()

        packages = []

        for dist in pkg_resources.working_set:
            package = dict(
                name=dist.project_name,
                key=dist.key,
                version=dist.version
                if dist.has_version() else 'Unknown version',
                vcs=None,
            )

            location = text_type(Path(dist.location).absolute())
            vcs_name = vcs.get_backend_name(location)

            if vcs_name:
                vc = vcs.get_backend(vcs_name)()
                try:
                    url = vc.get_url(location)
                except pip.exceptions.InstallationError:
                    url = 'None'
                try:
                    revision = vc.get_revision(location)
                except pip.exceptions.InstallationError:
                    revision = 'None'
                package['vcs'] = dict(name=vcs_name,
                                      url=url,
                                      revision=revision)

            packages.append(package)
            packages.sort(key=lambda d: d.get('key'))

        config_values = [(k, repr(v))
                         for k, v in sorted(current_app.config.items())]

        return render_template(
            "admin/sysinfo.html",
            python_version=python_version,
            packages=packages,
            uname=uname,
            config_values=config_values,
        )
Exemplo n.º 8
0
    def from_dist(cls, dist, dependency_links, find_tags=False):
        location = os.path.normcase(os.path.abspath(dist.location))
        comments = []
        from pip.vcs import vcs, get_src_requirement

        if vcs.get_backend_name(location):
            editable = True
            try:
                req = get_src_requirement(dist, location, find_tags)
            except InstallationError:
                ex = sys.exc_info()[1]
                logger.warn(
                    "Error when trying to get requirement for VCS system %s, falling back to uneditable format" % ex)
                req = None
            if req is None:
                logger.warn('Could not determine repository location of %s' % location)
                comments.append('## !! Could not determine repository location')
                req = dist.as_requirement()
                editable = False
        else:
            editable = False
            req = dist.as_requirement()
            specs = req.specs
            assert len(specs) == 1 and specs[0][0] == '=='
            version = specs[0][1]
            ver_match = cls._rev_re.search(version)
            date_match = cls._date_re.search(version)
            if ver_match or date_match:
                svn_backend = vcs.get_backend('svn')
                if svn_backend:
                    svn_location = svn_backend(
                    ).get_location(dist, dependency_links)
                if not svn_location:
                    logger.warn(
                        'Warning: cannot find svn location for %s' % req)
                    comments.append('## FIXME: could not find svn URL in dependency_links for this package:')
                else:
                    comments.append('# Installing as editable to satisfy requirement %s:' % req)
                    if ver_match:
                        rev = ver_match.group(1)
                    else:
                        rev = '{%s}' % date_match.group(1)
                    editable = True
                    req = '%s@%s#egg=%s' % (svn_location, rev, cls.egg_name(dist))
        return cls(dist.project_name, req, editable, comments)
Exemplo n.º 9
0
  def get(self):
    uname = os.popen("uname -a").read()
    python_version = sys.version.strip()

    packages = []

    for dist in pkg_resources.working_set:
      package = dict(
          name=dist.project_name,
          key=dist.key,
          version=dist.version if dist.has_version() else u'Unknown version',
          vcs=None,
      )

      location = unicode(Path(dist.location).absolute())
      vcs_name = vcs.get_backend_name(location)

      if vcs_name:
        vc = vcs.get_backend(vcs_name)()
        try:
          url = vc.get_url(location)
        except pip.exceptions.InstallationError:
          url = 'None'
        try:
          revision = vc.get_revision(location)
        except pip.exceptions.InstallationError:
          revision = 'None'
        package['vcs'] = dict(name=vcs_name, url=url, revision=revision)

      packages.append(package)
      packages.sort(key=lambda d: d.get('key', None))

    return render_template("admin/sysinfo.html",
                           python_version=python_version,
                           packages=packages,
                           uname=uname)
Exemplo n.º 10
0
def is_vcs_root(path):
    return vcs.get_backend_name(path) is not None
Exemplo n.º 11
0
 def from_dist(cls, dist, dependency_links):
     location = os.path.normcase(os.path.abspath(dist.location))
     comments = []
     from pip.vcs import vcs, get_src_requirement
     if dist_is_editable(dist) and vcs.get_backend_name(location):
         editable = True
         try:
             req = get_src_requirement(dist, location)
         except InstallationError as exc:
             logger.warning(
                 "Error when trying to get requirement for VCS system %s, "
                 "falling back to uneditable format", exc
             )
             req = None
         if req is None:
             logger.warning(
                 'Could not determine repository location of %s', location
             )
             comments.append(
                 '## !! Could not determine repository location'
             )
             req = dist.as_requirement()
             editable = False
     else:
         editable = False
         req = dist.as_requirement()
         specs = req.specs
         assert len(specs) == 1 and specs[0][0] in ["==", "==="], \
             'Expected 1 spec with == or ===; specs = %r; dist = %r' % \
             (specs, dist)
         version = specs[0][1]
         ver_match = cls._rev_re.search(version)
         date_match = cls._date_re.search(version)
         if ver_match or date_match:
             svn_backend = vcs.get_backend('svn')
             if svn_backend:
                 svn_location = svn_backend().get_location(
                     dist,
                     dependency_links,
                 )
             if not svn_location:
                 logger.warning(
                     'Warning: cannot find svn location for %s', req)
                 comments.append(
                     '## FIXME: could not find svn URL in dependency_links '
                     'for this package:'
                 )
             else:
                 warnings.warn(
                     "SVN editable detection based on dependency links "
                     "will be dropped in the future.",
                     RemovedInPip11Warning,
                 )
                 comments.append(
                     '# Installing as editable to satisfy requirement %s:' %
                     req
                 )
                 if ver_match:
                     rev = ver_match.group(1)
                 else:
                     rev = '{%s}' % date_match.group(1)
                 editable = True
                 req = '%s@%s#egg=%s' % (
                     svn_location,
                     rev,
                     cls.egg_name(dist)
                 )
     return cls(dist.project_name, req, editable, comments)