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

poetry search fails with ValueError: Unable to parse ".000001". #637

Closed
3 tasks done
DrPyser opened this issue Nov 16, 2018 · 9 comments
Closed
3 tasks done

poetry search fails with ValueError: Unable to parse ".000001". #637

DrPyser opened this issue Nov 16, 2018 · 9 comments
Labels
kind/bug Something isn't working as expected

Comments

@DrPyser
Copy link

DrPyser commented Nov 16, 2018

  • 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: archlinux
  • Poetry version: 0.12.8

Issue

When I try to run poetry search <name of my package>, I get an error:

[ValueError]   
Unable to parse ".000001".  
                              
Exception trace:
 /home/charles/.poetry/lib/poetry/_vendor/py3.7/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 /home/charles/.poetry/lib/poetry/console/application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 /home/charles/.poetry/lib/poetry/_vendor/py3.7/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 /home/charles/.poetry/lib/poetry/console/commands/command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)
 /home/charles/.poetry/lib/poetry/_vendor/py3.7/cleo/commands/base_command.py in run() at line 146
   status_code = self.execute(input_, output_)
 /home/charles/.poetry/lib/poetry/_vendor/py3.7/cleo/commands/command.py in execute() at line 107
   return self.handle()
 /home/charles/.poetry/lib/poetry/console/commands/search.py in handle() at line 20
   results = PyPiRepository().search(self.argument("tokens"), flags)
 /home/charles/.poetry/lib/poetry/repositories/pypi_repository.py in search() at line 207
   result = Package(hit["name"], hit["version"], hit["version"])
 /home/charles/.poetry/lib/poetry/packages/package.py in __init__() at line 40
   self._version = Version.parse(version)
 /home/charles/.poetry/lib/poetry/semver/version.py in parse() at line 200
   raise ValueError('Unable to parse "{}".'.format(text))

search [-N|--only-name] [--] <tokens> (<tokens>)...

The package I'm searching is mine, and is on a private repository. The problem is probably related to my package, since poetry search otherwise works with other packages(existing or not).

@sdispater
Copy link
Member

From the error you see, Poetry tries to parse a .000001 version which is not valid.

@DrPyser
Copy link
Author

DrPyser commented Nov 16, 2018

Right, and where does this version come from? My package version(the one I'm trying to install) is "0.0.1".

@sdispater
Copy link
Member

The search command does not search in private repositories, only on PyPI. So the package you are trying to search must exist on PyPI with a bad version.

@DrPyser
Copy link
Author

DrPyser commented Nov 16, 2018

Ok, well I assure you that it's not the case. pip search my-package-name confirms that. The package name is kioto-basic-utils, if you want to try for yourself.

@pspeter
Copy link

pspeter commented Mar 10, 2019

I have run into the same error on poetry version 0.12.11: Running the command poetry search beautifulsoup -vvv crashes with the error:

[ParseVersionError]
Unable to parse "rev452".

Exception trace:
 /home/peter/.poetry/lib/poetry/_vendor/py3.7/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 /home/peter/.poetry/lib/poetry/console/application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 /home/peter/.poetry/lib/poetry/_vendor/py3.7/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 /home/peter/.poetry/lib/poetry/console/commands/command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)
 /home/peter/.poetry/lib/poetry/_vendor/py3.7/cleo/commands/base_command.py in run() at line 146
   status_code = self.execute(input_, output_)
 /home/peter/.poetry/lib/poetry/_vendor/py3.7/cleo/commands/command.py in execute() at line 107
   return self.handle()
 /home/peter/.poetry/lib/poetry/console/commands/search.py in handle() at line 20
   results = PyPiRepository().search(self.argument("tokens"), flags)
 /home/peter/.poetry/lib/poetry/repositories/pypi_repository.py in search() at line 221
   result = Package(hit["name"], hit["version"], hit["version"])
 /home/peter/.poetry/lib/poetry/packages/package.py in __init__() at line 40
   self._version = Version.parse(version)
 /home/peter/.poetry/lib/poetry/semver/version.py in parse() at line 201
   raise ParseVersionError('Unable to parse "{}".'.format(text))

Seems like that command is quite brittle and crashes on packages using custom version strings. In this case, the package ElementSoup seems to be the culprit.

@pspeter
Copy link

pspeter commented Mar 15, 2019

@sdispater while I agree that .000001 is not a PEP 440 compliant version, it is still possible for packages on PyPi to have such invalid version strings, and it is unacceptable for poetry to just break when one pops up. I propose that packages with invalid versions should just be ignored and left out of the search results, which is also what PEP 440 recommends:

Installation tools SHOULD ignore any public versions which do not comply with this scheme but MUST also include the normalizations specified below.

@pspeter
Copy link

pspeter commented Aug 30, 2019

This bug is still not fixed in the newest release candidate 1.0.0b1.

@brycedrennan brycedrennan added the kind/bug Something isn't working as expected label Sep 1, 2019
@sztomi
Copy link
Contributor

sztomi commented Sep 2, 2019

This is a duplicate of #1346 (or rather, the latter is a duplicate of this one). I filed a PR to fix this.

sztomi added a commit to sztomi/poetry that referenced this issue Sep 8, 2019
Some packages (like `pygame-music-grid`) have unparseable metadata.
This resulted in a ValueError. pip ignores packages like these, so it's reasonable
to do the same in poetry itself and only display the well-formed ones.

Fixes python-poetry#1345.
Fixes python-poetry#637.
Copy link

github-actions bot commented Mar 3, 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 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

5 participants