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

Version Parse error #4095

Closed
3 tasks done
aviramha opened this issue May 24, 2021 · 9 comments
Closed
3 tasks done

Version Parse error #4095

aviramha opened this issue May 24, 2021 · 9 comments

Comments

@aviramha
Copy link
Contributor

  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: All Platforms

  • Poetry version: 1.2.1a

Issue

Python constraints issues happens when installing aiopika with weird python specifications - poetry add aiopika

  Stack trace:

  3  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/semver/helpers.py:137 in parse_single_constraint
      135│ 
      136│         try:
    → 137│             version = Version.parse(version)
      138│         except ValueError:
      139│             raise ValueError(

  2  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/version/pep440/version.py:134 in parse
      132│         from poetry.core.version.pep440.parser import parse_pep440
      133│ 
    → 134│         return parse_pep440(value, cls)
      135│ 
      136│     def is_prerelease(self) -> bool:

  1  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/version/pep440/parser.py:88 in parse_pep440
       86│     value: str, version_class: Optional[Type["PEP440Version"]] = None
       87│ ) -> "PEP440Version":
    →  88│     return PEP440Parser.parse(value, version_class)
       89│ 

  InvalidVersion

  Invalid PEP 440 version: '3.5.'

  at ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/version/pep440/parser.py:67 in parse
       63│     @classmethod
       64│     def parse(cls, value: str, version_class: Optional[Type["PEP440Version"]] = None):
       65│         match = cls._regex.search(value) if value else None
       66│         if not match:
    →  67│             raise InvalidVersion(f"Invalid PEP 440 version: '{value}'")
       68│ 
       69│         if version_class is None:
       70│             from poetry.core.version.pep440.version import PEP440Version
       71│ 

