mirror of
https://github.com/apache/impala.git
synced 2025-12-19 09:58:28 -05:00
In some build environments, the impala-shell Python 3
virtualenv install fails due to interactions with
shell/pkg_resources.py. This doesn't reproduce in the standard
development environment, but it is consistent. It seems to
be related to invoking a command in ${IMPALA_HOME}/shell
and the pkg_resources.py being in that directory.
To avoid any interactions, this moves shell/pkg_resources.py
to shell/legacy/pkg_resources.py. This keeps it off of the
path for the failing command, and it also keeps it off of
our PYTHONPATH (which includes ${IMPALA_HOME}/shell).
Testing:
- Ran a build in the affected build environment
- Ran a core job
Change-Id: Id8f2d8a8472c7bb405bf88673ed9779e23cde1d6
Reviewed-on: http://gerrit.cloudera.org:8080/20468
Reviewed-by: Michael Smith <michael.smith@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
76 lines
2.3 KiB
Bash
Executable File
76 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
# or more contributor license agreements. See the NOTICE file
|
|
# distributed with this work for additional information
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
# to you under the Apache License, Version 2.0 (the
|
|
# "License"); you may not use this file except in compliance
|
|
# with the License. You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing,
|
|
# software distributed under the License is distributed on an
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
# KIND, either express or implied. See the License for the
|
|
# specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
set -euo pipefail
|
|
|
|
pushd ${IMPALA_HOME} > /dev/null 2>&1
|
|
|
|
RETCODE=0
|
|
for file in $(git ls-files '**/*.py'); do
|
|
# Skip the shell's ext-py code
|
|
if [[ "${file}" =~ "shell/ext-py" ]]; then
|
|
continue
|
|
fi
|
|
# Skip the shell's pkg_resources.py
|
|
if [[ "${file}" == "shell/legacy/pkg_resources.py" ]]; then
|
|
continue
|
|
fi
|
|
|
|
# Python 2 checks
|
|
# -l = no recursion
|
|
# -q = only print errors
|
|
# -f = force recompile
|
|
# Ignore files that are created to run with python3.
|
|
FIRST_LINE=$(head -n1 ${file})
|
|
if [[ "${FIRST_LINE}" =~ "python3" ]]; then
|
|
>&2 echo "SKIPPING: ${file} is already using python3: ${FIRST_LINE}"
|
|
elif ! python2 -m compileall -l -q -f ${file} > /dev/null 2>&1; then
|
|
RETCODE=1
|
|
echo "Python 2 compilation failed for ${file}:"
|
|
set +e
|
|
python2 -m compileall -l -q -f ${file}
|
|
set -e
|
|
fi
|
|
# Clean up the .pyc files generated by compilation
|
|
if [[ -f "${file}c" ]]; then
|
|
rm "${file}c"
|
|
fi
|
|
|
|
# Python 3 checks
|
|
# -l = no recursion
|
|
# -q = only print errors
|
|
# -f = force recompile
|
|
if ! python3 -m compileall -l -q -f ${file} > /dev/null 2>&1 ; then
|
|
RETCODE=1
|
|
echo "Python 3 compilation failed for ${file}:"
|
|
set +e
|
|
python3 -m compileall -l -q -f ${file}
|
|
set -e
|
|
fi
|
|
# Clean up the __pycache__ directories generated by compilation
|
|
py_cache_dir="$(dirname ${file})/__pycache__"
|
|
if [[ -d "${py_cache_dir}" ]]; then
|
|
rm -rf ${py_cache_dir}
|
|
fi
|
|
done
|
|
|
|
popd > /dev/null 2>&1
|
|
|
|
exit ${RETCODE}
|