Skip to content

Commit

Permalink
Render post-install pages for Windows when input is a string (#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoesters authored Nov 28, 2024
1 parent d4a35e9 commit d85133d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
9 changes: 6 additions & 3 deletions constructor/winexe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion examples/exe_extra_pages/construct.yaml
Original file line number Diff line number Diff line change
@@ -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 %}
19 changes: 19 additions & 0 deletions news/904-post-install-pages-win-fix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Correctly parse post-install pages for Windows when input is a string. (#904)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
5 changes: 4 additions & 1 deletion tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d85133d

Please sign in to comment.