The following error occurred when trying to handle this error:


  Stack trace:

  21  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/application.py:314 in run
       312│ 
       313│             try:
     → 314│                 exit_code = self._run(io)
       315│             except Exception as e:
       316│                 if not self._catch_exceptions:

  20  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/console/application.py:167 in _run
       165│         self._load_plugins(io)
       166│ 
     → 167│         return super()._run(io)
       168│ 
       169│     def _configure_io(self, io: IO) -> None:

  19  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/application.py:409 in _run
       407│                 io.set_input(ArgvInput(argv))
       408│ 
     → 409│         exit_code = self._run_command(command, io)
       410│         self._running_command = None
       411│ 

  18  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/application.py:451 in _run_command
       449│ 
       450│         if error is not None:
     → 451│             raise error
       452│ 
       453│         return event.exit_code

  17  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/application.py:435 in _run_command
       433│ 
       434│             if event.command_should_run():
     → 435│                 exit_code = command.run(io)
       436│             else:
       437│                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

  16  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/commands/base_command.py:118 in run
       116│         io.input.validate()
       117│ 
     → 118│         status_code = self.execute(io)
       119│ 
       120│         if status_code is None:

  15  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/commands/command.py:85 in execute
        83│ 
        84│         try:
     →  85│             return self.handle()
        86│         except KeyboardInterrupt:
        87│             return 1

  14  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/console/commands/add.py:189 in handle
       187│             self._installer.whitelist([r["name"] for r in requirements])
       188│ 
     → 189│             status = self._installer.run()
       190│         except BaseException:
       191│             # Using BaseException here as some exceptions, eg: KeyboardInterrupt, do not inherit from Exception

  13  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/installation/installer.py:112 in run
       110│         local_repo = Repository()
       111│ 
     → 112│         return self._do_install(local_repo)
       113│ 
       114│     def dry_run(self, dry_run: bool = True) -> "Installer":

  12  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/installation/installer.py:252 in _do_install
       250│             )
       251│ 
     → 252│             ops = solver.solve(use_latest=self._whitelist)
       253│         else:
       254│             self._io.write_line("Installing dependencies from lock file")

  11  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/puzzle/solver.py:99 in solve
        97│         with self._provider.progress():
        98│             start = time.time()
     →  99│             packages, depths = self._solve(use_latest=use_latest)
       100│             end = time.time()
       101│ 

  10  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/puzzle/solver.py:270 in _solve
       268│ 
       269│         try:
     → 270│             result = resolve_version(
       271│                 self._package, self._provider, locked=locked, use_latest=use_latest
       272│             )

   9  ~/Library/Application Support/pypoetry/venv/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│ 

   8  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/mixology/version_solver.py:82 in solve
        80│             while next is not None:
        81│                 self._propagate(next)
     →  82│                 next = self._choose_package_version()
        83│ 
        84│             return self._result()

   7  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/mixology/version_solver.py:394 in _choose_package_version
       392│             version = locked
       393│ 
     → 394│         version = self._provider.complete_package(version)
       395│ 
       396│         conflict = False

   6  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/puzzle/provider.py:445 in complete_package
       443│             package = DependencyPackage(
       444│                 package.dependency,
     → 445│                 self._pool.package(
       446│                     package.name,
       447│                     package.version.text,

   5  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/repositories/pool.py:143 in package
       141│             for idx, repo in enumerate(self._repositories):
       142│                 try:
     → 143│                     package = repo.package(name, version, extras=extras)
       144│                 except PackageNotFound:
       145│                     continue

   4  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/repositories/pypi_repository.py:165 in package
       163│         extras: (Union[list, None]) = None,
       164│     ) -> Package:
     → 165│         return self.get_release_info(name, version).to_package(name=name, extras=extras)
       166│ 
       167│     def search(self, query: str) -> List[Package]:

   3  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/inspection/info.py:151 in to_package
       149│         package.description = self.summary
       150│         package.root_dir = root_dir
     → 151│         package.python_versions = self.requires_python or "*"
       152│         package.files = self.files
       153│ 

   2  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/packages/package.py:233 in python_versions
       231│     def python_versions(self, value: str) -> None:
       232│         self._python_versions = value
     → 233│         self._python_constraint = parse_constraint(value)
       234│         self._python_marker = parse_marker(
       235│             create_nested_marker("python_version", self._python_constraint)

   1  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/semver/helpers.py:33 in parse_constraint
        31│         if len(and_constraints) > 1:
        32│             for constraint in and_constraints:
     →  33│                 constraint_objects.append(parse_single_constraint(constraint))
        34│         else:
        35│             constraint_objects.append(parse_single_constraint(and_constraints[0]))

  ValueError

  Could not parse version constraint: >3.5.*

  at ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/semver/helpers.py:139 in parse_single_constraint
      135│ 
      136│         try:
      137│             version = Version.parse(version)
      138│         except ValueError:
    → 139│             raise ValueError(
      140│                 "Could not parse version constraint: {}".format(constraint)
      141│             )
      142│ 
      143│         if op == "<":
@aviramha aviramha added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels May 24, 2021
@albireox
Copy link

I'm seeing the same issue with 1.2.0a1. Both aio_pika and aiormq fail because of this error.

@abn
Copy link
Member

abn commented May 30, 2021

Is >3.5.* a valid PEP 345 specification?

$ curl -sL https://pypi.org/pypi/aio-pika/json | jq -r .info.requires_python
>3.5.*, <4

Seems PEP 345 Requires-Python section indicates that the value must be a valid Version Specifiers. This inturn expects this to be PEP 440. Which this is not afaict.

EIther poetry needs to relax the checks (which might cause unintended side-effects) or the project should use >3.5,<4.

@albireox
Copy link

I'm not very familiar with the version PEPs, but it seems excluding versions is very frequent, for example

python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"

so one would expect other inequalities would also be allowed. I can open an issue for the aio-pika people, but if poetry starts enforcing this version parsing, 1.2.x will become unusable for many of us.

@abn
Copy link
Member

abn commented May 31, 2021

I don't think the != operator is in question here, the issue is with >. Using a wild card does not make sense there and it is not, as per spec iiuc. I'll check the aio-pika package see how the pypi metadata is being generated.

@finswimmer
Copy link
Member

Closing this, because it's not poetry issue.

(Hopefully they will fix it upstream, because I'm using this packages as well)

@aviramha
Copy link
Contributor Author

aviramha commented Jun 4, 2021

@finswimmer can we consider maybe adding an ignore flag ? or being less strict with a warning period? This change is ofc good but it causes real issues that restricts many developers from updating to the new poetry version.

@ITProKyle
Copy link
Contributor

@finswimmer - seconding the above comment. While being more strict with versioning is great for the entirety of the python community, it is going to make the new release of poetry unusable in many circumstances as some python packages will become unusable.

I ran into this issue with yamllint defining their python version requirement as >=3.5.*.

Poetry should try to make an assumption in cases like this but log a waning about potential issues. Ideally, it would also provide a link to get more info about what is incorrect, why its incorrect, and how to fix it so that poetry users can submit PRs to slowly resolve these issue across the board.

Something that I would like to see in the next prerelease of poetry (if it has not been done already) is a better error when this issue is encountered. Right now, if I start using poetry 1.2.0a1 after using 1.1.6, it will result in the ValueError and show what version specification is incorrect but it does not show what package it belongs to. I just had to go through and poetry add <package> each of my project's dependencies to be able to find which one needed to be fixed.

adrienverge pushed a commit to adrienverge/yamllint that referenced this issue Jun 10, 2021
According to PEP 345 Requires-Python
(https://www.python.org/dev/peps/pep-0345/#requires-python), the value
of this field must be a valid Version Specifier
(https://www.python.org/dev/peps/pep-0345/#version-specifiers). Which
in turn expects this to comply with PEP 440
(https://www.python.org/dev/peps/pep-0440/).

While not an issue for those that directly use `pip`, this will cause
issues for `poetry` users in the next release (if their current stance
is maintained). Discussion of the issue and there stance can be found
here: python-poetry/poetry#4095.
@aviramha
Copy link
Contributor Author

aviramha commented Jun 13, 2021

Created a new issue for this as it seems unanswered here #4176 .

Copy link

github-actions bot commented Mar 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants