From 576b7a8326a9b9f5043c472694bba51cbb6b4fcc Mon Sep 17 00:00:00 2001 From: Alex Castillo Date: Sun, 18 Oct 2026 01:56:36 -0400 Subject: [PATCH 1/2] Skip "*" versions when pinning resolved default deps as constraints A default package whose markers exclude the locking platform is locked as "version": "*". get_constraints_from_resolved_deps turned that into the constraint "colorama*", which pip rejects, so locking any Pipfile with such a package and [dev-packages] failed with "Invalid requirement: 'colorama*'" since 2026.4.0. There is no pin to carry over for these packages, so skip them like get_constraints_from_deps does. Co-Authored-By: Claude Opus 5.5 --- news/0000.bugfix.rst | 3 +++ pipenv/utils/dependencies.py | 4 +++- tests/unit/test_dependencies.py | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 news/0000.bugfix.rst diff --git a/news/0000.bugfix.rst b/news/0000.bugfix.rst new file mode 100644 index 000000000..1cbb9055a --- /dev/null +++ b/news/0000.bugfix.rst @@ -0,0 +1,3 @@ +Fix ``pipenv lock`` failing with ``Invalid requirement: 'colorama*'`` when a default package has markers that exclude the current platform, +such as ``colorama = {version = "*", markers = "sys_platform == 'win32'"}``, and the Pipfile also has ``[dev-packages]``. +The default section's locked ``"*"`` entry was turned into an invalid constraint for the develop resolution. diff --git a/pipenv/utils/dependencies.py b/pipenv/utils/dependencies.py index 6d6b4658f..06b678fd2 100644 --- a/pipenv/utils/dependencies.py +++ b/pipenv/utils/dependencies.py @@ -1574,7 +1574,9 @@ def get_constraints_from_resolved_deps(resolved_deps): if any(k in dep_info for k in ("path", "file", "git", "hg", "svn", "bzr")): continue version = dep_info.get("version") - if version: + # A package skipped by its markers is locked as "*": there is no pin + # to carry over, and "name*" is not a valid requirement. + if version and not is_star(version): canonical = canonicalize_name(dep_name) constraints.add(f"{canonical}{version}") return constraints diff --git a/tests/unit/test_dependencies.py b/tests/unit/test_dependencies.py index fdf41ef06..c33944be1 100644 --- a/tests/unit/test_dependencies.py +++ b/tests/unit/test_dependencies.py @@ -998,6 +998,21 @@ def test_empty_deps(self): assert get_constraints_from_resolved_deps({}) == set() + def test_skips_wildcard_versions(self): + """A package whose markers exclude the locking platform is locked as "*". + + Writing it as ``colorama*`` made pip reject the constraints file, so + locking a dev category failed (``Invalid requirement: 'colorama*'``). + """ + from pipenv.utils.dependencies import get_constraints_from_resolved_deps + + resolved = { + "colorama": {"markers": "sys_platform == 'win32'", "version": "*"}, + "normal": {"version": "==1.0"}, + } + constraints = get_constraints_from_resolved_deps(resolved) + assert constraints == {"normal==1.0"} + def test_canonicalizes_names(self): from pipenv.utils.dependencies import get_constraints_from_resolved_deps From 683313038f6570ad98329e23d01bc4f97bf3961d Mon Sep 17 00:00:00 2001 From: Alex Castillo Date: Sun, 18 Oct 2026 01:59:07 -0400 Subject: [PATCH 2/2] Rename news fragment to 6744 Co-Authored-By: Claude Opus 5.5 --- news/{0000.bugfix.rst => 6744.bugfix.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename news/{0000.bugfix.rst => 6744.bugfix.rst} (100%) diff --git a/news/0000.bugfix.rst b/news/6744.bugfix.rst similarity index 100% rename from news/0000.bugfix.rst rename to news/6744.bugfix.rst