1
1
Fork 0
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:
Pradyun Gedam 2018-08-17 10:59:22 +05:30 committed by GitHub
commit 74721bcc8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -1,2 +1,2 @@
from certifi import where
from pip._vendor.certifi import where
print(where())

View file

@ -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,
)