Skip to content

solver doesn't find correct version of package with a number at the end of the name #6996

@samthurston

Description

@samthurston
  • [ x] I am on the latest stable Poetry version, installed using a recommended method.
  • [ x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [ x] I have consulted the FAQ and blog for any relevant entries or release notes.
  • [x ] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

When installing a package with an integer at the end of the package name, the solver is not finding the correct package. The specific package I am having trouble with is flask-restful-swagger-2. latest at the time of writing is 0.35

adding unbounded:

$ poetry add flask-restful-swagger-2
Using version ^0.20 for flask-restful-swagger-2

Updating dependencies
Resolving dependencies... (548.9s)

Writing lock file

Package operations: 13 installs, 0 updates, 0 removals

  • Installing markupsafe (2.1.1)
  • Installing zipp (3.10.0)
  • Installing click (8.1.3)
  • Installing importlib-metadata (5.0.0)
  • Installing itsdangerous (2.1.2)
  • Installing jinja2 (3.1.2)
  • Installing werkzeug (2.2.2)
  • Installing aniso8601 (9.0.1)
  • Installing flask (2.2.2)
  • Installing pytz (2022.6)
  • Installing six (1.16.0)
  • Installing flask-restful (0.3.9)
  • Installing flask-restful-swagger-2 (0.20)

adding the explicit latest version bound:

$ poetry add flask-restful-swagger-2@0.35
Could not find a matching version of package flask-restful-swagger-2

manually updating pyproject.toml to flask-restful-swagger-2 = "^0.35" and rerunning install:

Installing dependencies from lock file
Warning: poetry.lock is not consistent with pyproject.toml. You may be getting improper dependencies. Run `poetry lock [--no-update]` to fix it.

Because poetry-test depends on flask-restful-swagger-2 (^0.35) which doesn't match any versions, version solving failed.

run with -vvv

$ poetry install -vvv
Loading configuration file /home/sam/.config/pypoetry/config.toml
Using virtualenv: /home/sam/.cache/pypoetry/virtualenvs/poetry-test-yR2o0HPF-py3.8
Project environment contains an empty path in sys_path, ignoring.
Installing dependencies from lock file
Warning: poetry.lock is not consistent with pyproject.toml. You may be getting improper dependencies. Run `poetry lock [--no-update]` to fix it.

Finding the necessary packages for the current system
Source (poetry-repo): 0 packages found for flask-restful-swagger-2 0.35
Falling back to installed packages to discover metadata for flask-restful-swagger-2
Found 0 compatible packages for flask-restful-swagger-2

  Stack trace:

  4  ~/.local/lib/python3.8/site-packages/poetry/puzzle/solver.py:151 in _solve
      149│ 
      150│         try:
    → 151│             result = resolve_version(
      152│                 self._package, self._provider, locked=locked, use_latest=use_latest
      153│             )

  3  ~/.local/lib/python3.8/site-packages/poetry/mixology/__init__.py:24 in resolve_version
       22│     solver = VersionSolver(root, provider, locked=locked, use_latest=use_latest)
       23│ 
    →  24│     return solver.solve()
       25│ 

  2  ~/.local/lib/python3.8/site-packages/poetry/mixology/version_solver.py:126 in solve
      124│             next: str | None = self._root.name
      125│             while next is not None:
    → 126│                 self._propagate(next)
      127│                 next = self._choose_package_version()
      128│ 

  1  ~/.local/lib/python3.8/site-packages/poetry/mixology/version_solver.py:165 in _propagate
      163│                     # where that incompatibility will allow us to derive new assignments
      164│                     # that avoid the conflict.
    → 165│                     root_cause = self._resolve_conflict(incompatibility)
      166│ 
      167│                     # Back jumping erases all the assignments we did at the previous

  SolveFailure

  Because poetry-test depends on flask-restful-swagger-2 (0.35) which doesn't match any versions, version solving failed.

  at ~/.local/lib/python3.8/site-packages/poetry/mixology/version_solver.py:364 in _resolve_conflict
      360│             )
      361│             self._log(f'! which is caused by "{most_recent_satisfier.cause}"')
      362│             self._log(f"! thus: {incompatibility}")
      363│ 
    → 364│         raise SolveFailure(incompatibility)
      365│ 
      366│     def _choose_package_version(self) -> str | None:
      367│         """
      368│         Tries to select a version of a required package.

The following error occurred when trying to handle this error:


  Stack trace:

  11  ~/.local/lib/python3.8/site-packages/cleo/application.py:329 in run
       327│ 
       328│             try:
     → 329│                 exit_code = self._run(io)
       330│             except Exception as e:
       331│                 if not self._catch_exceptions:

  10  ~/.local/lib/python3.8/site-packages/poetry/console/application.py:185 in _run
       183│         self._load_plugins(io)
       184│ 
     → 185│         exit_code: int = super()._run(io)
       186│         return exit_code
       187│ 

   9  ~/.local/lib/python3.8/site-packages/cleo/application.py:423 in _run
       421│             io.input.set_stream(stream)
       422│ 
     → 423│         exit_code = self._run_command(command, io)
       424│         self._running_command = None
       425│ 

   8  ~/.local/lib/python3.8/site-packages/cleo/application.py:465 in _run_command
       463│ 
       464│         if error is not None:
     → 465│             raise error
       466│ 
       467│         return event.exit_code

   7  ~/.local/lib/python3.8/site-packages/cleo/application.py:449 in _run_command
       447│ 
       448│             if event.command_should_run():
     → 449│                 exit_code = command.run(io)
       450│             else:
       451│                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

   6  ~/.local/lib/python3.8/site-packages/cleo/commands/base_command.py:119 in run
       117│         io.input.validate()
       118│ 
     → 119│         status_code = self.execute(io)
       120│ 
       121│         if status_code is None:

   5  ~/.local/lib/python3.8/site-packages/cleo/commands/command.py:83 in execute
        81│ 
        82│         try:
     →  83│             return self.handle()
        84│         except KeyboardInterrupt:
        85│             return 1

   4  ~/.local/lib/python3.8/site-packages/poetry/console/commands/install.py:146 in handle
       144│         self.installer.verbose(self.io.is_verbose())
       145│ 
     → 146│         return_code = self.installer.run()
       147│ 
       148│         if return_code != 0:

   3  ~/.local/lib/python3.8/site-packages/poetry/installation/installer.py:115 in run
       113│             self._execute_operations = False
       114│ 
     → 115│         return self._do_install()
       116│ 
       117│     def dry_run(self, dry_run: bool = True) -> Installer:

   2  ~/.local/lib/python3.8/site-packages/poetry/installation/installer.py:321 in _do_install
       319│ 
       320│         with solver.use_environment(self._env):
     → 321│             ops = solver.solve(use_latest=self._whitelist).calculate_operations(
       322│                 with_uninstalls=self._requires_synchronization,
       323│                 synchronize=self._requires_synchronization,

   1  ~/.local/lib/python3.8/site-packages/poetry/puzzle/solver.py:73 in solve
        71│         with self._provider.progress():
        72│             start = time.time()
     →  73│             packages, depths = self._solve(use_latest=use_latest)
        74│             end = time.time()
        75│ 

  SolverProblemError

  Because poetry-test depends on flask-restful-swagger-2 (0.35) which doesn't match any versions, version solving failed.

  at ~/.local/lib/python3.8/site-packages/poetry/puzzle/solver.py:159 in _solve
      155│             packages = result.packages
      156│         except OverrideNeeded as e:
      157│             return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
      158│         except SolveFailure as e:
    → 159│             raise SolverProblemError(e)
      160│ 
      161│         combined_nodes = depth_first_search(PackageNode(self._package, packages))
      162│         results = dict(aggregate_package_nodes(nodes) for nodes in combined_nodes)
      163│

Incidentally, ^0.20 is the latest of the package flask-restful-swagger (package name doesn't end in -2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/solverRelated to the dependency resolverkind/bugSomething isn't working as expectedstatus/confirmedIssue is reproduced and confirmedversion/1.2.2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions