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

pixi add --pypi -p <platform> inconsistent between pixi.toml and pyproject.toml #2149

Closed
2 tasks done
escalonn opened this issue Sep 27, 2024 · 5 comments
Closed
2 tasks done
Labels
🐞 bug Something isn't working pyproject 🗒️ configuration Issue related to configuration of project or global behavior 👋 good first issue Good for newcomers

Comments

@escalonn
Copy link

escalonn commented Sep 27, 2024

Checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

Tested on 0.28 since it's the latest on winget

pixi add --pypi -p win-64 AssertWT

Issue description

With pixi.toml, that command adds the package to target.win-64.pypi-dependencies as expected.

[target.win-64.pypi-dependencies]
assertwt = ">=2.3.1, <3"

But with pyproject.toml, it adds the package to project.dependencies, without any environment marker.

[project]
dependencies = ["assertwt>=2.3.1,<3"]

In both scenarios, the same shell output was shown:

✔ Added AssertWT
Added these as pypi-dependencies.
Added these only for platform(s): win-64

Expected behavior

The behavior should be consistent between pixi.toml and pyproject.toml scenarios or else raise an error. The shell output shouldn't claim that the dependencies were added as platform-specific when they were not.

Possibilities:

  1. Pixi should have a documented translation from Pixi/Conda platform identifiers to PEP 508 environment markers, and use that translation to write to project.dependencies (Add Environment Markers to pypi-dependencies specification #1259)
  2. Pixi should make the --platform and --pypi options mutually exclusive for pyproject.toml projects, and direct users to write the environment markers themselves (e.g. pixi add --pypi 'AssertWT;platform_system=="Windows"' seems to work correctly, though I don't think pixi actually uses that marker yet)
  3. Pixi should write to tool.pixi.target.win-64.pypi-dependencies in this scenario
@escalonn
Copy link
Author

(thanks, pixi devs, for finally fixing python after 30 years)

@ruben-arts
Copy link
Contributor

Thank you @escalonn, great write up!

You correctly identified this as a bug. For now I would fix this with option 3, using the [tool.pixi.target. table prefix. But we should get the environment markers working to in the near future!

Note

If anyone is up to the job before we get to it feel free to make a PR. It should be a good first timer issue!

@ruben-arts ruben-arts added 🐞 bug Something isn't working 👋 good first issue Good for newcomers 🗒️ configuration Issue related to configuration of project or global behavior pyproject labels Sep 30, 2024
@olivier-lacroix
Copy link
Contributor

@escalonn good catch... adding the markers automatically would be pretty cool !

@thomas-maschler
Copy link

thomas-maschler commented Oct 18, 2024

I also ran into that issue and noticed that pypi dependencies for target platforms are not included in the wheel when trying to create a distribution. (I built the wheel with hatch build)

When using the project.dependencies in pyproject.toml the notation should be like

[ project ]
...
dependencies = [
    'tensorflow>=2.14.0,<2.15 ; sys_platform == "linux"',
    'tensorflow-macos>=2.14.0,<2.15 ; sys_platform == "darwin"'
]

This notation isn't correctly interpreted by pixi. It still tries to install all dependencies for all platforms

pixi install
  × failed to solve the pypi requirements of 'default' 'linux-64'
  ├─▶ failed to resolve pypi dependencies
  ╰─▶ Because only the following versions of tensorflow-macos are available:
          tensorflow-macos<=2.14.0
          tensorflow-macos==2.14.1
          tensorflow-macos>2.15
      and tensorflow-macos>=2.14.0,<=2.14.1 has no wheels with a matching Python implementation tag, we can conclude that tensorflow-macos>=2.14.0,<2.14.1 cannot be used.
      And because you require tensorflow-macos>=2.14.0,<2.15, we can conclude that your requirements are unsatisfiable.

@olivier-lacroix
Copy link
Contributor

I believe this issue can be closed, thanks to #2448

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working pyproject 🗒️ configuration Issue related to configuration of project or global behavior 👋 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants