From caef786c50e7bc23836e0364392eb9aecc943c00 Mon Sep 17 00:00:00 2001 From: Ryan Volz Date: Tue, 1 Mar 2022 00:11:33 -0500 Subject: [PATCH] Only include specifically-requested packages in radioconda metapackage. Including the fully solved list of packages is fragile to packages getting marked broken or having their metadata rewritten, making the radioconda metapackage uninstallable. This doesn't completely solve that (nothing really can), but it does make the metapackage still fulfill its intended purpose while hopefully remaining installable more often. --- rerender.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/rerender.py b/rerender.py index 71470d7..aca36a4 100755 --- a/rerender.py +++ b/rerender.py @@ -198,15 +198,6 @@ def render_platforms( else: variables = None - # write the full environment specification to a yaml file (to build metapackage) - locked_env_dict = write_env_file( - env_spec=locked_env_spec, - file_path=output_dir / f"{output_name}.yml", - name=env_name, - version=version, - variables=variables, - ) - # write the full environment specification to a lock file (to install from file) lockfile_contents = write_lock_file( lock_spec=locked_env_spec, @@ -214,6 +205,27 @@ def render_platforms( conda_exe=conda_exe, ) + # filter the full package spec by the explicitly listed package names + metapackage_pkg_specs = [ + spec + for spec in locked_env_spec.specs + if name_from_pkg_spec(spec) in env_spec.specs + ] + metapackage_spec = conda_lock.src_parser.LockSpecification( + specs=metapackage_pkg_specs, + channels=locked_env_spec.channels, + platform=locked_env_spec.platform, + ) + + # write the filtered environment spec to a yaml file (to build metapackage) + locked_env_dict = write_env_file( + env_spec=metapackage_spec, + file_path=output_dir / f"{output_name}.yml", + name=env_name, + version=version, + variables=variables, + ) + # add installer-only (base environment) packages and lock those too installer_pkg_spec = conda_lock.conda_lock.parse_environment_file( environment_file=installer_environment_file, platform=platform