Skip to content

🐍 Install pypi dependencies in pixi environment. #175

Closed

Description

@ruben-arts

To improve pixi we are planning to add pip support, which actually means we can install packages from pypi.
Required steps:

  • Figure out how to support cross-platform installation of the packages from the pixi application.
  • Figure out how to install pypi packages reproducible using our lock-files.
  • Figure out how to configure the installation of those dependencies.

Activity

  1. changed the title [-]Install pip dependencies after prefix installation[/-] [+]Install pip dependencies in pixi environment.[/+] on Aug 9, 2023
  2. flying-sheep commented on Aug 20, 2023

    @flying-sheep

    Conda/Mamba’s big flaw here is that it just uses pip, i.e. it first resolves conda deps and then lets pip loose on the pre-populated environment to alter it as it sees fit. That means that

    1. dependency resolution can fail even though a valid solution might exist
    2. pip might download and install packages a second time because it needs to down/upgrade them to resolve dependencies

    Pixi could set itself apart by solving everything together and that way making these problems go away.

  3. baszalmstra commented on Aug 20, 2023

    @baszalmstra
    Contributor

    You are completely right. We have such a solution in the works as we speak!

  4. zmbc commented on Aug 21, 2023

    @zmbc

    I assume you are aware of conda-lock? They have tackled essentially the same problem, doing a single solve taking everything into account using a mapping of how PyPI packages correspond to conda packages.

  5. wolfv commented on Aug 22, 2023

    @wolfv
    Member

    Yes, we are also implementing the same YAML lock format as conda-lock. We want to implement the solver on our own though :) let's see how that goes.

  6. manzt commented on Aug 22, 2023

    @manzt
    Contributor

    This would be awesome! Excited to see this feature.

  7. goyalyashpal commented on Aug 23, 2023

    @goyalyashpal

    Yes, we are also implementing the same YAML lock format as conda-lock. We want to implement the solver on our own though :) let's see how that goes.

    what would be the problem with mamba used libsolv?

  8. wolfv commented on Aug 23, 2023

    @wolfv
    Member

    @goyalyashpal we have also used libsolv (as in the C library) in rattler. There are some maintenance issues with libsolv (single-developer project) and the code is really hard to get into (it's proper "C" code if you know what I mean).
    We've taken the time to port the central algorithm from libsolv (with lots of inspirations from libsolv codebase) to Rust in the rattler_libsolv_rs crate: https://github.com/mamba-org/rattler/tree/main/crates/rattler_libsolv_rs

    Now we want to extend it to be generic enough to also consume PyPI version specs and solve for them.

    You can read more about the solver here: https://prefix.dev/blog/the_new_rattler_resolver and in Adolfo's blog post: https://ochagavia.nl/blog/the-magic-of-dependency-resolution/

  9. goyalyashpal commented on Aug 23, 2023

    @goyalyashpal

    Pixi could set itself apart by solving everything together and that way making these problems go away.

    - @ flying-sheep at #175 (comment)

    but wouldnt that require ability to link packages from coda-forge (i assuming this to be repo used by pixi) with those from pypi (repo used by pip) - both of which are in different formats. Is it possible?

  10. wolfv commented on Aug 23, 2023

    @wolfv
    Member

    It's not going to be easy and there will probably be some rough edges, but I think we can come up with an interesting solution! :)

  11. changed the title [-]Install pip dependencies in pixi environment.[/-] [+]🐍 Install pip dependencies in pixi environment.[/+] on Aug 24, 2023
  12. pelson commented on Aug 25, 2023

    @pelson

    The big problem, IMO, is that conda never introduced a namespace concept (at least, last time I checked) - and I don't mean channel namespacing, rather project namespacing. IMO, that would be a honking good idea, to allow us to clearly distinguish projects of the same name, but from different ecosystems (PyPI, CRAN, ...). The lack of this functionality will certainly make implementing the resolution harder, since you are going to have to guess if (missing) package "X" can be resolved by PyPI "X", or if it is a dependency that hasn't yet been published. If you get it working, it will lead to the uncomfortable situation where something works one day, and then somebody comes along and publishes a different project of the same name on a conda channel, and then pixi ceases to install from PyPI and starts getting the new thing (a form of dependency confusion).

    I'm exited to see the conda ecosystem to start making use of the pure python wheels that are being published on PyPI though - if it can be done, it will result in 1000s of person-hours being saved as we will no longer need to publish pure-python conda packages. This optimisation is only possible since relatively recently, since it is increasingly common to see wheels being published, and it is easy to (heuristically) distinguish pure from compiled wheels.

  13. goyalyashpal commented on Aug 25, 2023

    @goyalyashpal

    conda never introduced a namespace concept (at least, last time I checked)

    have u ever thought about using micromamba?

  14. 3 remaining items

  15. rgommers commented on Aug 26, 2023

    @rgommers
    Contributor

    Personally, I would love to see it be fully free of any middle-service - my view is that conda distributions are entirely unnecessary for pure Python projects, and I would love to see all conda-distribution based installers install the (mostly trivial) wheel format natively for those cases

    I don't know if conda-forge would want to go in that direction, but I do know that Spack would like to. Repackaging pure Python projects is a lot of work/churn, so yes it can in principle make sense to avoid that. Of course there'll be pragmatic issues, like conda-forge having all channel metadata available in one file, and PyPI forcing you to do separate REST queries for each package - that may be a showstopper in the short/medium term.

  16. kszlim commented on Aug 26, 2023

    @kszlim

    Curious if there are any workarounds (it doesn't have to be principled or the right way) for this right now? Seems like if I activate my pixi shell and pip install stuff that doesn't work at all, ie. my python interpreter within the pixi shell only references conda installed packages. This would be a showstopper for me from using pixi right now.

    I really like the direction pixi is going, so I'd really like to be an early adopter (and a work around would be appreciated). I see there's a branch that pupports to support that workflow, but looks like it's 300+ commits behind.

  17. tdejager commented on Aug 26, 2023

    @tdejager
    Contributor

    @kszlim So there is a project doing this: https://github.com/Quantco/polarify/blob/87a0a3036effb29e779db319f11d1126671197d1/pixi.toml#L12

    Which you could try out while waiting for us to work on this feature. We have started initial experiments with this issue.

  18. kszlim commented on Aug 26, 2023

    @kszlim

    @kszlim So there is a project doing this: https://github.com/Quantco/polarify/blob/87a0a3036effb29e779db319f11d1126671197d1/pixi.toml#L12

    Which you could try out while waiting for us to work on this feature. We have started initial experiments with this issue.

    Thanks, do you know how that works? I don't see what they're installing with pip, I've tried doing a pixi shell and then pip installing stuff, but that doesn't seem to work.

    To me that looks like it's installing the current package as a pip dependency, but not dependencies that purely exist in pypi?

  19. baszalmstra commented on Aug 27, 2023

    @baszalmstra
    Contributor

    Curious if there are any workarounds (it doesn't have to be principled or the right way) for this right now? Seems like if I activate my pixi shell and pip install stuff that doesn't work at all, ie. my python interpreter within the pixi shell only references conda installed packages. This would be a showstopper for me from using pixi right now.

    This is an issue caused by how we activate the environment when running pixi shell #297. It produces this weird behavior when you use for instance homebrew or a conda base environment. This will be fixed soon.

    The workaround is indeed to use pip install inside the pixi.toml (see https://github.com/hex-inc/vegafusion/blob/5e7ea041f7febe7c9ae96045291642818cffa9b4/pixi.toml#L29)

  20. kszlim commented on Aug 27, 2023

    @kszlim

    Thanks, so from doing some digging what I understand is that you're going to be implementing the conda lock strategy? Does that mean conda lock solves dependencies together (from pip and conda)?

  21. rahuldave commented on Sep 6, 2023

    @rahuldave

    unless one lockfile sees another (pixi lock sees poetry lock for example) I dont see any of these silutions as complete. Perhaps conda-lock is the only game in town for this (atleast for pip packages in the environment.yml) until pixi's combined resolution works. BTW i think once it works its gonna be a total gamechanger...

  22. roaldarbol commented on Oct 11, 2023

    @roaldarbol
    Contributor

    Have started to use pixi for most of the new projects I'm starting and it's awesome! This feature is highly anticipated, installing from PyPi is the only real hurdle I've had to face so far. Do you have any vague idea of when we could expect this? Even just short vs. long term, weeks or months? :-)

  23. baszalmstra commented on Oct 11, 2023

    @baszalmstra
    Contributor

    Thats great to hear! Im glad your enjoying it!

    This is currently my primary focus. We are building on our recently opensourced library https://github.com/prefix-dev/rip . Rip already contains a number of important required components.
    The initial implementation will not be fully featured but we’ll continue building from there. I dont want to make promises but I hope to land something relatively short term.

  24. roaldarbol commented on Oct 11, 2023

    @roaldarbol
    Contributor

    @baszalmstra That sounds great, it's all I needed to hear. Best of luck on the journey!

  25. silverwind commented on Oct 31, 2023

    @silverwind

    Shouldn't this issue be named "PyPI support"? pip is just a CLI tool, so unless you are planning to re-implement this CLI, the issue is mislabeled 😉.

  26. changed the title [-]🐍 Install pip dependencies in pixi environment.[/-] [+]🐍 Install pypi dependencies in pixi environment.[/+] on Oct 31, 2023
  27. ruben-arts commented on Jan 24, 2024

    @ruben-arts
    ContributorAuthor

    Hey followers, we have an initial implementation in. This issue was a source of some good ideas! But we've continued since with implementing it, so i'll close it.

    Summary of the current status (at time of writing) :

    • The solve, locking and installation of wheels is supported.
    • The build, solve, locking and installation of sdists is supported but will be improved overtime.

    We're missing:

    • Locking build environments for sdists, for improved reproducibility
    • Use conda dependencies as build dependencies for sdists, to avoid the need of local system dependencies.
    • Building and publishing pypi packages
    • Local/Git dependencies
    • Custom/Private pypi indices
    • Support for pyproject.toml
    • And possibly more that I don't think of now..

    We're working hard on supporting more of these features while also building on the rest of pixi.
    Most PyPI magic happens in rip, checkout its issues to follow the work there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions