HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: //snap/google-cloud-cli/396/platform/gsutil/third_party/httplib2/script/compile-py3-openssl11.sh
#!not for running standalone, see .github/workflows/test.yaml

cache_dir=$HOME/.cache
install_dir=$cache_dir/py3-openssl11
python_version="3.7.3"
openssl_version="1.1.1f"
cpucount=$(nproc --all)
export PYTHONDONTWRITEBYTECODE=1

#rm -rf $cache_dir/* # uncomment to rebuild

if [[ ! -x "$install_dir/bin/python" ]] || [[ $($install_dir/bin/python -V) != "Python $python_version" ]] ; then
  (
  mkdir -p /tmp/source
  cd /tmp/source
  # Compile OpenSSL
  curl -fLOsS "https://www.openssl.org/source/openssl-$openssl_version.tar.gz"
  echo "Extracting OpenSSL..."
  tar xf openssl-$openssl_version.tar.gz
  cd ./openssl-$openssl_version
  echo "Compiling OpenSSL $openssl_version..."
  ./config shared --prefix=$install_dir
  echo "Running make for OpenSSL..."
  make -j$cpucount -s
  echo "Running make install for OpenSSL..."
  make install_sw >/dev/null
  export LD_LIBRARY_PATH=$install_dir/lib

  cd /tmp/source
  sudo apt install -qq --yes libffi-dev
  # Compile latest Python
  curl -fLOsS "https://www.python.org/ftp/python/$python_version/Python-$python_version.tar.xz"
  echo "Extracting Python..."
  tar xf Python-$python_version.tar.xz
  cd ./Python-$python_version
  echo "Compiling Python $python_version..."
  # Note we are purposefully NOT using optimization flags as they increase compile time 10x
  conf_flags="--with-openssl=$install_dir --prefix=$install_dir --with-ensurepip=upgrade"
  CFLAGS=-O1 ./configure $conf_flags > /dev/null
  make -j$cpucount -s
  echo "Installing Python..."
  make altinstall bininstall >/dev/null
  ln -fs pip3.7 $install_dir/bin/pip3
  ln -fs pip3 $install_dir/bin/pip
  ln -fs python3 $install_dir/bin/python
  # care for CI cache size
  find $install_dir -type d -name __pycache__ -print0 |xargs -0 rm -rf
  )
fi

export LD_LIBRARY_PATH=$install_dir/lib
export PATH=$install_dir/bin:$PATH
if [[ $(python -V) != "Python $python_version" ]] ; then
  echo "Required Python version was not installed into PATH" >&2
  exit 1
fi
if [[ $(python -c 'import ssl; print(ssl.OPENSSL_VERSION)') != OpenSSL\ ${openssl_version}* ]] ; then
  echo "Required OpenSSL version was not installed into Python" >&2
  exit 1
fi