grayskull icon indicating copy to clipboard operation
grayskull copied to clipboard

Generate recipe from project tree using pypa/build

Open dholth opened this issue 1 year ago • 4 comments

Description

This is the start of something I've wanted: grayskull pypi . on a checkout to generate a recipe, suitable for committing to the project tree. Like https://github.com/conda/conda/blob/main/recipe/meta.yaml#L5-L7 where source is "../" or the parent directory of the meta.yaml.

pypa/build gets all project metadata in a standard way, including the build-system requires (setuptools, flit, poetry). If these are not already installed, we should add a "conda install " before project.metadata_path(...) or bail and let the user install those. We would also change the pip command used in the build: section so that we never accidentally pip install a build requirement.

Remaining to be done, process all possible metadata out of distribution and into recipe; possibly deal with late "we don't know the package name until after fetch_data" more elegantly since this breaks grayskull's current assumptions.

It's also a little awkward that the recipe output dir is always <given directory>/<project name>. These would be <checkout>/conda.recipe/meta.yaml when included as first-party recipes.

Fix #542

dholth avatar Jul 12 '24 15:07 dholth

is this still as a draft?

marcelotrevisani avatar Jul 28 '24 19:07 marcelotrevisani

I would like feedback but it is still a draft, it's not clean yet.

dholth avatar Jul 29 '24 13:07 dholth

@beenje I have been refining this technique here. It makes a wheel and immediately converts it to .conda without bothering with conda-build or a recipe. But it's focused on editable installs and there's no supporting code to manage build dependencies etc. In the future the metadata convert part might be shareable.

pyproject.toml doesn't give your imports in a generic way. You could inspect the contents of a wheel. You could have build-system-specific handling like how flit's name= must match the Python import.

dholth avatar Aug 17 '24 17:08 dholth

@beenje I have been refining this technique here. It makes a wheel and immediately converts it to .conda without bothering with conda-build or a recipe. But it's focused on editable installs and there's no supporting code to manage build dependencies etc. In the future the metadata convert part might be shareable.

Nice! Another project I have to look into :-)

beenje avatar Aug 19 '24 07:08 beenje