From c6b4b16fc8b9aeb75ccb93fd0144eac97039006e Mon Sep 17 00:00:00 2001 From: Marco Esters Date: Mon, 25 Nov 2024 14:04:41 -0800 Subject: [PATCH 1/7] Render post-install pages for Windows when input is a string --- constructor/winexe.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 From 27bfa6213607fef6eb65f83a1fa355539be8d653 Mon Sep 17 00:00:00 2001 From: Marco Esters Date: Mon, 25 Nov 2024 14:04:51 -0800 Subject: [PATCH 2/7] Add news --- news/904-post-install-pages-win-fix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 news/904-post-install-pages-win-fix 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 + +* From 7ff7f7cd56efa03cb6a3dba4b4dc688702f3951b Mon Sep 17 00:00:00 2001 From: Marco Esters Date: Mon, 25 Nov 2024 14:20:00 -0800 Subject: [PATCH 3/7] Update Windows extra page test --- tests/test_examples.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/test_examples.py b/tests/test_examples.py index f16200f44..454d050b8 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -379,8 +379,25 @@ def test_example_customized_welcome_conclusion(tmp_path, request): @pytest.mark.skipif(sys.platform != "win32", reason="Windows only") -def test_example_extra_pages_win(tmp_path, request): - input_path = _example_path("exe_extra_pages") +@pytest.mark.parameterize( + "extra_pages", + pytest.param(["extra_page_1.nsi", "extra_page_2.nsi"], id="two pages"), + pytest.param("extra_page_1.nsi", id="single page"), +) +def test_example_extra_pages_win(tmp_path, request, extra_pages): + recipe_path = _example_path("exe_extra_pages") + input_path = tmp_path / "input" + shutil.copytree(str(recipe_path), str(input_path)) + construct_yaml = input_path / "construct.yaml" + content = construct_yaml.read_text() + if isinstance(extra_pages, str): + content += f"post_install_pages: {extra_pages}\n" + content = content.replace("extraPages", "extraPage") + else: + content += "post_install_pages:\n" + for page in extra_pages: + content += f" - {page}\n" + construct_yaml.write_text(content) for installer, install_dir in create_installer(input_path, tmp_path): _run_installer(input_path, installer, install_dir, request=request) From d9711907d7a59cdfdebbbc7b3366a5da48cb0bcd Mon Sep 17 00:00:00 2001 From: Marco Esters Date: Mon, 25 Nov 2024 14:28:27 -0800 Subject: [PATCH 4/7] Fix typo --- tests/test_examples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_examples.py b/tests/test_examples.py index 454d050b8..0e9603ab7 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -379,7 +379,7 @@ def test_example_customized_welcome_conclusion(tmp_path, request): @pytest.mark.skipif(sys.platform != "win32", reason="Windows only") -@pytest.mark.parameterize( +@pytest.mark.parametrize( "extra_pages", pytest.param(["extra_page_1.nsi", "extra_page_2.nsi"], id="two pages"), pytest.param("extra_page_1.nsi", id="single page"), From 5614ce7c8e433bc1d8b2473f5a88e37ce90c7e7c Mon Sep 17 00:00:00 2001 From: Marco Esters Date: Mon, 25 Nov 2024 14:30:36 -0800 Subject: [PATCH 5/7] Fix parametrize syntax --- tests/test_examples.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_examples.py b/tests/test_examples.py index 0e9603ab7..44c5450e3 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -378,12 +378,14 @@ def test_example_customized_welcome_conclusion(tmp_path, request): _run_installer(input_path, installer, install_dir, request=request) -@pytest.mark.skipif(sys.platform != "win32", reason="Windows only") @pytest.mark.parametrize( "extra_pages", - pytest.param(["extra_page_1.nsi", "extra_page_2.nsi"], id="two pages"), - pytest.param("extra_page_1.nsi", id="single page"), + ( + pytest.param(["extra_page_1.nsi", "extra_page_2.nsi"], id="two pages"), + pytest.param("extra_page_1.nsi", id="single page"), + ) ) +@pytest.mark.skipif(sys.platform != "win32", reason="Windows only") def test_example_extra_pages_win(tmp_path, request, extra_pages): recipe_path = _example_path("exe_extra_pages") input_path = tmp_path / "input" From f088d7c4c1776f628981d693fe7b660f8afcf634 Mon Sep 17 00:00:00 2001 From: Marco Esters Date: Mon, 25 Nov 2024 15:02:12 -0800 Subject: [PATCH 6/7] Remove post_install_pages from base example --- examples/exe_extra_pages/construct.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/exe_extra_pages/construct.yaml b/examples/exe_extra_pages/construct.yaml index 95b649bf4..d78bed489 100644 --- a/examples/exe_extra_pages/construct.yaml +++ b/examples/exe_extra_pages/construct.yaml @@ -5,6 +5,3 @@ channels: - http://repo.anaconda.com/pkgs/main/ specs: - python -post_install_pages: - - extra_page_1.nsi - - extra_page_2.nsi From 881305e79a957b64ea0acb288155e7b66496fd32 Mon Sep 17 00:00:00 2001 From: Marco Esters Date: Tue, 26 Nov 2024 07:10:05 -0800 Subject: [PATCH 7/7] Use jinja in extra page example --- examples/exe_extra_pages/construct.yaml | 14 ++++++++++++- tests/test_examples.py | 26 +++++-------------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/examples/exe_extra_pages/construct.yaml b/examples/exe_extra_pages/construct.yaml index d78bed489..a7987b4e9 100644 --- a/examples/exe_extra_pages/construct.yaml +++ b/examples/exe_extra_pages/construct.yaml @@ -1,7 +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/tests/test_examples.py b/tests/test_examples.py index 44c5450e3..0fd099a19 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -378,28 +378,12 @@ def test_example_customized_welcome_conclusion(tmp_path, request): _run_installer(input_path, installer, install_dir, request=request) -@pytest.mark.parametrize( - "extra_pages", - ( - pytest.param(["extra_page_1.nsi", "extra_page_2.nsi"], id="two pages"), - pytest.param("extra_page_1.nsi", id="single page"), - ) -) +@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, extra_pages): - recipe_path = _example_path("exe_extra_pages") - input_path = tmp_path / "input" - shutil.copytree(str(recipe_path), str(input_path)) - construct_yaml = input_path / "construct.yaml" - content = construct_yaml.read_text() - if isinstance(extra_pages, str): - content += f"post_install_pages: {extra_pages}\n" - content = content.replace("extraPages", "extraPage") - else: - content += "post_install_pages:\n" - for page in extra_pages: - content += f" - {page}\n" - construct_yaml.write_text(content) +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)