Skip to content

Commit

Permalink
Clean up build_python.sh
Browse files Browse the repository at this point in the history
This is in preparation for the eventual refactoring of the run_tests.py
system.
  • Loading branch information
soltanmm committed Oct 6, 2015
1 parent e1d8d4d commit 9554534
Showing 1 changed file with 49 additions and 13 deletions.
62 changes: 49 additions & 13 deletions tools/run_tests/build_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,46 @@ GRPCIO=$ROOT/src/python/grpcio
GRPCIO_TEST=$ROOT/src/python/grpcio_test
GRPCIO_HEALTH_CHECKING=$ROOT/src/python/grpcio_health_checking

#
# Dependency steps.
#
install_grpcio_deps() {
cd $GRPCIO
pip install -r requirements.txt
}
install_grpcio_test_deps() {
cd $GRPCIO_TEST
pip install -r requirements.txt
}
#
# End dependency steps.
#

#
# Install steps. Requires that the `pip` command is appropriate (i.e. that the
# virtual environment has been activated).
#
install_grpcio() {
CFLAGS="-I$ROOT/include -std=c89" LDFLAGS=-L$ROOT/libs/$CONFIG GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install $GRPCIO
}
install_grpcio_test() {
pip install $GRPCIO_TEST
}
install_grpcio_health_checking() {
pip install $GRPCIO_HEALTH_CHECKING
}
#
# End install steps.
#

# Cleans the environment of previous installations
clean_grpcio_all() {
(yes | pip uninstall grpcio) || true
(yes | pip uninstall grpcio_test) || true
(yes | pip uninstall grpcio_health_checking) || true
}

# Builds the testing environment.
make_virtualenv() {
virtualenv_name="python"$1"_virtual_environment"
if [ ! -d $virtualenv_name ]
Expand All @@ -48,33 +88,29 @@ make_virtualenv() {
source $virtualenv_name/bin/activate

# Install grpcio
cd $GRPCIO
pip install -r requirements.txt
CFLAGS="-I$ROOT/include -std=c89" LDFLAGS=-L$ROOT/libs/$CONFIG GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install $GRPCIO
install_grpcio_deps
install_grpcio

# Install grpcio_test
cd $GRPCIO_TEST
pip install -r requirements.txt
pip install $GRPCIO_TEST
install_grpcio_test_deps
install_grpcio_test

# Install grpcio_health_checking
pip install $GRPCIO_HEALTH_CHECKING
install_grpcio_health_checking
else
source $virtualenv_name/bin/activate
# Uninstall and re-install the packages we care about. Don't use
# --force-reinstall or --ignore-installed to avoid propagating this
# unnecessarily to dependencies. Don't use --no-deps to avoid missing
# dependency upgrades.
(yes | pip uninstall grpcio) || true
(yes | pip uninstall grpcio_test) || true
(yes | pip uninstall grpcio_health_checking) || true
(CFLAGS="-I$ROOT/include -std=c89" LDFLAGS=-L$ROOT/libs/$CONFIG GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install $GRPCIO) || (
clean_grpcio_all
install_grpcio || (
# Fall back to rebuilding the entire environment
rm -rf $virtualenv_name
make_virtualenv $1
)
pip install $GRPCIO_TEST
pip install $GRPCIO_HEALTH_CHECKING
install_grpcio_test
install_grpcio_health_checking
fi
}

Expand Down

0 comments on commit 9554534

Please sign in to comment.