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

Invalid requirement, parse error at "'and ()'" #1772

Closed
3 tasks done
chunyang opened this issue Dec 19, 2019 · 4 comments · Fixed by #2361
Closed
3 tasks done

Invalid requirement, parse error at "'and ()'" #1772

chunyang opened this issue Dec 19, 2019 · 4 comments · Fixed by #2361
Labels
kind/bug Something isn't working as expected

Comments

@chunyang
Copy link

  • 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).

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: #804

@chunyang chunyang added the kind/bug Something isn't working as expected label Dec 19, 2019
@oliver-charlesworth
Copy link

Seems to be the same symptom as #1728.

@BakanovKirill
Copy link

BakanovKirill commented Jan 7, 2020

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 ()'"

@finswimmer
Copy link
Member

Should be fixed by #2361

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
4 participants