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

Issue 4925 resolver envvar limit #5313

Merged
merged 3 commits into from
Aug 31, 2022
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
44 changes: 23 additions & 21 deletions Pipfile.lock

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

1 change: 1 addition & 0 deletions news/4925.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``pipenv`` now uses a ``NamedTemporaryFile`` for rsolver constraints and drops internal env var ``PIPENV_PACKAGES``.
14 changes: 12 additions & 2 deletions pipenv/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ def get_parser():
action="store",
default=os.environ.get("PIPENV_RESOLVER_FILE"),
)
parser.add_argument(
"--constraints-file",
metavar="constraints_file",
action="store",
default=None,
)
parser.add_argument("packages", nargs="*")
return parser

Expand All @@ -120,8 +126,12 @@ def handle_parsed_args(parsed):
logger.setLevel(logging.INFO)
os.environ["PIP_RESOLVER_DEBUG"] = ""
os.environ["PIPENV_VERBOSITY"] = str(parsed.verbose)
if "PIPENV_PACKAGES" in os.environ:
parsed.packages += os.environ.get("PIPENV_PACKAGES", "").strip().split("\n")
if parsed.constraints_file:
constraints = open(parsed.constraints_file)
file_constraints = constraints.read().strip().split("\n")
constraints.close()
os.unlink(parsed.constraints_file)
parsed.packages += sorted(file_constraints)
return parsed


Expand Down
9 changes: 7 additions & 2 deletions pipenv/utils/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,10 +1026,15 @@ def venv_resolve_deps(
sp.write(decode_for_output("Building requirements..."))
deps = convert_deps_to_pip(deps, project, include_index=True)
constraints = set(deps)
os.environ["PIPENV_PACKAGES"] = str("\n".join(constraints))
constraints_file = tempfile.NamedTemporaryFile(
mode="w+", prefix="pipenv", suffix="constraints.txt", delete=False
)
constraints_file.write(str("\n".join(constraints)))
constraints_file.close()
cmd.append("--constraints-file")
cmd.append(constraints_file.name)
sp.write(decode_for_output("Resolving dependencies..."))
c = resolve(cmd, sp, project=project)
results = c.stdout.strip()
if c.returncode == 0:
sp.green.ok(environments.PIPENV_SPINNER_OK_TEXT.format("Success!"))
if not project.s.is_verbose() and c.stderr.strip():
Expand Down