pixi icon indicating copy to clipboard operation
pixi copied to clipboard

Import conda-based environment with pip (requirements.txt) dependencies

Open pierrepo opened this issue 1 year ago • 2 comments

Problem description

This feature request is related to issue #1410

Currently, it is possible to create a new Pixi environment based on a Conda YAML file:

pixi init --import environment.yml

This command works nicely if the environment contains both conda and pip dependencies, for instance:

name: test
channels:
  - conda-forge
  - nodefaults
dependencies:
  - python=3.12
  - pip
  - pandas
  - matplotlib
  - pip:
    - watermark

However, it does not work if pip dependencies are in an external file, for example:

environment.yml

name: test
channels:
  - conda-forge
  - nodefaults
dependencies:
  - python=3.12
  - pip
  - pandas
  - matplotlib
  - pip:
    - -r requirements.txt

requirements.txt

watermark
$ pixi init --import environment.yml 
  × Can't parse '-r requirements.txt' as pypi dependency
  ╰─▶ Expected package name starting with an alphanumeric character, found `-`
      -r requirements.txt
      ^

Feature request: could we please import conda YAML file with pip dependencies listed in an external file?

pierrepo avatar Sep 06 '24 08:09 pierrepo

This seems very useful indeed, thanks for reporting!

tdejager avatar Sep 06 '24 10:09 tdejager

Added good first issue.

We already have requirement parsing in the code base so it's basically just reading the file if there is a -r requirements.txt and adding the requirements to the pypi-dependencies.

ruben-arts avatar Sep 18 '24 11:09 ruben-arts

I'd like to work on this if that's ok.

LiamConnors avatar Dec 09 '24 11:12 LiamConnors

@LiamConnors Please go ahead!

ruben-arts avatar Dec 09 '24 13:12 ruben-arts

@ruben-arts I started looking at this and have a draft here https://github.com/prefix-dev/pixi/pull/2883 I wasn't 100% sure at which stage would be best to handle the dependencies within the external requirements.txt. I'd love your feedback. Is there an issue with parsing the external dependencies as if they were directly in the environment.yml file? and if so, and what stage instead do you think those external dependencies should be handled? Thanks for your help!

LiamConnors avatar Jan 13 '25 02:01 LiamConnors

Roadmap for related work: https://github.com/prefix-dev/pixi/issues/4192

lucascolley avatar Jul 24 '25 18:07 lucascolley