Skip to content

Could not parse version constraint #7729

@clintonroy

Description

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

Issue

clintonr@rassilon:/tmp/tester$ poetry add super-state-machine
Using version ^2.0.2 for super-state-machine

Updating dependencies
Resolving dependencies... (0.0s)

Could not parse version constraint: < "3.4"

And the exception:

Loading configuration file /home/clintonr/.config/pypoetry/config.toml
Loading configuration file /home/clintonr/.config/pypoetry/auth.toml
Using virtualenv: /home/clintonr/.cache/pypoetry/virtualenvs/tester-HyYo8Z1h-py3.11
[keyring.backend] Loading KWallet
[keyring.backend] Loading SecretService
[keyring.backend] Loading Windows
[keyring.backend] Loading chainer
[keyring.backend] Loading libsecret
[keyring.backend] Loading macOS
Creating new session for pypi.org
Source (PyPI): 5 packages found for super-state-machine *
Using version ^2.0.2 for super-state-machine

Updating dependencies
Resolving dependencies...
   1: fact: tester is 0.1.0
   1: derived: tester
   1: fact: tester depends on super-state-machine (^2.0.2)
   1: selecting tester (0.1.0)
   1: derived: super-state-machine (>=2.0.2,<3.0.0)
Source (PyPI): 1 packages found for super-state-machine >=2.0.2,<3.0.0
   1: Version solving took 0.005 seconds.
   1: Tried 1 solutions.

  Stack trace:

  24  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/application.py:327 in run
       325│ 
       326│             try:
     → 327│                 exit_code = self._run(io)
       328│             except BrokenPipeError:
       329│                 # If we are piped to another process, it may close early and send a

  23  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/console/application.py:190 in _run
       188│         self._load_plugins(io)
       189│ 
     → 190│         exit_code: int = super()._run(io)
       191│         return exit_code
       192│ 
 22  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/application.py:431 in _run
       429│             io.input.interactive(interactive)
       430│ 
     → 431│         exit_code = self._run_command(command, io)
       432│         self._running_command = None
       433│ 

  21  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/application.py:473 in _run_command
       471│ 
       472│         if error is not None:
     → 473│             raise error
       474│ 
       475│         return terminate_event.exit_code

  20  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/application.py:457 in _run_command
       455│ 
       456│             if command_event.command_should_run():
     → 457│                 exit_code = command.run(io)
       458│             else:
       459│                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

  19  ~/.local/pipx/venvs/poetry/lib/python3.11/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:

  18  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/commands/command.py:62 in execute
        60│ 
        61│         try:
     →  62│             return self.handle()
        63│         except KeyboardInterrupt:
        64│             return 1

  17  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/console/commands/add.py:262 in handle
       260│         self.installer.whitelist([r["name"] for r in requirements])
       261│ 
     → 262│         status = self.installer.run()
       263│ 
       264│         if status == 0 and not self.option("dry-run"):
 16  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/installer.py:116 in run
       114│             self._execute_operations = False
       115│ 
     → 116│         return self._do_install()
       117│ 
       118│     def dry_run(self, dry_run: bool = True) -> Installer:

  15  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/installer.py:263 in _do_install
       261│                 source_root=self._env.path.joinpath("src")
       262│             ):
     → 263│                 ops = solver.solve(use_latest=self._whitelist).calculate_operations()
       264│         else:
       265│             self._io.write_line("Installing dependencies from lock file")

  14  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/puzzle/solver.py:74 in solve
        72│         with self._progress(), self._provider.use_latest_for(use_latest or []):
        73│             start = time.time()
     →  74│             packages, depths = self._solve()
        75│             end = time.time()
        76│ 

  13  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/puzzle/solver.py:157 in _solve
       155│ 
       156│         try:
     → 157│             result = resolve_version(self._package, self._provider)
       158│ 
       159│             packages = result.packages

  12  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/mixology/__init__.py:18 in resolve_version
        16│     solver = VersionSolver(root, provider)
        17│ 
     →  18│     return solver.solve()
        19│ 

  11  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/mixology/version_solver.py:112 in solve
       110│             while next is not None:
       111│                 self._propagate(next)
     → 112│                 next = self._choose_package_version()
       113│ 
       114│             return self._result()
10  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/mixology/version_solver.py:428 in _choose_package_version
       426│             package = locked
       427│ 
     → 428│         package = self._provider.complete_package(package)
       429│ 
       430│         conflict = False

   9  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/puzzle/provider.py:578 in complete_package
        576│                 dependency_package = DependencyPackage(
        577│                     dependency,
     →  578│                     self._pool.package(
        579│                         package.pretty_name,
        580│                         package.version,

   8  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/repositories/repository_pool.py:124 in package
       122│         for repo in self.repositories:
       123│             try:
     → 124│                 return repo.package(name, version, extras=extras)
       125│             except PackageNotFound:
       126│                 continue

   7  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/repositories/cached_repository.py:76 in package
        74│         extras: list[str] | None = None,
        75│     ) -> Package:
     →  76│         return self.get_release_info(canonicalize_name(name), version).to_package(
        77│             name=name, extras=extras
        78│         )

   6  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/inspection/info.py:198 in to_package
       196│             try:
       197│                 # Attempt to parse the PEP-508 requirement string
     → 198│                 dependency = Dependency.create_from_pep_508(req, relative_to=root_dir)
       199│             except InvalidMarker:
       200│                 # Invalid marker, We strip the markers hoping for the best

   5  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/packages/dependency.py:369 in create_from_pep_508
       367│                 name += " ;" + rest.split(" ;", 1)[1]
       368│ 
     → 369│         req = Requirement(name)
       370│ 
       371│         name = req.name

   4  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/version/requirements.py:83 in __init__
        81│         marker = next(parsed.find_data("marker_spec"), None)
        82│         if marker:
     →  83│             marker = _compact_markers(
        84│                 marker.children[0].children, tree_prefix="markers__"
        85│             )

   3  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/version/markers.py:789 in _compact_markers
       787│ 
       788│             value = value[1:-1]
     → 789│             sub_marker = SingleMarker(str(name), f"{op}{value}")
       790│             groups[-1].append(sub_marker)
       791│ 

   2  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/version/markers.py:259 in __init__
       257│                 constraint_string = glue.join(f"{op} {value}" for value in values)
       258│ 
     → 259│             self._constraint = self._parser(constraint_string)
       260│ 
       261│     @property

   1  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/constraints/generic/parser.py:36 in parse_constraint
        34│         if len(and_constraints) > 1:
        35│             for constraint in and_constraints:
     →  36│                 constraint_objects.append(parse_single_constraint(constraint))
        37│         else:
        38│             constraint_objects.append(parse_single_constraint(and_constraints[0]))

  ParseConstraintError

  Could not parse version constraint: < "3.4"

  at ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/core/constraints/generic/parser.py:67 in parse_single_constraint
       63│         version = m.group(2).strip()
       64│ 
       65│         return Constraint(version, op)
       66│ 
    →  67│     raise ParseConstraintError(f"Could not parse version constraint: {constraint}")
       68│ 

It used to just warn:

Using version ^2.0.2 for super-state-machine

Updating dependencies
Resolving dependencies... (0.0s)Invalid constraint (enum34; extra == ':python_version < "3.4"') found in super-state-machine-2.0.2 dependencies, skipping
Resolving dependencies... (0.1s)

Package operations: 2 installs, 0 updates, 0 removals

  • Installing six (1.16.0)
  • Installing super-state-machine (2.0.2)

Do we consider this a regression or not ?

This used to just be a warning under older versions:

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expectedstatus/triageThis issue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions