Skip to content

Dependency resolution conflicts with hyphen in extras #11649

Closed
@subbyte

Description

@subbyte

Description

In the last couple of days, when pip install kestrel-jupyter==1.0.6, it will fail with a pip internal issue:

AssertionError: Internal issue: Candidate is not for this requirement jsonschema[format-nongpl,format-nongpl] vs jsonschema[format-nongpl]

The package kestrel-jupyter has dependencies

  • jupyterlab-server (from jupyterlab)
  • stix2-validator (from stix-shifter from kestrel-lang)

I checked that stix2-validator requires jsonschema[format-nongpl].
And it looks like jupyterlab-server only requires jsonschema.

Usually this will not lead to anything wrong, but several people hit the same error when installing kestrel-jupyter. The generated requirement jsonschema[format-nongpl,format-nongpl] looks strange. When I check further with pip --debug, it looks like pip tries to satisfy jsonschema with extras format-nongpl and format_nongpl (hyphen and underscore). Not sure how this happened and whether this led to a dependency resolution failure.

Expected behavior

Success installation of kestrel-jupyter.

I find a version of jupyterlab-server that does not trigger the issue, so I released a new version of kestrel-jupyter (1.0.7) to specify that version of jupyterlab-server and temporarily mitigate the issue for users.

That is to say, this will work:

# in a clean Python venv with latest pip
pip install jupyterlab-server==2.15.2
pip install kestrel-jupyter==1.0.6

But the following will fail:

# in a clean Python venv with latest pip
# jupyterlab-server>=2.16 will be installed
pip install kestrel-jupyter==1.0.6

pip version

22.3.1

Python version

3.9

OS

macos

How to Reproduce

In a newly created Python venv, upgrade pip to the latest (22.3.1), then do:

pip install kestrel-jupyter==1.0.6

Output

ERROR: Exception:
Traceback (most recent call last):
  File "/Users/subx/venv/test3/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 160, in exc_logging_wrapper
    status = run_func(*args)
  File "/Users/subx/venv/test3/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
    return func(self, options, args)
  File "/Users/subx/venv/test3/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 400, in run
    requirement_set = resolver.resolve(
  File "/Users/subx/venv/test3/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 92, in resolve
    result = self._result = resolver.resolve(
  File "/Users/subx/venv/test3/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 481, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/Users/subx/venv/test3/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 373, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
  File "/Users/subx/venv/test3/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 222, in _attempt_to_pin_criterion
    satisfied = all(
  File "/Users/subx/venv/test3/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 223, in <genexpr>
    self._p.is_satisfied_by(requirement=r, candidate=candidate)
  File "/Users/subx/venv/test3/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/provider.py", line 233, in is_satisfied_by
    return requirement.is_satisfied_by(candidate)
  File "/Users/subx/venv/test3/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/requirements.py", line 84, in is_satisfied_by
    assert candidate.name == self.name, (
AssertionError: Internal issue: Candidate is not for this requirement jsonschema[format-nongpl,format-nongpl] vs jsonschema[format-nongpl]

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    S: needs triageIssues/PRs that need to be triagedtype: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions