Skip to content

Commit

Permalink
Properly deactivate old virtualenv; use the shared third-party direct…
Browse files Browse the repository at this point in the history
…ory automatically when running in an NFS build environment

Summary:
- Do not try to "pip install --user" inside a virtualenv. We need to properly deactivate the old virtualenv in that case.
- When building in an NFS distributed build environment, run CMake with compiler invoked on the local machine.
- Use the shared thirdparty build by default in the NFS environment.

Test Plan: Jenkins

Reviewers: bogdan, bharat

Reviewed By: bharat

Subscribers: ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D4805
  • Loading branch information
mbautin committed May 16, 2018
1 parent cc2f69d commit 8b713a7
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ oprofile_data
*.iml

# VIM/emacs stuff
*.swp
*.sw?
*~
# These files could be used to auto-save vim sessions.
.session.vim
Expand Down
17 changes: 13 additions & 4 deletions build-support/common-build-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1561,21 +1561,30 @@ activate_virtualenv() {
unset YB_RECREATE_VIRTUALENV
fi
if [[ ! -d $virtualenv_dir ]]; then
if [[ -n ${VIRTUAL_ENV:-} && -f $VIRTUAL_ENV/bin/activate ]]; then
local old_virtual_env=$VIRTUAL_ENV
# Re-activate and deactivate the other virtualenv we're in. Otherwise the deactivate
# function might not even be present in our current shell. This is necessary because otherwise
# the --user installation below will fail.
set +eu
. "$VIRTUAL_ENV/bin/activate"
deactivate
set -eu
# Not clear why deactivate does not do this.
remove_path_entry "$old_virtual_env/bin"
fi
# We need to be using system python to install the virtualenv module or create a new virtualenv.
pip2 install virtualenv --user
(
set -x
mkdir -p "$virtualenv_parent_dir"
cd "$virtualenv_parent_dir"
python2.7 -m virtualenv "$YB_VIRTUALENV_BASENAME"
python2 -m virtualenv "$YB_VIRTUALENV_BASENAME"
)
fi
set +u
. "$virtualenv_dir"/bin/activate
# We unset the pythonpath to make sure we aren't looking at the global pythonpath.
unset PYTHONPATH
set -u
export PYTHONPATH=$YB_SRC_ROOT/python:$virtualenv_dir/lib/python2.7/site-packages
pip2 install -r "$YB_SRC_ROOT/requirements.txt"
add_python_wrappers_dir_to_path
}
Expand Down
35 changes: 32 additions & 3 deletions yb_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ script_name=${script_name%.*}

show_help() {
cat >&2 <<-EOT
yb_build.sh (or "ybd") is the main build tool for YugaByte Database.
Usage: ${0##*/} [<options>] [<build_type>] [<target_keywords>]
Options:
-h, --help
Expand Down Expand Up @@ -228,6 +229,10 @@ print_report() {
thick_horizontal_line
print_report_line "%s" "Build type" "${build_type:-undefined}"
print_report_line "%s" "Edition" "${YB_EDITION:-undefined}"
print_report_line "%s" "Third-party dir" "${YB_THIRDPARTY_DIR:-undefined}"
if ! is_mac; then
print_report_line "%s" "Linuxbrew dir" "${YB_LINUXBREW_DIR:-undefined}"
fi
report_time "CMake" "cmake"
report_time "C++ compilation" "make"
report_time "Java compilation" "java_build"
Expand All @@ -254,6 +259,9 @@ build_root: "$BUILD_ROOT"
compiler_type: "$YB_COMPILER_TYPE"
thirdparty_dir: "${YB_THIRDPARTY_DIR:-$YB_SRC_ROOT/thirdparty}"
EOT
if ! is_mac; then
echo "linuxbrew_dir: \"${YB_LINUXBREW_DIR:-}\"" >>"$build_descriptor_path"
fi
log "Created a build descriptor file at '$build_descriptor_path'"
fi
}
Expand All @@ -273,7 +281,14 @@ run_cxx_build() {
log "Using cmake binary: $( which cmake )"
log "Running cmake in $PWD"
capture_sec_timestamp "cmake_start"
( set -x; cmake "${cmake_opts[@]}" $cmake_extra_args "$YB_SRC_ROOT" )
(
# Always disable remote build (running the compiler on a remote worker node) when running the
# CMake step.
set -x
unset YB_REMOTE_BUILD
export YB_NO_REMOTE_BUILD=1
cmake "${cmake_opts[@]}" $cmake_extra_args "$YB_SRC_ROOT"
)
capture_sec_timestamp "cmake_end"
fi

Expand Down Expand Up @@ -510,6 +525,7 @@ mvn_opts=""
java_only=false
cmake_only=false
use_shared_thirdparty=false
no_shared_thirdparty=false
run_python_tests=false
cmake_extra_args=""
predefined_build_root=""
Expand Down Expand Up @@ -622,6 +638,9 @@ while [[ $# -gt 0 ]]; do
--use-shared-thirdparty|--ustp|--stp|--us3p|--s3p)
use_shared_thirdparty=true
;;
--no-shared-thirdparty|--nstp|ns3p)
no_shared_thirdparty=true
;;
--show-compiler-cmd-line|--sccl)
export YB_SHOW_COMPILER_COMMAND_LINE=1
;;
Expand Down Expand Up @@ -880,11 +899,21 @@ if [[ ${YB_SKIP_BUILD:-} == "1" ]]; then
set_flags_to_skip_build
fi

if "$use_shared_thirdparty" || [[ -f $YB_SRC_ROOT/thirdparty/.yb_thirdparty_do_not_use ]]; then
find_thirdparty_dir
if "$use_shared_thirdparty" && "$no_shared_thirdparty"; then
fatal "--use-shared-thirdparty and --no-shared-thirdparty cannot be specified at the same time"
fi

configure_remote_build
do_not_use_local_thirdparty_flag_path=$YB_SRC_ROOT/thirdparty/.yb_thirdparty_do_not_use

if [[ -f $do_not_use_local_thirdparty_flag_path ]] || \
"$use_shared_thirdparty" || \
is_remote_build && ! "$no_shared_thirdparty"; then
find_thirdparty_dir
fi

echo "Using third-party directory (YB_THIRDPARTY_DIR): $YB_THIRDPARTY_DIR"

detect_edition

if "$save_log"; then
Expand Down
1 change: 1 addition & 0 deletions yb_release
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ set -euo pipefail
. "${BASH_SOURCE%/*}/build-support/common-build-env.sh"

activate_virtualenv
export PYTHONPATH=$YB_SRC_ROOT/python:${PYTHONPATH:-}
"$YB_SRC_ROOT"/build-support/yb_release.py "$@"

0 comments on commit 8b713a7

Please sign in to comment.