mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Merge pull request #5708 from pradyunsg/fix/vendoring-first-line-imports
Fix vendoring import rewriting, when imports are on first line
This commit is contained in:
commit
74721bcc8b
2 changed files with 3 additions and 3 deletions
|
@ -1,2 +1,2 @@
|
|||
from certifi import where
|
||||
from pip._vendor.certifi import where
|
||||
print(where())
|
||||
|
|
|
@ -78,12 +78,12 @@ def rewrite_file_imports(item, vendored_libs):
|
|||
text = re.sub(r'pkg_resources.extern', r'pip._vendor', text)
|
||||
for lib in vendored_libs:
|
||||
text = re.sub(
|
||||
r'(\n\s*)import %s(\n\s*)' % lib,
|
||||
r'(\n\s*|^)import %s(\n\s*)' % lib,
|
||||
r'\1from pip._vendor import %s\2' % lib,
|
||||
text,
|
||||
)
|
||||
text = re.sub(
|
||||
r'(\n\s*)from %s(\.|\s+)' % lib,
|
||||
r'(\n\s*|^)from %s(\.|\s+)' % lib,
|
||||
r'\1from pip._vendor.%s\2' % lib,
|
||||
text,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue