From 034bd6a4fef56a85ebc9a02a3165333744122f7d Mon Sep 17 00:00:00 2001 From: frostming Date: Fri, 10 Jul 2020 16:06:14 +0800 Subject: [PATCH 1/2] Update requirementslib to 1.5.12 --- pipenv/vendor/requirementslib/__init__.py | 2 +- .../requirementslib/models/requirements.py | 4 +--- .../requirementslib/models/setup_info.py | 19 ++++++++++++++----- pipenv/vendor/vendor.txt | 2 +- tasks/vendoring/__init__.py | 5 ++++- .../patches/vendor/passa-close-session.patch | 13 +++++++++++++ .../vendor/update-attrs-import-path.patch | 13 ------------- 7 files changed, 34 insertions(+), 24 deletions(-) diff --git a/pipenv/vendor/requirementslib/__init__.py b/pipenv/vendor/requirementslib/__init__.py index f410333744..11803839c8 100644 --- a/pipenv/vendor/requirementslib/__init__.py +++ b/pipenv/vendor/requirementslib/__init__.py @@ -10,7 +10,7 @@ from .models.pipfile import Pipfile from .models.requirements import Requirement -__version__ = "1.5.11" +__version__ = "1.5.12" logger = logging.getLogger(__name__) diff --git a/pipenv/vendor/requirementslib/models/requirements.py b/pipenv/vendor/requirementslib/models/requirements.py index 77ba0fd879..bf62ad249c 100644 --- a/pipenv/vendor/requirementslib/models/requirements.py +++ b/pipenv/vendor/requirementslib/models/requirements.py @@ -887,9 +887,7 @@ def parsed_setup_cfg(self): and self.setup_cfg ): return {} - base_dir = os.path.dirname(os.path.abspath(self.setup_cfg)) - setup_content = read_source(self.setup_cfg) - return parse_setup_cfg(setup_content, base_dir) + return self.setup_info.parse_setup_cfg() @cached_property def parsed_setup_py(self): diff --git a/pipenv/vendor/requirementslib/models/setup_info.py b/pipenv/vendor/requirementslib/models/setup_info.py index fd2913c775..b78e33af7e 100644 --- a/pipenv/vendor/requirementslib/models/setup_info.py +++ b/pipenv/vendor/requirementslib/models/setup_info.py @@ -250,7 +250,7 @@ def get_package_dir_from_setupcfg(parser, base_dir=None): if "find:" in pkg_dir: _, pkg_dir = pkg_dir.split("find:") pkg_dir = pkg_dir.strip() - package_dir = os.path.join(package_dir, pkg_dir) + package_dir = os.path.join(package_dir, pkg_dir) elif os.path.exists(os.path.join(package_dir, "setup.py")): setup_py = ast_parse_setup_py(os.path.join(package_dir, "setup.py")) if "package_dir" in setup_py: @@ -681,6 +681,11 @@ def get_metadata_from_dist(dist): ) ) +if getattr(ast, "AnnAssign", None): + ASSIGN_NODES = (ast.Assign, ast.AnnAssign) +else: + ASSIGN_NODES = (ast.Assign,) + class Analyzer(ast.NodeVisitor): def __init__(self): @@ -704,7 +709,7 @@ def generic_visit(self, node): self.name_types.append(node) if isinstance(node, ast.Str): self.strings.append(node) - if isinstance(node, ast.Assign): + if isinstance(node, ASSIGN_NODES): self.assignments.update(ast_unparse(node, initial_mapping=True)) super(Analyzer, self).generic_visit(node) @@ -1139,20 +1144,24 @@ def ast_unparse(item, initial_mapping=False, analyzer=None, recurse=True): # no unparsed[func_name].update(unparse(keyword)) elif isinstance(item, ast.keyword): unparsed = {unparse(item.arg): unparse(item.value)} - elif isinstance(item, ast.Assign): + elif isinstance(item, ASSIGN_NODES): # XXX: DO NOT UNPARSE THIS # XXX: If we unparse this it becomes impossible to map it back # XXX: To the original node in the AST so we can find the # XXX: Original reference + try: + targets = item.targets # for ast.Assign + except AttributeError: # for ast.AnnAssign + targets = (item.target,) if not initial_mapping: - target = unparse(next(iter(item.targets)), recurse=False) + target = unparse(next(iter(targets)), recurse=False) val = unparse(item.value, recurse=False) if isinstance(target, (tuple, set, list)): unparsed = dict(zip(target, val)) else: unparsed = {target: val} else: - unparsed = {next(iter(item.targets)): item} + unparsed = {next(iter(targets)): item} elif isinstance(item, Mapping): unparsed = {} for k, v in item.items(): diff --git a/pipenv/vendor/vendor.txt b/pipenv/vendor/vendor.txt index de5797a938..c8325479f6 100644 --- a/pipenv/vendor/vendor.txt +++ b/pipenv/vendor/vendor.txt @@ -26,7 +26,7 @@ requests==2.23.0 idna==2.9 urllib3==1.25.9 certifi==2020.4.5.1 -requirementslib==1.5.11 +requirementslib==1.5.12 attrs==19.3.0 distlib==0.3.0 packaging==20.3 diff --git a/tasks/vendoring/__init__.py b/tasks/vendoring/__init__.py index 31f2203cf7..e55bdfdf7a 100644 --- a/tasks/vendoring/__init__.py +++ b/tasks/vendoring/__init__.py @@ -574,7 +574,10 @@ def packages_missing_licenses( for lic in itertools.product(("LICENSE", "LICENSE-MIT"), LICENSE_EXTS) ] for i, req in enumerate(requirements): - pkg = req.strip().split("=")[0] + if req.startswith("git+"): + pkg = req.strip().split("#egg=")[1] + else: + pkg = req.strip().split("=")[0] possible_pkgs = [pkg, pkg.replace("-", "_")] match_found = False if pkg in PY2_DOWNLOAD: diff --git a/tasks/vendoring/patches/vendor/passa-close-session.patch b/tasks/vendoring/patches/vendor/passa-close-session.patch index 38846befb5..2953f32b51 100644 --- a/tasks/vendoring/patches/vendor/passa-close-session.patch +++ b/tasks/vendoring/patches/vendor/passa-close-session.patch @@ -10,3 +10,16 @@ index 53b19b17..358cc33b 100644 return +diff --git a/pipenv/vendor/passa/models/projects.py b/pipenv/vendor/passa/models/projects.py +index f6e037d6..c7807c05 100644 +--- a/pipenv/vendor/passa/models/projects.py ++++ b/pipenv/vendor/passa/models/projects.py +@@ -6,7 +6,7 @@ import collections + import io + import os + +-import attr ++from pipenv.vendor import attr + import packaging.markers + import packaging.utils + import plette diff --git a/tasks/vendoring/patches/vendor/update-attrs-import-path.patch b/tasks/vendoring/patches/vendor/update-attrs-import-path.patch index d813371578..ffebbfebb6 100644 --- a/tasks/vendoring/patches/vendor/update-attrs-import-path.patch +++ b/tasks/vendoring/patches/vendor/update-attrs-import-path.patch @@ -1,16 +1,3 @@ -diff --git a/pipenv/vendor/passa/models/projects.py b/pipenv/vendor/passa/models/projects.py -index f6e037d6..c7807c05 100644 ---- a/pipenv/vendor/passa/models/projects.py -+++ b/pipenv/vendor/passa/models/projects.py -@@ -6,7 +6,7 @@ import collections - import io - import os - --import attr -+from pipenv.vendor import attr - import packaging.markers - import packaging.utils - import plette diff --git a/pipenv/vendor/requirementslib/models/dependencies.py b/pipenv/vendor/requirementslib/models/dependencies.py index 2608479a..1a610ce7 100644 --- a/pipenv/vendor/requirementslib/models/dependencies.py From 67a20395f5a640888939c38c3f1c79de3b951989 Mon Sep 17 00:00:00 2001 From: frostming Date: Fri, 10 Jul 2020 16:16:48 +0800 Subject: [PATCH 2/2] add news entry --- news/4335.bugfix.rst | 1 + news/4342.bugfix.rst | 1 + news/4385.vendor.rst | 1 + 3 files changed, 3 insertions(+) create mode 100644 news/4335.bugfix.rst create mode 100644 news/4342.bugfix.rst create mode 100644 news/4385.vendor.rst diff --git a/news/4335.bugfix.rst b/news/4335.bugfix.rst new file mode 100644 index 0000000000..8251e7ab86 --- /dev/null +++ b/news/4335.bugfix.rst @@ -0,0 +1 @@ +Fix a bug that Pipenv can't locate the correct file of special directives in ``setup.cfg`` of an editable package. diff --git a/news/4342.bugfix.rst b/news/4342.bugfix.rst new file mode 100644 index 0000000000..d3ae0a9a58 --- /dev/null +++ b/news/4342.bugfix.rst @@ -0,0 +1 @@ +Fix a bug that ``setup.py`` can't be parsed correctly when the assignment is type-annotated. diff --git a/news/4385.vendor.rst b/news/4385.vendor.rst new file mode 100644 index 0000000000..0cc19ef591 --- /dev/null +++ b/news/4385.vendor.rst @@ -0,0 +1 @@ +Update ``requirementslib`` to ``1.5.12``.