Skip to content

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

@chunyang

Description

@chunyang
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions