Esempio n. 1
0
 def update_editable(self, obtain=True):
     if not self.link:
         logger.debug(
             "Cannot update repository at %s; repository location is "
             "unknown",
             self.source_dir,
         )
         return
     assert self.editable
     assert self.source_dir
     if self.link.scheme == 'file':
         # Static paths don't get updated
         return
     assert '+' in self.link.url, "bad url: %r" % self.link.url
     if not self.update:
         return
     vc_type, url = self.link.url.split('+', 1)
     backend = vcs.get_backend(vc_type)
     if backend:
         vcs_backend = backend(self.link.url)
         if obtain:
             vcs_backend.obtain(self.source_dir)
         else:
             vcs_backend.export(self.source_dir)
     else:
         assert 0, ('Unexpected version control type (in %s): %s' %
                    (self.link, vc_type))
Esempio n. 2
0
 def update_editable(self, obtain=True):
     if not self.url:
         logger.debug(
             "Cannot update repository at %s; repository location is "
             "unknown",
             self.source_dir,
         )
         return
     assert self.editable
     assert self.source_dir
     if self.url.startswith('file:'):
         # Static paths don't get updated
         return
     assert '+' in self.url, "bad url: %r" % self.url
     if not self.update:
         return
     vc_type, url = self.url.split('+', 1)
     backend = vcs.get_backend(vc_type)
     if backend:
         vcs_backend = backend(self.url)
         if obtain:
             vcs_backend.obtain(self.source_dir)
         else:
             vcs_backend.export(self.source_dir)
     else:
         assert 0, (
             'Unexpected version control type (in %s): %s'
             % (self.url, vc_type))
Esempio n. 3
0
File: freeze.py Progetto: 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)
Esempio n. 4
0
def get_vcs_command(vcs_type):
    """Find the command using a Pip VCS backend.

    """
    try:
        return pip_vcs.get_backend(vcs_type)().cmd
    except BadCommand:
        pass
Esempio 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)
Esempio 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)
Esempio 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,
        )
Esempio 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)
Esempio n. 9
0
 def update_editable(self, obtain=True):
     if not self.link:
         logger.debug("Cannot update repository at %s; repository location is " "unknown", self.source_dir)
         return
     assert self.editable
     assert self.source_dir
     if self.link.scheme == "file":
         # Static paths don't get updated
         return
     assert "+" in self.link.url, "bad url: %r" % self.link.url
     if not self.update:
         return
     vc_type, url = self.link.url.split("+", 1)
     backend = vcs.get_backend(vc_type)
     if backend:
         vcs_backend = backend(self.link.url)
         if obtain:
             vcs_backend.obtain(self.source_dir)
         else:
             vcs_backend.export(self.source_dir)
     else:
         assert 0, "Unexpected version control type (in %s): %s" % (self.link, vc_type)
Esempio n. 10
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)
Esempio n. 11
0
def parse_editable(editable_req, default_vcs=None):
    """Parses an editable requirement into:
        - a requirement name
        - an URL
        - extras
        - editable options
    Accepted requirements:
        svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
        .[some_extra]
    """

    from pip.index import Link

    url = editable_req
    extras = None

    # If a file path is specified with extras, strip off the extras.
    m = re.match(r'^(.+)(\[[^\]]+\])$', url)
    if m:
        url_no_extras = m.group(1)
        extras = m.group(2)
    else:
        url_no_extras = url

    if os.path.isdir(url_no_extras):
        if not os.path.exists(os.path.join(url_no_extras, 'setup.py')):
            raise InstallationError(
                "Directory %r is not installable. File 'setup.py' not found." %
                url_no_extras)
        # Treating it as code that has already been checked out
        url_no_extras = path_to_url(url_no_extras)

    if url_no_extras.lower().startswith('file:'):
        package_name = Link(url_no_extras).egg_fragment
        if extras:
            return (
                package_name,
                url_no_extras,
                pkg_resources.Requirement.parse('__placeholder__' +
                                                extras).extras,
                {},
            )
        else:
            return package_name, url_no_extras, None, {}

    for version_control in vcs:
        if url.lower().startswith('%s:' % version_control):
            url = '%s+%s' % (version_control, url)
            break

    if '+' not in url:
        if default_vcs:
            url = default_vcs + '+' + url
        else:
            raise InstallationError(
                '%s should either be a path to a local project or a VCS url '
                'beginning with svn+, git+, hg+, or bzr+' % editable_req)

    vc_type = url.split('+', 1)[0].lower()

    if not vcs.get_backend(vc_type):
        error_message = 'For --editable=%s only ' % editable_req + \
            ', '.join([backend.name + '+URL' for backend in vcs.backends]) + \
            ' is currently supported'
        raise InstallationError(error_message)

    try:
        options = _build_editable_options(editable_req)
    except Exception as exc:
        raise InstallationError('--editable=%s error in editable options:%s' %
                                (editable_req, exc))
    if not options or 'egg' not in options:
        req = _build_req_from_url(editable_req)
        if not req:
            raise InstallationError(
                '--editable=%s is not the right format; it must have '
                '#egg=Package' % editable_req)
    else:
        req = options['egg']

    package = _strip_postfix(req)
    return package, url, None, options
