diff --git a/CONSTRUCT.md b/CONSTRUCT.md index 356eeaf10..ccb36a91e 100644 --- a/CONSTRUCT.md +++ b/CONSTRUCT.md @@ -233,8 +233,6 @@ name) to a dictionary of options: Notes: - `ignore_duplicate_files` will always be considered `True` if `extra_envs` is in use. - `conda` needs to be present in the `base` environment (via `specs`) -- support for `menu_packages` is planned, but not possible right now. For now, all packages - in an `extra_envs` config will be allowed to create their shortcuts. - If a global `exclude` option is used, it will have an effect on the environments created by `extra_envs` too. For example, if the global environment excludes `tk`, none of the extra environments will have it either. Unlike the global option, an error will not be diff --git a/constructor/construct.py b/constructor/construct.py index 228fb8470..71934da7e 100644 --- a/constructor/construct.py +++ b/constructor/construct.py @@ -165,8 +165,6 @@ Notes: - `ignore_duplicate_files` will always be considered `True` if `extra_envs` is in use. - `conda` needs to be present in the `base` environment (via `specs`) -- support for `menu_packages` is planned, but not possible right now. For now, all packages - in an `extra_envs` config will be allowed to create their shortcuts. - If a global `exclude` option is used, it will have an effect on the environments created by `extra_envs` too. For example, if the global environment excludes `tk`, none of the extra environments will have it either. Unlike the global option, an error will not be @@ -608,9 +606,7 @@ "channels_remap": (list, tuple), "user_requested_specs": (list, tuple), "exclude": (list, tuple), - # TODO: we can't support menu_packages for extra envs yet - # will implement when the PR for new menuinst lands - # "menu_packages": (list, tuple), + "menu_packages": (list, tuple), } logger = logging.getLogger(__name__) diff --git a/constructor/osxpkg.py b/constructor/osxpkg.py index 5535b0a9e..a32fa2fb4 100644 --- a/constructor/osxpkg.py +++ b/constructor/osxpkg.py @@ -202,7 +202,6 @@ def modify_xml(xml_path, info): choices_outline.extend(list(child)) choices_outline.remove(child) - menu_packages = info.get('menu_packages', True) for path_choice in root.findall('choice'): ident = path_choice.get('id') if ident == 'default': @@ -218,7 +217,7 @@ def modify_xml(xml_path, info): path_choice.set('visible', 'false') path_choice.set('title', 'Apply {}'.format(info['name'])) path_choice.set('enabled', 'false') - elif ident.endswith('shortcuts') and menu_packages: + elif ident.endswith('shortcuts') and info["_enable_shortcuts"]: # Show this option if menu_packages was set to a non-empty value # or if the option was not set at all. We don't show the option # menu_packages was set to an empty list! @@ -227,7 +226,11 @@ def modify_xml(xml_path, info): path_choice.set('enabled', 'true') descr = "Create shortcuts for compatible packages" menu_packages = info.get("menu_packages") - if isinstance(menu_packages, (list, tuple)): + if menu_packages is None: + menu_packages = [] + for extra_env in info.get("_extra_envs_info", {}).values(): + menu_packages += extra_env.get("menu_packages", []) + if menu_packages: descr += f" ({', '.join(menu_packages)})" path_choice.set('description', descr) elif ident.endswith('user_pre_install') and info.get('pre_install_desc'): diff --git a/docs/source/construct-yaml.md b/docs/source/construct-yaml.md index 356eeaf10..ccb36a91e 100644 --- a/docs/source/construct-yaml.md +++ b/docs/source/construct-yaml.md @@ -233,8 +233,6 @@ name) to a dictionary of options: Notes: - `ignore_duplicate_files` will always be considered `True` if `extra_envs` is in use. - `conda` needs to be present in the `base` environment (via `specs`) -- support for `menu_packages` is planned, but not possible right now. For now, all packages - in an `extra_envs` config will be allowed to create their shortcuts. - If a global `exclude` option is used, it will have an effect on the environments created by `extra_envs` too. For example, if the global environment excludes `tk`, none of the extra environments will have it either. Unlike the global option, an error will not be diff --git a/examples/shortcuts/construct.yaml b/examples/shortcuts/construct.yaml index f50000558..f7dbae225 100644 --- a/examples/shortcuts/construct.yaml +++ b/examples/shortcuts/construct.yaml @@ -12,5 +12,16 @@ specs: - console_shortcut # [win] - package_1 +menu_packages: + - package_1 + +extra_envs: + another_env: + specs: + - package_1 + - console_shortcut # [win] + menu_packages: + - console_shortcut # [win] + initialize_by_default: false register_python: False diff --git a/tests/test_examples.py b/tests/test_examples.py index 475c6f95e..89636bcc3 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -405,16 +405,23 @@ def test_example_shortcuts(tmp_path, request): # check that the shortcuts are created if sys.platform == "win32": for key in ("ProgramData", "AppData"): - pkg_1 = Path(os.environ[key]) / "Microsoft/Windows/Start Menu/Programs/Package 1" - if pkg_1.exists(): - assert (pkg_1 / "A.lnk").exists() - assert (pkg_1 / "B.lnk").exists() + start_menu = Path(os.environ[key]) / "Microsoft/Windows/Start Menu/Programs" + package_1 = start_menu / "Package 1" + miniconda = start_menu / "Miniconda3" + if package_1.is_dir() and miniconda.is_dir(): + assert (package_1 / "A.lnk").is_file() + assert (package_1 / "B.lnk").is_file() + # The shortcut created from the 'base' env + # should not exist because we filtered it out in the YAML + # We do expect one shortcut from 'another_env' + assert not (miniconda / "Anaconda Prompt.lnk").is_file() + assert (miniconda / "Anaconda Prompt (another_env).lnk").is_file() break else: raise AssertionError("No shortcuts found!") _run_uninstaller_exe(install_dir) - assert not (pkg_1 / "A.lnk").exists() - assert not (pkg_1 / "B.lnk").exists() + assert not (package_1 / "A.lnk").is_file() + assert not (package_1 / "B.lnk").is_file() elif sys.platform == "darwin": applications = Path("~/Applications").expanduser() print("Shortcuts found:", sorted(applications.glob("**/*.app")))