constructor icon indicating copy to clipboard operation
constructor copied to clipboard

Fix environment and environment_file modes

Open mcg1969 opened this issue 2 years ago • 2 comments

I was finding something interesting: if I built an installer using environment or environment_file modes—which causes the constructor to inspect an existing environment (or one that it creates with the user's conda) to determine the installer recipe—then the conda environment metadata is corrupt. Specifically, the depends entries were empty, causing conda to think my environment was fully of PyPi packages, among other things.

I traced the cause to the _precs_from_environment function, which tried to use primarily external conda calls to inspect the environment, instead of using the full power of the PrefixData object. The depends field was simply not being populated. I've rewritten that function considerably here.

I've also modified the environment_file behavior. If the suffix is .yml or .yaml, it uses conda env create --file to create the environment; otherwise it uses conda create --file.

Finally, I've made it optional to supply channels or channels_remap list in these modes. channels is definitely unnecessary, but channels_remap might still be useful.

I'm reluctant to merge this without external review from someone who actually uses the environment approach to building installers, to make sure I didn't miss anything. That said, I did create three new examples that are run by the run_examples.py script...

mcg1969 avatar Dec 29 '21 21:12 mcg1969

Hello, I've run into the same issue and would appreciate if this could get reviewed & merged :) I'm also willing to help test things if you tell me what to do! I have access to Linux and macOS computers.

Thank you!

hoechenberger avatar Jan 11 '22 16:01 hoechenberger

@mcg1969 I just created an installer using your constructor branch, and while conda list doesn't claim the packages were installed from pypi anymore, the Channel column now is entirely empty. I don't think this is intended behavior, or is it?

hoechenberger avatar Jan 11 '22 22:01 hoechenberger