prefix-dev / pixi

Package management made easy
https://pixi.sh
BSD 3-Clause "New" or "Revised" License
3.23k stars 178 forks source link

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

Open pierrepo opened 1 month ago

pierrepo commented 1 month ago

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?

tdejager commented 1 month ago

This seems very useful indeed, thanks for reporting!

ruben-arts commented 1 month ago

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.