44set -e
55
66function usage() {
7- echo ' build-conda-installer.sh
7+ echo " build-conda-installer.sh
88
99Build 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
1212Note: Needs basic bash env on Windows (git-bash is sufficient/tested, but
1313 cygwin should work too)
1414
1515Options:
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:
3235Examples
3336
3437 $ ./scripts/windows/build-conda-installer.sh --online=yes
35- '
38+ "
3639}
3740
3841NAME=Orange3
3942# version is determined from the ENV_SPEC_FILE
4043VERSION=
4144
42- PYTHON=
4345BUILDBASE=
4446DISTDIR=
4547CACHEDIR=
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
5154PLATTAG=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
9198done
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
98101if [[ ! ${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
107110fi
108111
109- # Major.Minor
110- PYTHON_VER=${PYTHON_VERSION% .* }
111- # MajorMinor
112- PYTAG=${PYTHON_VER/ ./ }
113112
114113if [[ ${PLATTAG} == win32 ]]; then
115114 CONDAPLATTAG=x86
119118
120119
121120BUILDBASE=${BUILDBASE:- ./ build}
122- BASEDIR=" ${BUILDBASE:? } " /temp.${PLATTAG} - ${PYTHON_VER} .conda-installer
121+ BASEDIR=" ${BUILDBASE:? } " /temp.${PLATTAG} .conda-installer
123122
124123CACHEDIR=${CACHEDIR:- ./ build/ download-cache}
125124DISTDIR=${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
319326Acknowledgments 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)
358367else
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)
364375fi
365376
366377if [[ ! " ${VERSION} " ]]; then
0 commit comments