Invalid requirement, parse error at "'and ()'"
- [x] I am on the latest Poetry version.
- [x] I have searched the issues of this repo and believe that this is not a duplicate.
- [x] If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption).
- OS version and name: Ubuntu 18.04
- Poetry version: 1.0.0
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/chunyang/a084ce013da1bafb7988163b1dff57ec
Issue
I am unable to add apache-beam[gcp] as a dependency via
poetry add "apache-beam==2.16.0" --extras gcp -vvv
Attempting to do so gives the following error:
...
[InvalidRequirement]
Invalid requirement, parse error at "'and ()'"
Traceback (most recent call last):
File "/home/chuck.yang/.poetry/lib/poetry/_vendor/py2.7/clikit/console_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "/home/chuck.yang/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "/home/chuck.yang/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 171, in _do_handle
return getattr(handler, handler_method)(args, io, self)
File "/home/chuck.yang/.poetry/lib/poetry/_vendor/py2.7/cleo/commands/command.py", line 92, in wrap_handle
return self.handle()
File "/home/chuck.yang/.poetry/lib/poetry/console/commands/add.py", line 149, in handle
status = installer.run()
File "/home/chuck.yang/.poetry/lib/poetry/installation/installer.py", line 74, in run
self._do_install(local_repo)
File "/home/chuck.yang/.poetry/lib/poetry/installation/installer.py", line 225, in _do_install
ops = solver.solve(use_latest=whitelist)
File "/home/chuck.yang/.poetry/lib/poetry/puzzle/solver.py", line 36, in solve
packages, depths = self._solve(use_latest=use_latest)
File "/home/chuck.yang/.poetry/lib/poetry/puzzle/solver.py", line 181, in _solve
self._package, self._provider, locked=locked, use_latest=use_latest
File "/home/chuck.yang/.poetry/lib/poetry/mixology/__init__.py", line 7, in resolve_version
return solver.solve()
File "/home/chuck.yang/.poetry/lib/poetry/mixology/version_solver.py", line 80, in solve
next = self._choose_package_version()
File "/home/chuck.yang/.poetry/lib/poetry/mixology/version_solver.py", line 381, in _choose_package_version
for incompatibility in self._provider.incompatibilities_for(version):
File "/home/chuck.yang/.poetry/lib/poetry/puzzle/provider.py", line 528, in incompatibilities_for
for dep in dependencies
File "/home/chuck.yang/.poetry/lib/poetry/packages/package.py", line 394, in to_dependency
return dependency_from_pep_508(name)
File "/home/chuck.yang/.poetry/lib/poetry/packages/__init__.py", line 38, in dependency_from_pep_508
req = Requirement(name)
File "/home/chuck.yang/.poetry/lib/poetry/version/requirements.py", line 212, in __init__
requirement_string[e.loc : e.loc + 8]
The poetry.lock file has a few sections which may be implicated:
# ...
[[package]]
category = "main"
description = "google cloud datastore protobuf client"
marker = "python_version < \"3.0\" and ()"
name = "googledatastore"
optional = false
python-versions = "*"
version = "7.0.2"
# ...
[[package]]
category = "main"
description = "GRPC library for the Google Cloud Datastore API"
marker = "python_version < \"3.0\" and ()"
name = "proto-google-cloud-datastore-v1"
optional = false
python-versions = "*"
version = "0.90.4"
# ...
Rerunning the same command when the poetry.lock file already exists results in a slightly different error:
...
[ParseException]
Expected stringEnd, found u'a' (at char 23), (line:1, col:24)
Traceback (most recent call last):
File "/home/chuck.yang/.poetry/lib/poetry/_vendor/py2.7/clikit/console_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "/home/chuck.yang/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "/home/chuck.yang/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 171, in _do_handle
return getattr(handler, handler_method)(args, io, self)
File "/home/chuck.yang/.poetry/lib/poetry/_vendor/py2.7/cleo/commands/command.py", line 92, in wrap_handle
return self.handle()
File "/home/chuck.yang/.poetry/lib/poetry/console/commands/add.py", line 149, in handle
status = installer.run()
File "/home/chuck.yang/.poetry/lib/poetry/installation/installer.py", line 74, in run
self._do_install(local_repo)
File "/home/chuck.yang/.poetry/lib/poetry/installation/installer.py", line 139, in _do_install
locked_repository = self._locker.locked_repository(True)
File "/home/chuck.yang/.poetry/lib/poetry/packages/locker.py", line 117, in locked_repository
package.marker = parse_marker(info['marker'])
File "/home/chuck.yang/.poetry/lib/poetry/version/markers.py", line 649, in parse_marker
markers = _coerce_parse_result(MARKER.parseString(marker))
File "/home/chuck.yang/.poetry/lib/poetry/_vendor/py2.7/pyparsing.py", line 1945, in parseString
raise exc
The following pip command works fine:
pip install "apache-beam[gcp]==2.16.0"
Potentially related issue: https://github.com/python-poetry/poetry/issues/804
Seems to be the same symptom as #1728.
Same issue here on latest poetry, but just installing a simple package
$ poetry add kafka-python
Using version ^1.4.7 for kafka-python
Updating dependencies
Resolving dependencies... (86.5s)
Writing lock file
[InvalidRequirement]
Invalid requirement, parse error at "'and ()'"
Should be fixed by https://github.com/python-poetry/poetry/pull/2361
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.