Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch install-time errors on windows #552

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 12 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
[ $RUNNER_OS = 'Windows' ] && CONDA_EXE=$CONDA/Scripts/conda.exe
[ $RUNNER_OS == macOS ] && export CONDA_PKGS_DIRS=~/.pkgs
${CONDA_EXE:-conda} create -p ../conda conda conda-build conda-verify

- name: Build the package
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -57,7 +58,7 @@ jobs:
# and upload them all to anaconda.org in a single job
name: package-${{ github.sha }}
path: ${{ runner.temp }}/conda-bld/*/*.tar.bz2
- name: Run examples and prepare artifacts
- name: Install local constructor
run: |
source ../conda/etc/profile.d/conda.sh
CONDA_BLD_PATH="${{ runner.temp }}/conda-bld" \
Expand All @@ -69,6 +70,16 @@ jobs:
echo "Installed constructor is not local!"
exit 1
fi
- name: Patch NSIS to use logging builds on Windows
if: startsWith(matrix.os, 'windows')
run: |
source ../conda/etc/profile.d/conda.sh
nsis_version=$(conda list nsis --json | jq -r ".[].version")
curl -sL "https://sourceforge.net/projects/nsis/files/NSIS%203/${nsis_version}/nsis-${nsis_version}-log.zip/download" -o "nsis-${nsis_version}-log.zip"
unzip "nsis-${nsis_version}-log.zip" -d "$CONDA_PREFIX/NSIS/"
echo "NSIS_USING_LOG_BUILD=1" >> $GITHUB_ENV
- name: Run examples and prepare artifacts
source ../conda/etc/profile.d/conda.sh
mkdir -p examples_artifacts/
python scripts/run_examples.py --keep-artifacts=examples_artifacts/
- name: Upload the example installers as artifacts
Expand Down
30 changes: 27 additions & 3 deletions constructor/nsis/main.nsi.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@

Unicode "true"

#if enable_debugging
!define ENABLE_LOGGING

!define LogSet "!insertmacro LogSetMacro"
!macro LogSetMacro SETTING
!ifdef ENABLE_LOGGING
LogSet ${SETTING}
!endif
!macroend

!define LogText "!insertmacro LogTextMacro"
!macro LogTextMacro INPUT_TEXT
!ifdef ENABLE_LOGGING
LogText ${INPUT_TEXT}
!endif
!macroend
#endif

!include "WinMessages.nsh"
!include "WordFunc.nsh"
!include "LogicLib.nsh"
Expand Down Expand Up @@ -414,6 +432,7 @@ Function InstModePage_Leave
FunctionEnd

Function .onInit
${LogSet} on
Push $0
Push $1
Push $2
Expand Down Expand Up @@ -835,6 +854,7 @@ Function AbortRetryNSExecWait
nsExec::ExecToLog $2
pop $0
${If} $0 != "0"
DetailPrint "::error:: $1"
MessageBox MB_ABORTRETRYIGNORE|MB_ICONEXCLAMATION|MB_DEFBUTTON3 \
$1 /SD IDIGNORE IDABORT abort IDRETRY retry
; IDIGNORE: Continue anyway
Expand Down Expand Up @@ -906,9 +926,13 @@ Section "Install"
call AbortRetryNSExecWait
${EndIf}

push '"$INSTDIR\pythonw.exe" -E -s "$INSTDIR\Lib\_nsis.py" mkdirs'
push 'Failed to initialize Anaconda directories'
call AbortRetryNSExecWait
DetailPrint "Running mkdirs..."
nsExec::ExecToLog '"$INSTDIR\pythonw.exe" "$INSTDIR\Lib\_nsis.py" mkdirs'
Pop $0
${If} $0 != "0"
push 'Failed to set directories!'
call AbortRetryNSExecWait
${EndIf}

${If} $Ana_PostInstall_State = ${BST_CHECKED}
DetailPrint "Running post install..."
Expand Down
5 changes: 3 additions & 2 deletions constructor/winexe.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def setup_envs_commands(info, dir_path):
SetDetailsPrint both
# List of packages to install
SetOutPath "{env_txt_dir}"
File {env_txt_abspath}
File "{env_txt_abspath}"
# A conda-meta\history file is required for a valid conda prefix
SetOutPath "{conda_meta}"
FileOpen $0 "history" w
Expand All @@ -86,7 +86,7 @@ def setup_envs_commands(info, dir_path):
# Restore shipped conda-meta\history for remapped
# channels and retain only the first transaction
SetOutPath "{conda_meta}"
File {history_abspath}
File "{history_abspath}"
"""

lines = template.format( # this one block is for the base environment
Expand Down Expand Up @@ -194,6 +194,7 @@ def make_nsi(info, dir_path, extra_files=()):
ppd['keep_pkgs'] = info.get('keep_pkgs') or False
ppd['post_install_exists'] = bool(info.get('post_install'))
ppd['with_conclusion_text'] = bool(conclusion_text)
ppd["enable_debugging"] = bool(os.environ.get("NSIS_USING_LOG_BUILD"))
data = preprocess(data, ppd)
data = fill_template(data, replace)
if info['_platform'].startswith("win") and sys.platform != 'win32':
Expand Down
7 changes: 7 additions & 0 deletions scripts/run_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ def run_examples(keep_artifacts=None):
elif ext == 'exe':
cmd = ['cmd.exe', '/c', 'start', '/wait', fpath, '/S', '/D=%s' % env_dir]
test_errored = _execute(cmd)
if ext == 'exe' and os.environ.get("NSIS_USING_LOG_BUILD"):
test_errored = 0
with open(os.path.join(env_dir, "install.log")) as f:
for line in f:
if ":error:" in line:
print(line)
test_errored = 1
errored += test_errored
if keep_artifacts:
shutil.move(fpath, keep_artifacts)
Expand Down