Feature Request: Support reading project dependencies from `pyproject.toml` for `recipe.yaml`
Hey,
I'm currently working on a Python project that I build and distribute in two ways: as a PyPI package (using 'uv) and as a Conda package. My goal is to maintain a single source of truth for all project dependencies. The most natural place for this, especially for Python projects, is the pyproject.tomlfile. Right now I'm using the[build-system].requires(host dependencies) and[project].dependencies` (run dependencies) tables.
Currently, when creating a Conda package using rattler-build, dependencies are defined in the requirements section of the recipe.yaml. This requires duplicating the dependency list that is already present in pyproject.toml.
My request is to explore the possibility of rattler-build being able to directly read and utilize the dependency specifications from the [build-system].requires and [project].dependencies tables (or other if they are more fitting) within a project's pyproject.toml file when generating the requirements: build: and requirements: run: sections of the recipe.yaml.
This functionality would significantly reduce redundancy and potential errors caused by maintaining two separate lists of dependencies for the same project. It would streamline the packaging workflow for projects targeting both ecosystems.
For context, in conda-build, it is possible to achieve a similar result by using load_file_data to read the pyproject.toml and then programmatically parse the dependencies within the recipe, often using Jinja2 and loops.
I understand that pixi has strong integration with pyproject.toml and there are plans to integrate rattler-build into pixi (e.g., via a pixi build command). Is this feature something that might be implemented as part of that pixi integration, or is it a feature being considered for rattler-build itself?
Thank you for considering this feature request! Please let me know if any further clarification or details are needed.
the package's pypi name may differ from it's conda name,
and also conda doesn't support env maker,
for example, tomli ; python_version <'3.11' won't work with conda
Thats a good point! I guess the loop option in conda allowes you do "copy over" the package names, but its on your own risk that the package names work. But I would understand if rattler-build doesn't want such a "maybe it works" solution.
althrought, it would be possible to translate names with pypi-conda-mapping.
I think our idea is more that you should be able to generate recipes with a little bit of python code easily, in the future. In the python test we also automatically run pip check to make sure that all dependencies are installed and satisfied.
That's the solution I'm implemented for us for now. Having a small python script which generates the recipe.yaml based on the dependencies in the pyproject.yaml and some other predefined stuff (basically the recipe format with the "stable" values hardcoded). But because I hardcoded the recipe format with some values it's not really portable and needs adjustment for other projects. Looking forward to a more generalized solution :)