Skip to content

Commit

Permalink
Merge pull request #4385 from pypa/vendor/update
Browse files Browse the repository at this point in the history
Update requirementslib to 1.5.12
  • Loading branch information
frostming authored Jul 10, 2020
2 parents 6aa08f8 + ce2611e commit b29a488
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 24 deletions.
1 change: 1 addition & 0 deletions news/4335.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug that Pipenv can't locate the correct file of special directives in ``setup.cfg`` of an editable package.
1 change: 1 addition & 0 deletions news/4342.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug that ``setup.py`` can't be parsed correctly when the assignment is type-annotated.
1 change: 1 addition & 0 deletions news/4385.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update ``requirementslib`` to ``1.5.12``.
2 changes: 1 addition & 1 deletion pipenv/vendor/requirementslib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
4 changes: 1 addition & 3 deletions pipenv/vendor/requirementslib/models/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
19 changes: 14 additions & 5 deletions pipenv/vendor/requirementslib/models/setup_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand All @@ -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)

Expand Down Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion tasks/vendoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions tasks/vendoring/patches/vendor/passa-close-session.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 0 additions & 13 deletions tasks/vendoring/patches/vendor/update-attrs-import-path.patch
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b29a488

Please sign in to comment.