From 6c714ae3b009f91ff430c6f29c9b07c3cd698d97 Mon Sep 17 00:00:00 2001
From: Amir MOHAMMADI <amir.mohammadi@idiap.ch>
Date: Tue, 11 Dec 2018 12:13:35 +0100
Subject: [PATCH] Setup condarc in pypi pushes as well

---
 gitlab/before_build.sh | 16 +---------------
 gitlab/functions.sh    | 24 ++++++++++++++++++++++++
 gitlab/pypi.sh         |  2 ++
 3 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/gitlab/before_build.sh b/gitlab/before_build.sh
index cfa6e93..046c0af 100755
--- a/gitlab/before_build.sh
+++ b/gitlab/before_build.sh
@@ -12,21 +12,7 @@ mkdir -p ${CONDA_ROOT}/pkgs
 touch ${CONDA_ROOT}/pkgs/urls
 touch ${CONDA_ROOT}/pkgs/urls.txt
 
-cat <<EOF > ${CONDARC}
-default_channels: #!final
-  - https://repo.anaconda.com/pkgs/main
-  - https://repo.anaconda.com/pkgs/free
-  - https://repo.anaconda.com/pkgs/r
-  - https://repo.anaconda.com/pkgs/pro
-add_pip_as_python_dependency: false #!final
-changeps1: false #!final
-always_yes: true #!final
-quiet: true #!final
-show_channel_urls: true #!final
-anaconda_upload: false #!final
-ssl_verify: false #!final
-channels: #!final
-EOF
+create_condarc ${CONDARC}
 
 if [[ "${STABLE}" == "true" ]]; then
   set_conda_channels ${VISIBILITY} "stable"
diff --git a/gitlab/functions.sh b/gitlab/functions.sh
index 35c213a..8276a86 100644
--- a/gitlab/functions.sh
+++ b/gitlab/functions.sh
@@ -367,6 +367,30 @@ install_miniconda() {
 }
 
 
+# Creates a sane base condarc file
+# $1: Path to where to populate the condarc file
+create_condarc() {
+  log_info "Populating the basic condarc file in ${1} ..."
+
+  cat <<EOF > ${1}
+default_channels: #!final
+  - https://repo.anaconda.com/pkgs/main
+  - https://repo.anaconda.com/pkgs/free
+  - https://repo.anaconda.com/pkgs/r
+  - https://repo.anaconda.com/pkgs/pro
+add_pip_as_python_dependency: false #!final
+changeps1: false #!final
+always_yes: true #!final
+quiet: true #!final
+show_channel_urls: true #!final
+anaconda_upload: false #!final
+ssl_verify: false #!final
+channels: #!final
+EOF
+
+}
+
+
 # sets CONDA_CHANNELS to the list of conda channels that should be considered
 # $1: visibility (maybe either "public" or "private")
 # $2: typically, the value of ${CI_COMMIT_TAG} or empty
diff --git a/gitlab/pypi.sh b/gitlab/pypi.sh
index e79ce86..7edfa02 100755
--- a/gitlab/pypi.sh
+++ b/gitlab/pypi.sh
@@ -3,6 +3,8 @@
 
 source $(dirname ${0})/functions.sh
 
+create_condarc ${CONDARC}
+
 if [ "${VISIBILITY}" != "public" ]; then
   log_warn "WARNING: You cannot publish a PRIVATE to PyPI"
   log_warn "WARNING: Make this package public if you wish to do so next time"
-- 
GitLab