Skip to content

Commit d998711

Browse files
authored
Merge pull request #4142 from ales-erjavec/fixes/conda-installer-py-version-check
[FIX] build-conda-installer.sh: Do not use python version from Miniconda
2 parents 05c8ae0 + 355b2f0 commit d998711

File tree

2 files changed

+37
-29
lines changed

2 files changed

+37
-29
lines changed

scripts/windows/build-conda-installer.sh

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,27 @@
44
set -e
55

66
function usage() {
7-
echo 'build-conda-installer.sh
7+
echo "build-conda-installer.sh
88
99
Build a conda based based windows application installer.
1010
11-
Note: This script needs makensis and curl on $PATH
11+
Note: This script needs makensis and curl on \$PATH
1212
Note: Needs basic bash env on Windows (git-bash is sufficient/tested, but
1313
cygwin should work too)
1414
1515
Options:
1616
-b --build-base <path> Build directory (default ./build)
1717
-d --dist-dir <path> Distribution dir (default ./dist)
1818
--cache-dir <path> Cache downloaded packages in DIR (the default
19-
is "build/download-cache")
19+
is \"build/download-cache\")
20+
-M, --miniconda-version <version>
21+
The miniconda distribution to include in the
22+
installer (default ${MINICONDA_VERSION_DEFAULT}).
2023
--platform <plattag> win32 or win_amd64
2124
--env-spec An environment specification file as exported by
22-
`conda list --export --explicit --md5`
25+
\`conda list --export --explicit --md5\`
2326
(the default is specs/conda-spec.txt)
24-
--online (yes|no) Build an "online" or "offline" installer.
27+
--online (yes|no) Build an \"online\" or \"offline\" installer.
2528
In an online installer only the Miniconda installer
2629
is included. All other packages are otherwise
2730
fetched at installation time
@@ -32,21 +35,21 @@ Options:
3235
Examples
3336
3437
$ ./scripts/windows/build-conda-installer.sh --online=yes
35-
'
38+
"
3639
}
3740

3841
NAME=Orange3
3942
# version is determined from the ENV_SPEC_FILE
4043
VERSION=
4144

42-
PYTHON=
4345
BUILDBASE=
4446
DISTDIR=
4547
CACHEDIR=
4648

47-
# Python version in the Miniconda installer.
48-
MINICONDA_VERSION=4.7.12
49-
PYTHON_VERSION=3.7.0
49+
# Miniconda installer version; included and installed if there is no existing
50+
# Anaconda/Miniconda installation found on the target system.
51+
MINICONDA_VERSION_DEFAULT=4.7.12
52+
MINICONDA_VERSION=${MINICONDA_VERSION_DEFAULT}
5053

5154
PLATTAG=win_amd64
5255

@@ -71,6 +74,10 @@ while [[ "${1:0:1}" = "-" ]]; do
7174
CACHEDIR=${2:?}; shift 2;;
7275
--cache-dir=*)
7376
CACHEDIR=${1#*=}; shift 1;;
77+
-M|--miniconda-version)
78+
MINICONDA_VERSION=${2:?}; shift 2;;
79+
--miniconda-version=*)
80+
MINICONDA_VERSION=${1*=}; shift 1;;
7481
--platform)
7582
PLATTAG=${2:?}; shift 2;;
7683
--platform=*)
@@ -90,10 +97,6 @@ while [[ "${1:0:1}" = "-" ]]; do
9097
esac
9198
done
9299

93-
if [[ ! ${PYTHON_VERSION} =~ ^([0-9]+\.){2,}[0-9]+$ ]]; then
94-
echo "Invalid python version: $PYTHON_VERSION (need major.minor.micro)" >&2
95-
exit 1
96-
fi
97100

98101
if [[ ! ${PLATTAG:?} =~ (win32|win_amd64) ]]; then
99102
echo "Invalid platform tag: ${PLATTAG} (expected win32 or win_amd64)" >&2
@@ -106,10 +109,6 @@ if [[ ! "${ONLINE}" =~ ^(yes|no)$ ]]; then
106109
exit 1
107110
fi
108111

109-
# Major.Minor
110-
PYTHON_VER=${PYTHON_VERSION%.*}
111-
# MajorMinor
112-
PYTAG=${PYTHON_VER/./}
113112

114113
if [[ ${PLATTAG} == win32 ]]; then
115114
CONDAPLATTAG=x86
@@ -119,7 +118,7 @@ fi
119118

120119

121120
BUILDBASE=${BUILDBASE:-./build}
122-
BASEDIR="${BUILDBASE:?}"/temp.${PLATTAG}-${PYTHON_VER}.conda-installer
121+
BASEDIR="${BUILDBASE:?}"/temp.${PLATTAG}.conda-installer
123122

124123
CACHEDIR=${CACHEDIR:-./build/download-cache}
125124
DISTDIR=${DISTDIR:-./dist}
@@ -185,6 +184,14 @@ fetch-miniconda() {
185184
fi
186185
}
187186

187+
188+
# extract Mayor.Minor.Micro python version string from a conda env spec file
189+
# contents read from stdin
190+
conda-env-spec-python-version() {
191+
grep -E "(^|.+/)python-(\d+.\d+.\d+)" | sed -n 's@.*python-\([^-]*\)-.*$@\1@p'
192+
}
193+
194+
188195
# $ conda-fetch-packages DESTDIR SPECFILE
189196
#
190197
# Given an conda env spec (as exported by `conda list --explicit`),
@@ -311,9 +318,9 @@ make-installer() {
311318
local major=$(version-component 1 "${versionstr}")
312319
local minor=$(version-component 2 "${versionstr}")
313320
local micro=$(version-component 3 "${versionstr}")
314-
local pymajor=$(version-component 1 "${PYTHON_VERSION}")
315-
local pyminor=$(version-component 2 "${PYTHON_VERSION}")
316-
local pymicro=$(version-component 3 "${PYTHON_VERSION}")
321+
local pymajor=$(version-component 1 "${PYTHON_VERSION:?}")
322+
local pyminor=$(version-component 2 "${PYTHON_VERSION:?}")
323+
local pymicro=$(version-component 3 "${PYTHON_VERSION:?}")
317324

318325
cat <<EOF > "${BASEDIR}"/license.txt
319326
Acknowledgments and License Agreement
@@ -355,12 +362,16 @@ if [[ "${ONLINE}" == yes ]]; then
355362
VERSION=$(cat < "${BASEDIR}"/conda-spec.txt |
356363
grep -E 'orange3-.*tar.bz2' |
357364
sed -e 's@^.*orange3-\([^-]*\)-.*tar.bz2.*@\1@')
365+
PYTHON_VERSION=$(conda-env-spec-python-version \
366+
< "${BASEDIR:?}"/conda-spec.txt)
358367
else
359368
conda-fetch-packages "${BASEDIR:?}"/conda-pkgs "${ENV_SPEC_FILE}"
360369
# extract the orange version from env spec
361370
VERSION=$(cat < "${BASEDIR:?}"/conda-pkgs/conda-spec.txt |
362371
grep -E 'orange3-.*tar.bz2' |
363372
cut -d "-" -f 2)
373+
PYTHON_VERSION=$(conda-env-spec-python-version \
374+
< "${BASEDIR:?}"/conda-pkgs/conda-spec.txt)
364375
fi
365376

366377
if [[ ! "${VERSION}" ]]; then

scripts/windows/orange-conda.nsi

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Required definitions need to be passed to the makensis call
66
# - BASEDIR base location of all required files, ... (see below)
77
# - PYARCH python architecture identifier (win32 or amd64)
8-
# - PY{MAJOR,MINOR,MICRO} Python version of the included installer
8+
# - PY{MAJOR,MINOR,MICRO} Python version to be installed in the new env
99
# - APPNAME Application (short) name
1010
# - VER{MAJOR,MINOR,MICRO} Application version
1111
# - PYINSTALLER basename of the Miniconda python installer
@@ -362,7 +362,7 @@ Function DirectoryLeave
362362
${Else}
363363
${LogWrite} "$InstDir is not empty, aborting"
364364
MessageBox MB_OK '"$InstDir" exists and is not empty.$\r$\n \
365-
Please choose annother destination folder.'
365+
Please choose another destination folder.'
366366
Abort '"$InstDir" exists an is not empty'
367367
${EndIf}
368368
${EndIf}
@@ -384,7 +384,7 @@ FunctionEnd
384384
# Section Miniconda
385385
# -----------------
386386
# A Miniconda Python distributions
387-
Section "Miniconda ${MINICONDA_VERSION} (Python ${PYTHON_VERSION} ${BITS}-bit)" \
387+
Section "Miniconda ${MINICONDA_VERSION}" \
388388
SectionMiniconda
389389
${GetAnyAnacondaInstall} $BasePythonPrefix $PythonInstallMode
390390
${If} $BasePythonPrefix != ""
@@ -407,10 +407,7 @@ Section "Miniconda ${MINICONDA_VERSION} (Python ${PYTHON_VERSION} ${BITS}-bit)"
407407
${If} $0 != 0
408408
Abort "Miniconda installation failed (error value: $0)"
409409
${EndIf}
410-
411-
${GetAnacondaInstall} ${PYMAJOR}${PYMINOR} ${BITS} \
412-
$BasePythonPrefix $PythonInstallMode
413-
410+
${GetAnyAnacondaInstall} $BasePythonPrefix $PythonInstallMode
414411
${IfNot} ${FileExists} "$BasePythonPrefix\python.exe"
415412
Abort "No python.exe found in $BasePythonPrefix$\r$\n \
416413
Cannot continue."

0 commit comments

Comments
 (0)