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