From d85133decbc713ea6bc13359bb479c3bcf90c0fa Mon Sep 17 00:00:00 2001 From: Marco Esters Date: Thu, 28 Nov 2024 06:45:54 -0800 Subject: [PATCH] Render post-install pages for Windows when input is a string (#904) --- constructor/winexe.py | 9 ++++++--- examples/exe_extra_pages/construct.yaml | 11 ++++++++++- news/904-post-install-pages-win-fix | 19 +++++++++++++++++++ tests/test_examples.py | 5 ++++- 4 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 news/904-post-install-pages-win-fix diff --git a/constructor/winexe.py b/constructor/winexe.py index 16d42304c..74cf2e4da 100644 --- a/constructor/winexe.py +++ b/constructor/winexe.py @@ -365,9 +365,12 @@ def make_nsi( if variables['custom_conclusion'] else '' ) - variables['POST_INSTALL_PAGES'] = '\n'.join( - custom_nsi_insert_from_file(file) for file in info.get('post_install_pages', []) - ) + if isinstance(info.get("post_install_pages"), str): + variables["POST_INSTALL_PAGES"] = custom_nsi_insert_from_file(info["post_install_pages"]) + else: + variables['POST_INSTALL_PAGES'] = '\n'.join( + custom_nsi_insert_from_file(file) for file in info.get('post_install_pages', []) + ) variables['TEMP_EXTRA_FILES'] = '\n '.join(insert_tempfiles_commands(temp_extra_files)) variables['VIRTUAL_SPECS'] = " ".join([f'"{spec}"' for spec in info.get("virtual_specs", ())]) # This is the same but without quotes so we can print it fine diff --git a/examples/exe_extra_pages/construct.yaml b/examples/exe_extra_pages/construct.yaml index 95b649bf4..a7987b4e9 100644 --- a/examples/exe_extra_pages/construct.yaml +++ b/examples/exe_extra_pages/construct.yaml @@ -1,10 +1,19 @@ -name: extraPages +{% if os.environ.get("POST_INSTALL_PAGES_LIST") %} +{% set name = "extraPages" %} +{% else %} +{% set name = "extraPageSingle" %} +{% endif %} +name: {{ name }} version: X installer_type: all channels: - http://repo.anaconda.com/pkgs/main/ specs: - python +{% if os.environ.get("POST_INSTALL_PAGES_LIST") %} post_install_pages: - extra_page_1.nsi - extra_page_2.nsi +{% else %} +post_install_pages: extra_page_1.nsi +{% endif %} diff --git a/news/904-post-install-pages-win-fix b/news/904-post-install-pages-win-fix new file mode 100644 index 000000000..40d2a879e --- /dev/null +++ b/news/904-post-install-pages-win-fix @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* Correctly parse post-install pages for Windows when input is a string. (#904) + +### Deprecations + +* + +### Docs + +* + +### Other + +* diff --git a/tests/test_examples.py b/tests/test_examples.py index f16200f44..0fd099a19 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -378,8 +378,11 @@ def test_example_customized_welcome_conclusion(tmp_path, request): _run_installer(input_path, installer, install_dir, request=request) +@pytest.mark.parametrize("extra_pages", ("str", "list")) @pytest.mark.skipif(sys.platform != "win32", reason="Windows only") -def test_example_extra_pages_win(tmp_path, request): +def test_example_extra_pages_win(tmp_path, request, extra_pages, monkeypatch): + if extra_pages == "list": + monkeypatch.setenv("POST_INSTALL_PAGES_LIST", "1") input_path = _example_path("exe_extra_pages") for installer, install_dir in create_installer(input_path, tmp_path): _run_installer(input_path, installer, install_dir, request=request)