Esempio n. 12
0
def parse_editable(editable_req, default_vcs=None):
    """Parses an editable requirement into:
        - a requirement name
        - an URL
        - extras
        - editable options
    Accepted requirements:
        svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
        .[some_extra]
    """

    from pip.index import Link

    url = editable_req

    # If a file path is specified with extras, strip off the extras.
    url_no_extras, extras = _strip_extras(url)

    if os.path.isdir(url_no_extras):
        if not os.path.exists(os.path.join(url_no_extras, 'setup.py')):
            raise InstallationError(
                "Directory %r is not installable. File 'setup.py' not found." %
                url_no_extras)
        # Treating it as code that has already been checked out
        url_no_extras = path_to_url(url_no_extras)

    if url_no_extras.lower().startswith('file:'):
        package_name = Link(url_no_extras).egg_fragment
        if extras:
            return (
                package_name,
                url_no_extras,
                Requirement("placeholder" + extras.lower()).extras,
            )
        else:
            return package_name, url_no_extras, None

    for version_control in vcs:
        if url.lower().startswith('%s:' % version_control):
            url = '%s+%s' % (version_control, url)
            break

    if '+' not in url:
        if default_vcs:
            warnings.warn(
                "--default-vcs has been deprecated and will be removed in "
                "the future.",
                RemovedInPip10Warning,
            )
            url = default_vcs + '+' + url
        else:
            raise InstallationError(
                '%s should either be a path to a local project or a VCS url '
                'beginning with svn+, git+, hg+, or bzr+' % editable_req)

    vc_type = url.split('+', 1)[0].lower()

    if not vcs.get_backend(vc_type):
        error_message = 'For --editable=%s only ' % editable_req + \
            ', '.join([backend.name + '+URL' for backend in vcs.backends]) + \
            ' is currently supported'
        raise InstallationError(error_message)

    package_name = Link(url).egg_fragment
    if not package_name:
        raise InstallationError(
            "Could not detect requirement name for '%s', please specify one "
            "with #egg=your_package_name" % editable_req)
    return _strip_postfix(package_name), url, None
Esempio n. 13
0
        else:
            editable = False
            req = dist.as_requirement()
            specs = req.specs
<<<<<<< HEAD
            assert len(specs) == 1 and specs[0][0] in ["==", "==="], \
                'Expected 1 spec with == or ===; specs = %r; dist = %r' % \
                (specs, dist)
=======
            assert len(specs) == 1 and specs[0][0] in ["==", "==="]
>>>>>>> bde4533e29dfedadf6bcf9d451baa615bc828a59
            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:' %
Esempio n. 14
0
        os.makedirs(os.path.dirname(cache_path))
    except OSError, e:
        if e.errno != errno.EEXIST:
            raise

    if not self.url:
        return self._orig_update_editable(obtain=obtain)

    assert self.editable
    assert self.source_dir
    if self.url.startswith('file:'):
        # we don't care about file: urls
        return self._orig_update_editable(obtain=obtain)

    vc_type, url = self.url.split('+', 1)
    backend = vcs.get_backend(vc_type)
    if backend:
        vcs_backend = backend(self.url)
        vcs_backend.obtain(cache_path)
        shutil.copytree(cache_path, self.source_dir, symlinks=True)
    else:
        assert 0, (
            'Unexpected version control type (in %s): %s'
            % (self.url, vc_type))


def main():
    from pipproxy.pippatch.venv import restart_in_venv as patched_restart_in_venv
    import pip.venv
    import pip.basecommand
    pip.venv.restart_in_venv = patched_restart_in_venv
Esempio n. 15
0
def parse_editable(editable_req):
    """Parses an editable requirement into:
        - a requirement name
        - an URL
        - extras
        - editable options
    Accepted requirements:
        svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
        .[some_extra]
    """

    from pip.index import Link

    url = editable_req

    # If a file path is specified with extras, strip off the extras.
    url_no_extras, extras = _strip_extras(url)

    if os.path.isdir(url_no_extras):
        if not os.path.exists(os.path.join(url_no_extras, 'setup.py')):
            raise InstallationError(
                "Directory %r is not installable. File 'setup.py' not found." %
                url_no_extras
            )
        # Treating it as code that has already been checked out
        url_no_extras = path_to_url(url_no_extras)

    if url_no_extras.lower().startswith('file:'):
        package_name = Link(url_no_extras).egg_fragment
        if extras:
            return (
                package_name,
                url_no_extras,
                Requirement("placeholder" + extras.lower()).extras,
            )
        else:
            return package_name, url_no_extras, None

    for version_control in vcs:
        if url.lower().startswith('%s:' % version_control):
            url = '%s+%s' % (version_control, url)
            break

    if '+' not in url:
        raise InstallationError(
            '%s should either be a path to a local project or a VCS url '
            'beginning with svn+, git+, hg+, or bzr+' %
            editable_req
        )

    vc_type = url.split('+', 1)[0].lower()

    if not vcs.get_backend(vc_type):
        error_message = 'For --editable=%s only ' % editable_req + \
            ', '.join([backend.name + '+URL' for backend in vcs.backends]) + \
            ' is currently supported'
        raise InstallationError(error_message)

    package_name = Link(url).egg_fragment
    if not package_name:
        raise InstallationError(
            "Could not detect requirement name for '%s', please specify one "
            "with #egg=your_package_name" % editable_req
        )
    return _strip_postfix(package_name), url, None
Esempio n. 16
0
def parse_editable(editable_req, default_vcs=None):
    """Parses an editable requirement into:
        - a requirement name
        - an URL
        - extras
        - editable options
    Accepted requirements:
        svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
        .[some_extra]
    """

    url = editable_req
    extras = None

    # If a file path is specified with extras, strip off the extras.
    m = re.match(r'^(.+)(\[[^\]]+\])$', url)
    if m:
        url_no_extras = m.group(1)
        extras = m.group(2)
    else:
        url_no_extras = url

    if os.path.isdir(url_no_extras):
        if not os.path.exists(os.path.join(url_no_extras, 'setup.py')):
            raise InstallationError(
                "Directory %r is not installable. File 'setup.py' not found." %
                url_no_extras
            )
        # Treating it as code that has already been checked out
        url_no_extras = path_to_url(url_no_extras)

    if url_no_extras.lower().startswith('file:'):
        if extras:
            return (
                None,
                url_no_extras,
                pkg_resources.Requirement.parse(
                    '__placeholder__' + extras
                ).extras,
                {},
            )
        else:
            return None, url_no_extras, None, {}

    for version_control in vcs:
        if url.lower().startswith('%s:' % version_control):
            url = '%s+%s' % (version_control, url)
            break

    if '+' not in url:
        if default_vcs:
            url = default_vcs + '+' + url
        else:
            raise InstallationError(
                '%s should either be a path to a local project or a VCS url '
                'beginning with svn+, git+, hg+, or bzr+' %
                editable_req
            )

    vc_type = url.split('+', 1)[0].lower()

    if not vcs.get_backend(vc_type):
        error_message = 'For --editable=%s only ' % editable_req + \
            ', '.join([backend.name + '+URL' for backend in vcs.backends]) + \
            ' is currently supported'
        raise InstallationError(error_message)

    try:
        options = _build_editable_options(editable_req)
    except Exception as exc:
        raise InstallationError(
            '--editable=%s error in editable options:%s' % (editable_req, exc)
        )
    if not options or 'egg' not in options:
        req = _build_req_from_url(editable_req)
        if not req:
            raise InstallationError(
                '--editable=%s is not the right format; it must have '
                '#egg=Package' % editable_req
            )
    else:
        req = options['egg']

    package = _strip_postfix(req)
    return package, url, None, options
Esempio n. 17
0
def parse_editable(editable_req, default_vcs=None):
    """Parses an editable requirement into:
        - a requirement name
        - an URL
        - extras
        - editable options
    Accepted requirements:
        svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
        .[some_extra]
    """

    from pip.index import Link

    url = editable_req
    extras = None

    # If a file path is specified with extras, strip off the extras.
    m = re.match(r'^(.+)(\[[^\]]+\])$', url)
    if m:
        url_no_extras = m.group(1)
        extras = m.group(2)
    else:
        url_no_extras = url

    if os.path.isdir(url_no_extras):
        if not os.path.exists(os.path.join(url_no_extras, 'setup.py')):
            raise InstallationError(
                "Directory %r is not installable. File 'setup.py' not found." %
                url_no_extras
            )
        # Treating it as code that has already been checked out
        url_no_extras = path_to_url(url_no_extras)

    if url_no_extras.lower().startswith('file:'):
        package_name = Link(url_no_extras).egg_fragment
        if extras:
            return (
                package_name,
                url_no_extras,
                Requirement("placeholder" + extras.lower()).extras,
            )
        else:
            return package_name, url_no_extras, None

    for version_control in vcs:
        if url.lower().startswith('%s:' % version_control):
            url = '%s+%s' % (version_control, url)
            break

    if '+' not in url:
        if default_vcs:
            warnings.warn(
                "--default-vcs has been deprecated and will be removed in "
                "the future.",
                RemovedInPip10Warning,
            )
            url = default_vcs + '+' + url
        else:
            raise InstallationError(
                '%s should either be a path to a local project or a VCS url '
                'beginning with svn+, git+, hg+, or bzr+' %
                editable_req
            )

    vc_type = url.split('+', 1)[0].lower()

    if not vcs.get_backend(vc_type):
        error_message = 'For --editable=%s only ' % editable_req + \
            ', '.join([backend.name + '+URL' for backend in vcs.backends]) + \
            ' is currently supported'
        raise InstallationError(error_message)

    package_name = Link(url).egg_fragment
    if not package_name:
        raise InstallationError(
            "Could not detect requirement name, please specify one with #egg="
        )
    if not package_name:
        raise InstallationError(
            '--editable=%s is not the right format; it must have '
            '#egg=Package' % editable_req
        )
    return _strip_postfix(package_name), url, None
Esempio n. 18
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)