Skip to content

Commit

Permalink
Update scandir to avoid importing from system lib
Browse files Browse the repository at this point in the history
- Update lockfile with py2 deps

Signed-off-by: Dan Ryan <dan@danryan.co>
  • Loading branch information
techalchemy committed Jun 16, 2018
1 parent 69ace95 commit 2caa9d7
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 4 deletions.
34 changes: 34 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions pipenv/vendor/scandir.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
import os
import sys

try:
import _scandir
except ImportError:
_scandir = None
_scandir = None

try:
import ctypes
Expand Down
15 changes: 15 additions & 0 deletions tasks/vendoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,21 @@ def vendor(ctx, vendor_dir, rewrite=True):
remove_all(msgpack.glob('*.so'))


@invoke.task
def redo_imports(ctx, library):
vendor_dir = _get_vendor_dir(ctx)
log('Using vendor dir: %s' % vendor_dir)
vendored_libs = detect_vendored_libs(vendor_dir)
item = vendor_dir / library
library_name = vendor_dir / '{0}.py'.format(library)
log("Detected vendored libraries: %s" % ", ".join(vendored_libs))
log('Rewriting imports for %s...' % item)
if item.is_dir():
rewrite_imports(item, vendored_libs, vendor_dir)
else:
rewrite_file_imports(library_name, vendored_libs, vendor_dir)


@invoke.task
def rewrite_all_imports(ctx):
vendor_dir = _get_vendor_dir(ctx)
Expand Down
16 changes: 16 additions & 0 deletions tasks/vendoring/patches/vendor/drop_scandir_import.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/pipenv/vendor/scandir.py b/pipenv/vendor/scandir.py
index 2e47a397..2b2ade30 100644
--- a/pipenv/vendor/scandir.py
+++ b/pipenv/vendor/scandir.py
@@ -26,10 +26,7 @@ import collections
import os
import sys

-try:
- import _scandir
-except ImportError:
- _scandir = None
+_scandir = None

try:
import ctypes

0 comments on commit 2caa9d7

Please sign in to comment.