attempt to stop using pip internals

This should let us stop using pip internals, which breaks us all the
time.

Change-Id: I10ada6860768017d4eb3c729f2870f2c7f4a46d7
This commit is contained in:
Sean Dague 2015-04-07 07:04:59 -04:00
parent 3010a55ea8
commit 166a9f1d50

View File

@ -31,8 +31,7 @@ import os
import os.path
import sys
from pip import req
import pkg_resources
_setup_py_text = """#!/usr/bin/env python
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
@ -59,17 +58,14 @@ setuptools.setup(
"""
def _parse_pip(pip):
def _package_name(pip_line):
"""Return normalized (lower case) package name.
install_require = req.InstallRequirement.from_line(pip)
if install_require.editable:
return pip
elif hasattr(install_require, "url") and install_require.url:
return pip
elif hasattr(install_require, "link") and install_require.link:
return pip
else:
return install_require.req.key
This is needed for comparing old and new dictionaries of
requirements to ensure they match.
"""
name = pkg_resources.Requirement.parse(pip_line).project_name
return name.lower()
def _pass_through(pip):
@ -99,7 +95,7 @@ def _parse_reqs(filename):
pip = pip.strip()
if _pass_through(pip):
continue
reqs[_parse_pip(pip)] = pip
reqs[_package_name(pip)] = pip
return reqs
@ -121,7 +117,7 @@ def _sync_requirements_file(source_reqs, dev_reqs, dest_path, suffix):
new_reqs.write(old_line)
continue
old_pip = _parse_pip(old_require.lower())
old_pip = _package_name(old_require)
# Special cases:
# projects need to align pep8 version on their own time
@ -131,8 +127,8 @@ def _sync_requirements_file(source_reqs, dev_reqs, dest_path, suffix):
if old_pip in source_reqs:
# allow it to be in dev-requirements
if ((old_pip in dev_reqs) and (old_require.lower() ==
dev_reqs[old_pip])):
if ((old_pip in dev_reqs) and (
old_require == dev_reqs[old_pip])):
new_reqs.write("%s\n" % dev_reqs[old_pip])
else:
new_reqs.write("%s\n" % source_reqs[old_pip])