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

url-dependency is missing from multiple-constraints-dependency #2033

Closed
3 tasks done
djlancelot opened this issue Feb 13, 2020 · 6 comments · Fixed by #2035 or python-poetry/poetry-core#32
Closed
3 tasks done
Labels
kind/bug Something isn't working as expected

Comments

@djlancelot
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: OSX 10.15.2 and Ubuntu

  • Poetry version: 1.0.2

  • Relevant part:

[tool.poetry.dependencies]
torch = [
        {url = "https://download.pytorch.org/whl/cpu/torch-1.4.0%2Bcpu-cp37-cp37m-linux_x86_64.whl", markers = "sys_platform == 'linux'"},
        {version="^1.4.0", markers = "sys_platform == 'darwin'"}
    ]

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

Issue

Hi there,
When I tried adding multiple constraints using an url dependency I got the following error message:

poetry install -vvv

[RuntimeError]
The Poetry configuration is invalid:
  - [dependencies.torch] [{u'url': u'https://download.pytorch.org/whl/cpu/torch-1.4.0%2Bcpu-cp37-cp37m-linux_x86_64.whl', u'markers': u"sys_platform == 'linux'"}, {u'version': u'^1.4.0', u'markers': u"sys_platform == 'darwin'"}] is not valid under any of the given schemas


Traceback (most recent call last):
  File "/Users/lancelot/.poetry/lib/poetry/_vendor/py2.7/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/Users/lancelot/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/Users/lancelot/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 163, in _do_handle
    self._dispatcher.dispatch(PRE_HANDLE, event)
  File "/Users/lancelot/.poetry/lib/poetry/_vendor/py2.7/clikit/api/event/event_dispatcher.py", line 22, in dispatch
    self._do_dispatch(listeners, event_name, event)
  File "/Users/lancelot/.poetry/lib/poetry/_vendor/py2.7/clikit/api/event/event_dispatcher.py", line 89, in _do_dispatch
    listener(event, event_name, self)
  File "/Users/lancelot/.poetry/lib/poetry/console/config/application_config.py", line 85, in set_env
    poetry = command.poetry
  File "/Users/lancelot/.poetry/lib/poetry/console/commands/command.py", line 10, in poetry
    return self.application.poetry
  File "/Users/lancelot/.poetry/lib/poetry/console/application.py", line 49, in poetry
    self._poetry = Factory().create_poetry(Path.cwd())
  File "/Users/lancelot/.poetry/lib/poetry/factory.py", line 54, in create_poetry
    raise RuntimeError('The Poetry configuration is invalid:
'" + message)

The dependency doesn't seem to be valid under any of the given schemas.

Possible reason

After looking at the source code I found that the schema descriptor file is missing the url-dependency from the list of values here:

"multiple-constraints-dependency": {

Possible solution

Add the url-dependency to the list of values for multiple constraints:

        "multiple-constraints-dependency": {
            "type": "array",
            "minItems": 1,
            "items": {
                "oneOf": [
                    {
                        "$ref": "#/definitions/dependency"
                    },
                    {
                        "$ref": "#/definitions/long-dependency"
                    },
                    {
                        "$ref": "#/definitions/git-dependency"
                    },
                    {
                        "$ref": "#/definitions/file-dependency"
                    },
                    {
                        "$ref": "#/definitions/path-dependency"
                    },
                    {
                        "$ref": "#/definitions/url-dependency"
                    }
                ]
            }
        },

Let me know what you think.

@djlancelot djlancelot added the kind/bug Something isn't working as expected label Feb 13, 2020
@djlancelot
Copy link
Author

Added PR for fix: #2035

@lejafar
Copy link

lejafar commented Mar 9, 2020

@djlancelot When I run this pyproject.toml it still fails (I'm on macos), does it work for you?

[tool]

[tool.poetry]
name = "torch_test"
version = "1.0.0"
description = ""
authors = [""]

[tool.poetry.dependencies]
torch = [
        {url = "https://download.pytorch.org/whl/cpu/torch-1.4.0%2Bcpu-cp37-cp37m-linux_x86_64.whl", markers = "sys_platform == 'linux'"},
        {version="^1.4.0", markers = "sys_platform == 'darwin'"}
    ]

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
$ python -c "import sys; print(sys.platform)"
darwin
$ poetry --version
Poetry version 1.0.5
$ poetry install -vvv
Using virtualenv: /Users/lejafar/Library/Caches/pypoetry/virtualenvs/torch-test-Zhr66SfZ-py3.7
Updating dependencies
Resolving dependencies...
   1: fact: torch-test is 1.0.0
   1: derived: torch-test
   0: Duplicate dependencies for torch
   0: Different requirements found for torch (*) and torch (^1.4.0).
   1: Version solving took 0.003 seconds.
   1: Tried 1 solutions.
   0: Retrying dependency resolution for Python (>=2.7,<2.8 || >=3.4).
   1: fact: torch-test is 1.0.0
   1: derived: torch-test
   0: Duplicate dependencies for torch
   0: Different requirements found for torch (*) and torch (^1.4.0).
   1: Version solving took 0.002 seconds.
   1: Tried 1 solutions.
   0: Retrying dependency resolution for Python (>=2.7,<2.8 || >=3.4).
   1: fact: torch-test is 1.0.0
   1: derived: torch-test
   0: Duplicate dependencies for torch
   0: Different requirements found for torch (*) and torch (^1.4.0).
   1: Version solving took 0.003 seconds.
   1: Tried 1 solutions.
   0: Retrying dependency resolution for Python (>=2.7,<2.8 || >=3.4).
   1: fact: torch-test is 1.0.0
   1: derived: torch-test
   0: Duplicate dependencies for torch
   0: Different requirements found for torch (*) and torch (^1.4.0).
...
[RecursionError]
maximum recursion depth exceeded while calling a Python object

Traceback (most recent call last):
  File "/Users/lejafar/.poetry/lib/poetry/_vendor/py3.7/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/Users/lejafar/.poetry/lib/poetry/_vendor/py3.7/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/Users/lejafar/.poetry/lib/poetry/_vendor/py3.7/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/Users/lejafar/.poetry/lib/poetry/_vendor/py3.7/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/Users/lejafar/.poetry/lib/poetry/console/commands/install.py", line 63, in handle
    return_code = installer.run()
  File "/Users/lejafar/.poetry/lib/poetry/installation/installer.py", line 74, in run
    self._do_install(local_repo)
  File "/Users/lejafar/.poetry/lib/poetry/installation/installer.py", line 161, in _do_install
    ops = solver.solve(use_latest=self._whitelist)
  File "/Users/lejafar/.poetry/lib/poetry/puzzle/solver.py", line 36, in solve
    packages, depths = self._solve(use_latest=use_latest)
  File "/Users/lejafar/.poetry/lib/poetry/puzzle/solver.py", line 187, in _solve

@AlexJoz
Copy link

AlexJoz commented Apr 11, 2020

@lejafar did you manage to fix it?

@djlancelot I have pretty much the same on Catalina 10.15.4

@lejafar
Copy link

lejafar commented Apr 11, 2020

No I didn't :/

@djlancelot
Copy link
Author

@lejafar , @AlexJoz There are multiple issues with the URL dependency, although you can specify it from 1.0.5, it will still fail. We ended up doing something completely different, but I tried to solve this for you and this is why it breaks:

I noticed that the maximum recursion depth exceeded while calling a Python object is due to the fact that poetry doesn't resolve the version from the URL dependency, so the two incompatible versions are fighting with each other. I tried fixing it by adding both as URL dependency:

[tool]

[tool.poetry]
name = "torch_test"
version = "1.0.0"
description = ""
authors = [""]

[tool.poetry.dependencies]
python = "^3.7"
torch = [
        {url = "https://download.pytorch.org/whl/cpu/torch-1.4.0%2Bcpu-cp37-cp37m-linux_x86_64.whl", "platform" = "linux"},
        {url = "https://download.pytorch.org/whl/cpu/torch-1.4.0-cp37-none-macosx_10_9_x86_64.whl",  "platform" = "darwin"}
    ]

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

However, it turned out that the URL dependency supports just a few properties and python markers or platform is not one of them. Until those parameters are added platform based dependencies will only work with simple packages ( you can try having a private pypi repo with the Linux wheel and downloading the dependencies from there, that should work ).

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