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 build creates package with platform marker not parseable: pkg_resources.RequirementParseError: Invalid requirement, parse error at "'sys_plat'" #2802

Closed
3 tasks done
daniel-j-h opened this issue Aug 12, 2020 · 3 comments · Fixed by python-poetry/poetry-core#60
Assignees
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) kind/bug Something isn't working as expected

Comments

@daniel-j-h
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).

  • OS version and name: Ubuntu 20.04 (container)

  • Poetry version: 10.1.10

  • Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/daniel-j-h/789f181c620a97d74f4731b42a88e073

Issue

Hey folks - here is my use case: I work in a self-contained ubuntu:20.04 docker container and want to add a remote wheel

poetry add --platform linux https://download.pytorch.org/whl/cpu/torch-1.5.1%2Bcpu-cp38-cp38-linux_x86_64.whl

This works fine, but when I then poetry build my package and try to install it (even e.g. with pip3) I get the parsing error stack trace attached below.

Small self-contained reproducible example is here: https://gist.github.com/daniel-j-h/789f181c620a97d74f4731b42a88e073

What works tho is leaving out the platform marker and installing with

poetry add https://download.pytorch.org/whl/cpu/torch-1.5.1%2Bcpu-cp38-cp38-linux_x86_64.whl

which semantically is wrong but at least the package then is installable.

When I unzip the wheel I get from poetry build, then in the METADATA file the platform marker looks like this

Requires-Dist: torch @ https://download.pytorch.org/whl/cpu/torch-1.5.1%2Bcpu-cp38-cp38-linux_x86_64.whl; sys_platform == "linux"

And here is the full stack trace when I try to install the package with platform marker

python@154ca81a64c9:~/app$ pip3 install dist/app-0.1.0-py3-none-any.whl 
Processing ./dist/app-0.1.0-py3-none-any.whl
ERROR: Exception:         
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3023, in _dep_map                              
    return self.__dep_map
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2817, in __getattr__
    raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map
                                                                      
During handling of the above exception, another exception occurred:
                                                                      
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/requirements.py", line 90, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/pyparsing.py", line 1654, in parseString
    raise exc
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/pyparsing.py", line 1644, in parseString
    loc, tokens = self._parse( instring, 0 )
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/pyparsing.py", line 1402, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/pyparsing.py", line 3417, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/pyparsing.py", line 1406, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/pyparsing.py", line 3205, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pkg_resources._vendor.pyparsing.ParseException: Expected stringEnd (at char 91), (line:1, col:92)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3103, in __init__
    super(Requirement, self).__init__(requirement_string)
  File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/requirements.py", line 92, in __init__
    raise InvalidRequirement(
pkg_resources.extern.packaging.requirements.InvalidRequirement: Invalid requirement, parse error at "'sys_plat'"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 186, in _main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 357, in run
    resolver.resolve(requirement_set)
  File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 177, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 382, in _resolve_one
    set(req_to_install.extras) - set(dist.extras)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2980, in extras
    return [dep for dep in self._dep_map if dep]
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3025, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3035, in _compute_dependencies
    reqs.extend(parse_requirements(req))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3096, in parse_requirements
    yield Requirement(line)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3105, in __init__
    raise RequirementParseError(str(e))
pkg_resources.RequirementParseError: Invalid requirement, parse error at "'sys_plat'"
@daniel-j-h daniel-j-h added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Aug 12, 2020
@finswimmer
Copy link
Member

Hello @daniel-j-h,

thanks a lot for reporting this 👍 The problem is/was that there must be a whitespace after the url. So
torch @ https://download.pytorch.org/whl/cpu/torch-1.5.1%2Bcpu-cp38-cp38-linux_x86_64.whl; sys_platform == "linux" must become torch @ https://download.pytorch.org/whl/cpu/torch-1.5.1%2Bcpu-cp38-cp38-linux_x86_64.whl ; sys_platform == "linux".

Fix is on the way: python-poetry/poetry-core#60

fin swimmer

@finswimmer finswimmer self-assigned this Aug 13, 2020
@finswimmer finswimmer removed the status/triage This issue needs to be triaged label Aug 13, 2020
@daniel-j-h
Copy link
Author

Wonderful, thank you for this amazingly quick fix! 🤗

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
area/build-system Related to PEP 517 packaging (see poetry-core) kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants