Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion constructor/briefcase/run_installation.bat
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ rem Set CONDA_QUIET primarily to disable the spinners
set CONDA_QUIET={{ 0 if add_debug else 1 }}

rem Get the name of the install directory
for %%I in ("%INSTDIR%") do set "APPNAME=%%~nxI"
for %%I in ("%INSTDIR%") do set "DISTRIBUTION_NAME=%%~nxI"
set MENUINST_DISTRIBUTION_NAME=%DISTRIBUTION_NAME%
set "LOG=%INSTDIR%\install.log"

{%- if script_env_variables %}
Expand Down Expand Up @@ -128,6 +129,15 @@ if "%ALLUSERS%"=="0" (
if errorlevel 1 ( exit /b %errorlevel% )
)

rem Persist distribution_name to menuinst.toml before installing packages.
rem This ensures the value is captured even if no packages have shortcuts.
rem Must run before conda install to avoid creating shortcuts twice.
"%CONDA_EXE%" menuinst --install -p "%BASE_PATH%" --root-prefix "%BASE_PATH%"
if errorlevel 1 ( exit /b %errorlevel% )
if not exist "%BASE_PATH%\Menu\menuinst.toml" (
{{ error_block('Failed to initialize shortcut configuration', 14) }}
)

{%- if has_pre_install %}
rem Run user-supplied pre-install script
{%- if has_pre_install_desc %}
Expand Down
25 changes: 16 additions & 9 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,28 +997,35 @@ def test_example_scripts(tmp_path, request):
def test_example_shortcuts(tmp_path, request):
input_path = _example_path("shortcuts")
for installer, install_dir in create_installer(input_path, tmp_path):
# console_shortcut package uses hardcoded "Anaconda3" in its menu definition
distribution_name = "Anaconda3"
if sys.platform == "win32":
# Verify shortcuts don't exist before installation (not leftover from previous run (since EXE/MSI run in a loop))
for key in ("ProgramData", "AppData"):
start_menu = Path(os.environ[key]) / "Microsoft/Windows/Start Menu/Programs"
package_1 = start_menu / "Package 1"
if package_1.is_dir():
assert not (package_1 / "A.lnk").is_file(), "A.lnk exists before installation"
assert not (package_1 / "B.lnk").is_file(), "B.lnk exists before installation"

_run_installer(input_path, installer, install_dir, request=request, uninstall=False)
# check that the shortcuts are created
if sys.platform == "win32":
# MSI shortcut verification expected to fail due to menuinst bug
# https://github.com/conda/menuinst/issues/453
if installer.suffix == ".msi":
pytest.xfail("MSI shortcut verification fails due to menuinst#453")
for key in ("ProgramData", "AppData"):
start_menu = Path(os.environ[key]) / "Microsoft/Windows/Start Menu/Programs"
package_1 = start_menu / "Package 1"
anaconda = start_menu / "Anaconda3 (64-bit)"
if package_1.is_dir() and anaconda.is_dir():
console_shortcut_dir = start_menu / f"{distribution_name} (64-bit)"
if package_1.is_dir() and console_shortcut_dir.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 (anaconda / "Anaconda Prompt.lnk").is_file()
assert (anaconda / "Anaconda Prompt (another_env).lnk").is_file()
assert not (console_shortcut_dir / "Anaconda Prompt.lnk").is_file()
assert (console_shortcut_dir / "Anaconda Prompt (another_env).lnk").is_file()
break
else:
raise AssertionError("No shortcuts found!")
raise AssertionError(f"No shortcuts found! Expected '{distribution_name} (64-bit)'")
if installer.suffix == ".msi":
_run_uninstaller_msi(installer, install_dir)
else:
Expand Down