Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update requirementslib to 1.5.12 #4385

Merged
merged 3 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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