-
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
Poetry ignores platform constraint when using local path #2765
Comments
@M-J-Murray can you try this with the current pre-release or |
@abn I installed poetry using: |
Sorry for the delay in response. That installs the latest available release. Which right now is |
I have the same problem with multiple constraints. [tool.poetry.dependencies]
python = ">=3.8,<3.9"
numpy = [
{ version = "^1.19.4", platform = "linux" },
{ path = "wheels/numpy-1.19.4+mkl-cp38-cp38-win_amd64.whl", platform = "windows" },
] On Linux I get an error:
On Windows it works, but created lock file will be broken on Linux platform:
I tried to install the same project on WSL in the same project directory with the lock file created on Windows. Poetry is trying to install win_amd64 wheel file on Linux:
It seems to me that this because the lock file does not contain any info about platform marker. The lock file is not cross-platform without platform markers. I'm using Poetry 1.1.4 |
This is still an issue with poetry 1.1.7 |
This issue appears to still exist on 1.1.11. |
This is still happening on 1.2.1 I'm trying to have Poetry lock a single Using a local wheel solves this neatly, but then we run into this bug. My current solution isn't nice, but it works at least: pre-commit executes a Python script immediately after Maybe this will help someone, or help to create a reproducible example? |
@radoering any chance you want to take a whack at this? Looks like another issue around markers and multiple constraint dependencies when using direct origin deps. |
I can't reproduce this yet. In general, the markers are not required in the lockfile to choose the correct version for installation. @john-sandall Can you share your pyproject.toml and poetry.lock? (That should be more helpful to reproduce the issue.) By the way, I noticed that some posts in this issue declare a platform constraint that doesn't make sense. On Windows |
I am running into this on Windows 11. Building our docker image was building wheels for hdbscan so we built it ourselves. It should fall to 0.8.28 on windows, and that works ( This is what our pyproject.toml looks like.
I verified with |
@billfreeman44 your issue is different -- this issue is specifically for path dependencies, not URL dependencies. That being said, the following works as expected on every platform for me -- I suspect your markers are just slightly off: [[tool.poetry.dependencies.hdbscan]]
python = "3.9"
markers = "platform_python_implementation == 'CPython' and sys_platform == 'linux' and platform_machine == 'x86_64'"
url = "https://github.com/rxfork/hdbscan/releases/download/0.8.28/hdbscan-0.8.28-cp39-cp39-linux_x86_64.whl"
[[tool.poetry.dependencies.hdbscan]]
python = "3.9"
markers = "platform_python_implementation == 'CPython' and sys_platform == 'linux' and platform_machine == 'aarch64'"
url = "https://github.com/rxfork/hdbscan/releases/download/0.8.28/hdbscan-0.8.28-cp39-cp39-linux_aarch64.whl"
[[tool.poetry.dependencies.hdbscan]]
markers = "python_version != '3.9' or sys_platform != 'linux'"
version = "0.8.28" If you need more help or advice, please start a Discussion, join Discord, or create a detailed issue report if you think there may be a bug. |
poetry considers that if a dependency doesn't specify its source, then any package with a compatible version is a candidate to meet that dependency, regardless of that package's source. So at install time on linux: poetry sees the dependency on numpy 1.19.4, and considers the package that points at the local wheel to be a perfectly valid choice. In effect the pyproject.toml had overlapping requirements for numpy, even though that wasn't what was intended. (In fact I also don't reproduce the reported problem today, but I reckon that's just because of a coincidence about the order in which poetry happens to store packages in the lockfile rather than because any actual fix has happened). So to deal with this you can explicitly specify the pypi source on the linux numpy dependency. That un-overlaps the constraints, they are now unambigously pointing at different things. Then at install time, poetry will be able to tell that the file package is not compatible with the pypi requirement, and do the right thing. Except that per #6710 this doesn't quite work today. Still, in principle that's a sensible answer - and reduces this one to being a duplicate of that one. |
To clarify, I was analysing this comment as being the same as #6710 The original is long fixed, if indeed it ever reproduced in the first place. |
I'm still having issues with this limitation. I'm linking to different paths on a shared drive that are mapped based on the base operating system and folder shares for the compute resources. These are compiled libraries wrapped using maturin.
When I try to resolve If I manually update the path on each host individually every time it works just fine, but I don't see why I should need to do that if there is the platform flag |
I can confirm that I’m also having issue with a combination of [tool.poetry.dependencies]
python = "3.8.*"
ids_peak = [
{markers = "platform_system == 'Windows'", path = "C:/Program Files/IDS/ids_peak/generic_sdk/api/binding/python/wheel/x86_64/ids_peak-1.5.0.0-cp38-cp38-win_amd64.whl"},
{markers = "platform_system == 'Linux'", path = "vendor/ids-peak_2.3.0.0-15823_amd64/local/share/ids/bindings/python/wheel/ids_peak-1.5.0.0-cp38-cp38-linux_x86_64.whl"},
] Where > poetry lock
Path /home/matthieu/git/ids-peak-python/C:/Program Files/IDS/ids_peak/generic_sdk/api/binding/python/wheel/x86_64/ids_peak-1.5.0.0-cp38-cp38-win_amd64.whl for ids_peak does not exist
Updating dependencies
Resolving dependencies... (0.0s)
Path /home/matthieu/git/ids-peak-python/C:/Program Files/IDS/ids_peak/generic_sdk/api/binding/python/wheel/x86_64/ids_peak-1.5.0.0-cp38-cp38-win_amd64.whl for ids_peak does not exist Poetry version: 1.4.1 |
@neersighted Could you look into this issue again since you closed it? The issue still pops up when I have a specification exactly like this. The pyproject.toml and lock file are provided. The attached lock file was generated in a Windows machine. Regardless of whether this file exists or not,
Updated: the poetry version I used was
|
Just to update, my reported case above happened in version 1.7.0 of Poetry. |
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. |
Issue
Hello,
I'm attempting to setup poetry such that a couple of local libraries are only installed when using windows. However, the platform argument is failing in two ways. When I use platform and path arguments on ubuntu, like so:
Even though I am not on windows, poetry keeps trying to install the library and failing because the install will only work on windows. As a workarounds I have tried:
But it keeps ignoring my platform requirement. I have a feeling the problem comes from the combination of path and platform markers.
The text was updated successfully, but these errors were encountered: