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

Solver tries to resolve dependencies not required on platform #2275

Closed
3 tasks done
ErikBjare opened this issue Apr 6, 2020 · 7 comments
Closed
3 tasks done

Solver tries to resolve dependencies not required on platform #2275

ErikBjare opened this issue Apr 6, 2020 · 7 comments
Labels
area/solver Related to the dependency resolver status/external-issue Issue is caused by external project (platform, dep, etc)

Comments

@ErikBjare
Copy link

ErikBjare commented Apr 6, 2020

  • 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'm trying to remove some unneeded dependencies from my project since they are no longer used (pypiwin32 and pyHook).

However, a dependency (PyUserInput) that is still needed on Linux depends on these two old dependencies, but only on Windows.

Since PyUserInput is only a dependency for Linux (selected with platform = "linux") I shouldn't need to install these other two dependencies on Windows anymore, yet the solver complains:

[SolverProblemError]
Because no versions of pyuserinput match !=0.1.12
 and pyuserinput (0.1.12) depends on pypiwin32 (*), every version of pyuserinput requires pypiwin32 (*).
So, because no versions of pypiwin32 match *
 and aw-watcher-afk depends on pyuserinput (*), version solving failed.

PR with changes here: ActivityWatch/aw-watcher-afk#39

Failing CI run here: https://github.com/ActivityWatch/aw-watcher-afk/pull/39/checks?check_run_id=564392363

@abn
Copy link
Member

abn commented Apr 6, 2020

This could be related to issue 1 identified in #2138 (comment).

@kasteph kasteph added the status/triage This issue needs to be triaged label Apr 13, 2020
@ErikBjare
Copy link
Author

ErikBjare commented Apr 19, 2020

I believe this should have the tag Dependency resolution.

Out of curiosity, I'd be interested to have a look at this myself (depending on how messy it may be). But I'm having a bit trouble trying to figure exactly where in

class Solver:
that the platform check should be made, so if anyone could point me in the right direction it'd be appreciated.

@finswimmer finswimmer added the area/solver Related to the dependency resolver label Apr 19, 2020
@abn
Copy link
Member

abn commented Apr 19, 2020

@ErikBjare the traceback with -vvv should provide an idea of the codepath.

The relevant block here could be

if not installed:
operations.append(Install(package))

The issue seems to be that poetry is requesting an install operation even if that package is not required. It could also be handled deeper in the Install logic too. Ideally, it should both skip the package and ensure that any unnecessary install/solve operation is not performed during instsall time.

@ErikBjare
Copy link
Author

I've taken a look at it and from my limited understanding of poetry it seems I should check the marker using Env.is_valid_for_marker and if not matched then skip the operation (not easily done from Solver, since an instance of Env is not accessible from there, as it probably shouldn't be).

I also obtained the verbose traceback:

[SolverProblemError]
Because no versions of pyuserinput match !=0.1.12
 and pyuserinput (0.1.12) depends on pypiwin32 (*), every version of pyuserinput requires pypiwin32 (*).
So, because no versions of pypiwin32 match *
 and aw-watcher-afk depends on pyuserinput (*), version solving failed.

Traceback (most recent call last):
  File "c:\hostedtoolcache\windows\python\3.6.8\x64\lib\site-packages\clikit\console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "c:\hostedtoolcache\windows\python\3.6.8\x64\lib\site-packages\clikit\api\command\command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "c:\hostedtoolcache\windows\python\3.6.8\x64\lib\site-packages\clikit\api\command\command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "c:\hostedtoolcache\windows\python\3.6.8\x64\lib\site-packages\cleo\commands\command.py", line 92, in wrap_handle
    return self.handle()
  File "c:\hostedtoolcache\windows\python\3.6.8\x64\lib\site-packages\poetry\console\commands\install.py", line 63, in handle
    return_code = installer.run()
  File "c:\hostedtoolcache\windows\python\3.6.8\x64\lib\site-packages\poetry\installation\installer.py", line 74, in run
    self._do_install(local_repo)
  File "c:\hostedtoolcache\windows\python\3.6.8\x64\lib\site-packages\poetry\installation\installer.py", line 225, in _do_install
    ops = solver.solve(use_latest=whitelist)
  File "c:\hostedtoolcache\windows\python\3.6.8\x64\lib\site-packages\poetry\puzzle\solver.py", line 36, in solve
    packages, depths = self._solve(use_latest=use_latest)
  File "c:\hostedtoolcache\windows\python\3.6.8\x64\lib\site-packages\poetry\puzzle\solver.py", line 190, in _solve
    raise SolverProblemError(e)

I traced the cause of the SolverProblemError to a SolveFailure being thrown in poetry/mixology/version_solver.py, which is too complicated for me to grok.

Right after the solver.solve is called in Installer._do_install the _filter_operations is called which would, as far as I can tell, successfully filter away the package by checking the marker.

Further guidance welcome.

@dimbleby
Copy link
Contributor

dimbleby commented Apr 18, 2022

The dependency from pyuserinput on pypiwin32 is via code in setup.py - https://github.com/PyUserInput/PyUserInput/blob/ac2d4c7a7f4b1a72e70b1a2ef8925d5312fb12bc/setup.py#L19

poetry tries its best to deal with such things, but can't always get it right. The preferred approach is to specify the dependency with pep508 markers.

If pyuserinput used markers for its requirements I expect this would all work out fine.

@Secrus Secrus removed the status/triage This issue needs to be triaged label May 16, 2022
@finswimmer
Copy link
Member

Closing this as an upstream issue, as explained by @dimbleby. Please contact the maintainer of this package and ask them to fix it.

@finswimmer finswimmer closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2022
@finswimmer finswimmer added status/external-issue Issue is caused by external project (platform, dep, etc) and removed kind/bug Something isn't working as expected labels Oct 21, 2022
Copy link

github-actions bot commented Mar 1, 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 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/solver Related to the dependency resolver status/external-issue Issue is caused by external project (platform, dep, etc)
Projects
None yet
Development

No branches or pull requests

6 participants