Fix the vendoring script to cover relative imports

This commit is contained in:
Pradyun Gedam 2018-09-30 22:55:51 +05:30
parent 50ab3bf51e
commit caabd1f8b2
No known key found for this signature in database
GPG Key ID: DA17C4B29CB32E4B
3 changed files with 5 additions and 4 deletions

View File

@ -2,7 +2,7 @@ import os
import errno
import sys
from .extern import six
from pip._vendor import six
def _makedirs_31(path, exist_ok=False):

View File

@ -37,7 +37,7 @@ C{"<salutation>, <addressee>!"}), built up using L{Word}, L{Literal}, and L{And}
(L{'+'<ParserElement.__add__>} operator gives L{And} expressions, strings are auto-converted to
L{Literal} expressions)::
from pyparsing import Word, alphas
from pip._vendor.pyparsing import Word, alphas
# define grammar of a greeting
greet = Word(alphas) + "," + Word(alphas) + "!"
@ -1594,7 +1594,7 @@ class ParserElement(object):
after importing pyparsing.
Example::
import pyparsing
from pip._vendor import pyparsing
pyparsing.ParserElement.enablePackrat()
"""
if not ParserElement._packratEnabled:

View File

@ -75,7 +75,8 @@ def rewrite_file_imports(item, vendored_libs):
"""Rewrite 'import xxx' and 'from xxx import' for vendored_libs"""
text = item.read_text(encoding='utf-8')
# Revendor pkg_resources.extern first
text = re.sub(r'pkg_resources.extern', r'pip._vendor', text)
text = re.sub(r'pkg_resources\.extern', r'pip._vendor', text)
text = re.sub(r'from \.extern', r'from pip._vendor', text)
for lib in vendored_libs:
text = re.sub(
r'(\n\s*|^)import %s(\n\s*)' % lib,