-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Picking wrong platform installing a dependency with multiple constraints #2138
Comments
@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.
From what I can tell, when 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: Issue 2: the python version specified is ignored if poetry/poetry/packages/package.py Lines 349 to 359 in ae6d64d
Issue 3: sole use of markers causes solver to be stuck in an infinite loop. 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. |
@abn I tried using platform instead of markers as suggested but it still does not work for me Note: If I reverse the order of the dependencies, the first line the darwin url, it works on linux (I haven't tested on mac yet) |
@leon19 looks like it is non-deterministic. |
I have a similar problem.
but, judging from the
I've also asked a question on StackOverflow. |
@breki try this instead. python-ldap = [
{ platform = "linux", version = "*" },
{ platform = "win32'", path="lib/python_ldap-3.2.0-cp36-cp36m-win_amd64.whl" }
] |
any solution so far? I am having problem because of pyTorch. They did not release a windows package. And my dev env is a crappy windows, but my production env is linux. It is very hard to make my docker build to work with poetry. |
@abn or @eterna2 any new findings or workarounds for this issue? I am encountering the same behavior using multiple constraints for a package using git and path dependencies based on platform. The From my understanding, this is not the expected behavior, as multiple constraints dependencies are meant to allow for defining different locations for retrieving a given dependency. |
I have a similar issue. In my case, I need 3 different packages of mxnet, based on platform_machine and sys_platform.
The pyproject.toml section looks like this:
But the poetry solver returns an error:
|
I also get the |
I created issue #2613 for creating different variants (CPU/CUDA) for a project, which might possibly also help with some instances of this problem. |
This has been fixed in the
|
Thanks for your response @g4b1nagy . So I will close this. If anyone disagree please leave a comment. |
It looks like this may have regressed in 1.1.4 |
Hi, Having
does not work with Poetry v1.1.4 even if the condition returns true when using |
I do not think this is a valid markers notation. What error message, if any do you see? Should probably be the following instead:
|
@joshua-s |
@sinoroc I used "in" operator since sometimes I get "linux2" and at start I was looking for platform machine starting with "armv". But I could give a try to a more complex condition with only "==" matches. |
As far as I know, only exact comparison For
I think I would rather use |
OK, I tested a bit, and apparently the
but I would not recommend it:
|
I tried several combinations and none worked. Among the things I tried were the following things:
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. |
@sinoroc I ran: poetry export --without-hashes > requirements.txt Here's an excerpt from my [tool.poetry.dependencies]
python = "2.7.18 || ~3.7"
cryptography = [
{ version = "2.3.1", python = "<3" },
{ version = "~3.2", python = ">=3.7" },
] I received a requirements list with flags like this:
When attempting to pip install this, I get:
|
Don't see the issued get fixed in 1.1.4, I may try a lower version. |
@sinoroc about your answer: #2138 (comment) Even if the tests pass... I never succeeded making this working (to take in account
Instead of that, the following works:
I can't explain why but I'm fine with that for now :) |
Yeah, don't use the |
@finswimmer I'm running poetry 1.1.6, and it appears to still have problems resolving multiple constraints dependencies. Here's my dependencies spec: [tool.poetry.dependencies]
python = "^3.8"
torch = [
{ version = "^1.8.1", markers = "sys_platform == 'darwin'" },
{ url = "https://download.pytorch.org/whl/cu111/torch-1.8.1%2Bcu111-cp38-cp38-linux_x86_64.whl", markers = "sys_platform == 'linux'" },
] Given the above, when I run $ poetry install
Creating virtualenv poetry-test in [...]/poetry-test/.venv
Updating dependencies
Resolving dependencies... (112.3s)
SolverProblemError
Because poetry-test depends on torch (1.8.1+cu111) which doesn't match any versions, version solving failed.
at ~/.poetry/lib/poetry/puzzle/solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes Thoughts? |
@agurtovoy
After looking at
I'm no P.S. |
Now poetry 1.6.1 poetry has a good conception but finally I have to give up using it in platform sensetive projects. |
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. |
-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 platformdarwin
when I'm under alinux
platformI 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
The text was updated successfully, but these errors were encountered: