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

Poetry overwrites package dependency when adding with different extras and different platform #6955

Closed
tbenthompson opened this issue Nov 3, 2022 · 3 comments
Labels
kind/question User questions (candidates for conversion to discussion)

Comments

@tbenthompson
Copy link

If I run:

poetry add "jax[cuda]" --platform linux

I get the attached pyproject.toml.

Afterwards, I run:

poetry add "jax[cpu]" --platform darwin

which causes the jax line in pyproject.toml to be overwritten with

jax = {extras = ["cpu"], version = "^0.3.23", platform = "darwin"}

deleting the linux platform-specific dependency.

I would have expected the Mac dependency to be included in addition to the existing Linux dependency.

Thanks!

Versions:

  • Poetry version: 1.2.2
  • Python version: 3.10.6
  • OS version and name: Ubuntu 22.04
  • pyproject.toml:
[tool.poetry]
name = "confirm"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = "~3.10"
numpy = "^1.23.4"
scipy = "^1.9.3"
typer = "^0.6.1"
jax = {extras = ["cuda"], version = "^0.3.23", platform = "linux"}
    
[tool.poetry.dev-dependencies]
jupyterlab = "^3.5.0"

[tool.poetry.group.test.dependencies]
pytest = "^7.2.0"
pre-commit = "^2.20.0"


[[tool.poetry.source]]
name = "jax"
url = "https://storage.googleapis.com/jax-releases/jax_cuda_releases.html"
default = false
secondary = false

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

@tbenthompson tbenthompson added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Nov 3, 2022
@neersighted
Copy link
Member

Not a bug; poetry add only handles simple constraints and does not manage multiple constraint versions. You should write out your platform-specific constraints by editing pyproject.toml.

@neersighted neersighted added kind/question User questions (candidates for conversion to discussion) and removed kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Nov 3, 2022
@tbenthompson
Copy link
Author

tbenthompson commented Nov 3, 2022

Thanks!

[UPDATE: the below does not actually work: #6956]

Just a note in case anyone finds this by searching. I was able to get I what I wanted with:

jax = [
    {extras = ["cpu"], version = "^0.3.23", platform = "darwin"},
    {extras = ["cuda"], version = "^0.3.23", platform = "linux"}
]

Without the extra = ["cpu"], I wasn't getting correct results. That is to say:

jax = [
    {version = "^0.3.23", platform = "darwin"},
    {extras = ["cuda"], version = "^0.3.23", platform = "linux"}
]

did not work even though pip install jax normally behaves identically to pip install jax[cpu]. I'm assuming that's probably some issue with how JAX specifies its dependencies.

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
kind/question User questions (candidates for conversion to discussion)
Projects
None yet
Development

No branches or pull requests

2 participants