question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Picking wrong platform installing a dependency with multiple constraints

See original GitHub issue
  • I am on the 1.0.5 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

Markers are not working properly with multiple constraints dependencies as stated in the docs

I am trying to install a dependency from an URL based on the platform, different URLs for every platform (markers = "sys_platform == 'linux'") and poetry is picking the URL from the platform darwin when I’m under a linux platform

I have not tested yet what happens on a Darwin platform. Will update the issue when I do

Update:

If I reverse the order of the dependencies, the first line the darwin url, it works on Linux. The same behaviour applies on Darwin

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:27 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
abncommented, Mar 8, 2020

@leon19 try chaging it to the following (this is only a partial workaround - see below).

guildai = [
  {url = "https://files.pythonhosted.org/packages/10/ed/ffc1a004da1a272131e776f4b1d24d980b1dbb25b3bbaea4aff5ff7ef538/guildai-0.7.0rc7-cp37-cp37m-manylinux1_x86_64.whl", platform = "linux"},
  {url = "https://files.pythonhosted.org/packages/17/bc/2bc49e33d9343e689723c0b67aa45653d79fc4b5342c12bd7836aca58e7b/guildai-0.7.0rc7-cp37-cp37m-macosx_10_14_x86_64.whl", platform = "darwin"}
]

This will work if you are on a linux environment. I did notice that the generated lockfile will only contain the first specified url (in this case command will succeed since I was working on a linux machine and linux platform was specified first). If I were to change the order, it will fail again. However, when building the wheel generated the correct metadata.

Requires-Dist: guildai @ https://files.pythonhosted.org/packages/10/ed/ffc1a004da1a272131e776f4b1d24d980b1dbb25b3bbaea4aff5ff7ef538/guildai-0.7.0rc7-cp37-cp37m-manylinux1_x86_64.whl; sys_platform == "linux"
Requires-Dist: guildai @ https://files.pythonhosted.org/packages/17/bc/2bc49e33d9343e689723c0b67aa45653d79fc4b5342c12bd7836aca58e7b/guildai-0.7.0rc7-cp37-cp37m-macosx_10_14_x86_64.whl; sys_platform == "darwin"

From what I can tell, when markers are explicitly used the constraints get populated differently.

Issue 1: This pertains to the use of “url”. When duplicate dependencies are being merged, url and markers are ignored resulting in only the first entry to be used (in this case the linux url). Ideally, the dependency graph should be branched due to the existance of the platform marker and the url should be considered when merging duplicates.

Additionally, during investigation, I had a quick look at how this was being processed. It did raise a few questions (which might be separate issue(s) to be dealt with).

When markers are explicitly provided (eg: markers = "sys_platform == 'win32'", python = ">=3.6");

Issue 2: the python version specified is ignored if markers are explicitly specified (unsure if this is expected behaviour). https://github.com/python-poetry/poetry/blob/ae6d64ded40bea9019f7e1de229cd0b360d65e70/poetry/packages/package.py#L349-L359

Issue 3: sole use of markers causes solver to be stuck in an infinite loop. As an example, this works.

pypiwin32 = [
    { version = "220", platform = "win32", python = ">=3.6"},
    { version = "219", platform = "win32", python = "<3.6"}
]

However, this causes an infinite loop.

pypiwin32 = [
    { version = "220", markers = "sys_platform == 'win32' and python_version >= '3.6'"},
    { version = "219", markers = "sys_platform == 'win32' and python_version < '3.6'"}
]

@finswimmer would be good to get your thoughts on the above.

7reactions
Leon0402commented, Dec 17, 2020

I tried several combinations and none worked. Among the things I tried were the following things:

torch = [
    {url = "https://download.pytorch.org/whl/cu102/torch-1.6.0-cp38-cp38-win_amd64.whl", python = "~3.8", markers = "sys_platform == 'win32'" },
    {version = "1.6.0", markers = "sys_platform != 'win32'" }
]
torch = [
    {url = "https://download.pytorch.org/whl/cu102/torch-1.6.0-cp38-cp38-win_amd64.whl", python = "~3.8", platform = "win32" },
    {version = "1.6.0", platform = "linux || darwin" }
]

I tried both and similar variations of the two above with poetry 1.1.0, 1.1.1, 1.1.2, 1.1.3 and 1.1.4

In all cases, the first entry was always used no matter what platform I was on. So on Linux it downloaded the windows wheel. And On Windows, if you changed the order, it took the instructions for linux / mac os.

Could be clarified how exactly this should work and with what poetry versions in specific. So far it failed with all versions, so I’m slightly confused why this issue has been marked as resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cabal install error with conflicting constraints - Stack Overflow
So right now I'm trying to run cabal install --lib bytestring , seems simple enough. But every time I run this I get...
Read more >
Adding and Updating Software in Oracle® Solaris 11.3
A constraint package specifies which versions of packages can be installed. These version constraints help keep the system in a supportable state across ......
Read more >
Dependency specification | Documentation | Poetry - Python ...
Version constraints Caret requirements Caret requirements allow SemVer compatible updates to a ... For instance, if we previously ran poetry add requests@^2.
Read more >
Dependency Resolution - pip documentation v22.3.1
pip is capable of determining and installing the dependencies of packages. The process of determining which version of a dependency to install is...
Read more >
Upgrading versions of transitive dependencies
Direct dependencies vs dependency constraints ... A component may have two different kinds of dependencies: ... It's quite common that issues with dependency...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found