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:
parent
3010a55ea8
commit
166a9f1d50
28
update.py
28
update.py
@ -31,8 +31,7 @@ import os
|
|||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from pip import req
|
import pkg_resources
|
||||||
|
|
||||||
|
|
||||||
_setup_py_text = """#!/usr/bin/env python
|
_setup_py_text = """#!/usr/bin/env python
|
||||||
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
# 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)
|
This is needed for comparing old and new dictionaries of
|
||||||
if install_require.editable:
|
requirements to ensure they match.
|
||||||
return pip
|
"""
|
||||||
elif hasattr(install_require, "url") and install_require.url:
|
name = pkg_resources.Requirement.parse(pip_line).project_name
|
||||||
return pip
|
return name.lower()
|
||||||
elif hasattr(install_require, "link") and install_require.link:
|
|
||||||
return pip
|
|
||||||
else:
|
|
||||||
return install_require.req.key
|
|
||||||
|
|
||||||
|
|
||||||
def _pass_through(pip):
|
def _pass_through(pip):
|
||||||
@ -99,7 +95,7 @@ def _parse_reqs(filename):
|
|||||||
pip = pip.strip()
|
pip = pip.strip()
|
||||||
if _pass_through(pip):
|
if _pass_through(pip):
|
||||||
continue
|
continue
|
||||||
reqs[_parse_pip(pip)] = pip
|
reqs[_package_name(pip)] = pip
|
||||||
return reqs
|
return reqs
|
||||||
|
|
||||||
|
|
||||||
@ -121,7 +117,7 @@ def _sync_requirements_file(source_reqs, dev_reqs, dest_path, suffix):
|
|||||||
new_reqs.write(old_line)
|
new_reqs.write(old_line)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
old_pip = _parse_pip(old_require.lower())
|
old_pip = _package_name(old_require)
|
||||||
|
|
||||||
# Special cases:
|
# Special cases:
|
||||||
# projects need to align pep8 version on their own time
|
# 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:
|
if old_pip in source_reqs:
|
||||||
# allow it to be in dev-requirements
|
# allow it to be in dev-requirements
|
||||||
if ((old_pip in dev_reqs) and (old_require.lower() ==
|
if ((old_pip in dev_reqs) and (
|
||||||
dev_reqs[old_pip])):
|
old_require == dev_reqs[old_pip])):
|
||||||
new_reqs.write("%s\n" % dev_reqs[old_pip])
|
new_reqs.write("%s\n" % dev_reqs[old_pip])
|
||||||
else:
|
else:
|
||||||
new_reqs.write("%s\n" % source_reqs[old_pip])
|
new_reqs.write("%s\n" % source_reqs[old_pip])
|
||||||
|
Loading…
Reference in New Issue
Block a user