Skip to content

Commit

Permalink
Patch pyenv-build to not upgrade conda
Browse files Browse the repository at this point in the history
When installing miniconda3, `pyenv-build` calls:

  conda install --yes pip

which automatically updates conda to its latest version and making us lossing
our pinned version.

This commit adds a patch to keep installing pip after conda install, but pinning
conda to the current version to avoid upgrading it automatically.

See pyenv/pyenv#2070
  • Loading branch information
humitos committed Sep 23, 2021
1 parent 326b231 commit fba017d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scripts/compile_version_upload_s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,24 @@ OS="ubuntu-20.04"
TOOL=$1
VERSION=$2

# https://stackoverflow.com/questions/59895/how-can-i-get-the-source-directory-of-a-bash-script-from-within-the-script-itsel
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

# Spin up a container with the Ubuntu 20.04 LTS image
CONTAINER_ID=$(docker run --user docs --rm --detach readthedocs/build:$OS sleep $SLEEP)
CONTAINER_ID=$(docker run --user docs --rm --detach --volume ${SCRIPT_DIR}/python-build.diff:/tmp/python-build.diff readthedocs/build:$OS sleep $SLEEP)
echo "Running all the commands in Docker container: $CONTAINER_ID"

# Install the tool version requested
if [[ $TOOL == "python" ]]
then
# Download list for all Python to force pyenv to be installed
docker exec $CONTAINER_ID asdf list all python &> /dev/null
# Patch pyenv to not update conda when installing pip
# https://github.com/pyenv/pyenv/issues/2070
docker exec $CONTAINER_ID patch -p0 /home/docs/.asdf/plugins/python/pyenv/plugins/python-build/bin/python-build /tmp/python-build.diff
# Remove .git because otherwise the patch is reset
docker exec $CONTAINER_ID rm -rf /home/docs/.asdf/plugins/python/pyenv/.git

docker exec --env PYTHON_CONFIGURE_OPTS="--enable-shared" $CONTAINER_ID asdf install $TOOL $VERSION
else
docker exec $CONTAINER_ID asdf install $TOOL $VERSION
Expand Down
15 changes: 15 additions & 0 deletions scripts/python-build.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build
index a18680a4..ea976328 100755
--- a/plugins/python-build/bin/python-build
+++ b/plugins/python-build/bin/python-build
@@ -1042,7 +1042,9 @@ build_package_anaconda() {

build_package_miniconda() {
build_package_anaconda "$@"
- "${PREFIX_PATH}/bin/conda" install --yes "pip"
+ # Workaround to not upgrade conda when installing pip
+ # see https://github.com/pyenv/pyenv/issues/2070
+ "${PREFIX_PATH}/bin/conda" install --yes "pip" "conda=$(${PREFIX_PATH}/bin/conda --version | cut -d ' ' -f 2)"
}

build_package_copy() {

0 comments on commit fba017d

Please sign in to comment.