Skip to content

Commit

Permalink
Update requirementslib and vistir
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Ryan <dan.ryan@canonical.com>
  • Loading branch information
techalchemy committed May 19, 2020
1 parent 243b4fd commit f4fba43
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pipenv/vendor/requirementslib/models/setup_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ def unparse_Mapping(self, item):
return unparsed

def unparse_list(self, item):
return type(item)([unparse(el) for el in item])
return type(item)([self.unparse(el) for el in item])

def unparse_tuple(self, item):
return self.unparse_list(item)
Expand Down Expand Up @@ -966,6 +966,17 @@ def parse_functions(self):
)
return self.resolved_function_names

def parse_setup_function(self):
setup = {} # type: Dict[Any, Any]
self.unmap_binops()
function_names = self.parse_functions()
if "setup" in function_names:
setup = self.unparse(function_names["setup"])
keys = list(setup.keys())
if len(keys) == 1 and keys[0] is None:
_, setup = setup.popitem()
return setup


def ast_unparse(item, initial_mapping=False, analyzer=None, recurse=True): # noqa:C901
# type: (Any, bool, Optional[Analyzer], bool) -> Union[List[Any], Dict[Any, Any], Tuple[Any, ...], STRING_TYPE]
Expand Down
20 changes: 20 additions & 0 deletions pipenv/vendor/vistir/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"TemporaryDirectory",
"NamedTemporaryFile",
"to_native_string",
"samefile",
"Mapping",
"Hashable",
"MutableMapping",
Expand Down Expand Up @@ -80,6 +81,7 @@
MutableSequence,
Callable,
)
from os.path import samefile

else: # pragma: no cover
# Only Python 2.7 is supported
Expand Down Expand Up @@ -110,6 +112,24 @@
NamedTemporaryFile = _NamedTemporaryFile
from pipenv.vendor.backports.weakref import finalize # type: ignore

try:
from os.path import samefile
except ImportError:

def samestat(s1, s2):
"""Test whether two stat buffers reference the same file."""
return s1.st_ino == s2.st_ino and s1.st_dev == s2.st_dev

def samefile(f1, f2):
"""Test whether two pathnames reference the same actual file or
directory This is determined by the device number and i-node number
and raises an exception if an os.stat() call on either pathname
fails."""
s1 = os.stat(f1)
s2 = os.stat(f2)
return samestat(s1, s2)


try:
# Introduced Python 3.5
from json import JSONDecodeError
Expand Down

0 comments on commit f4fba43

Please sign in to comment.