Files
impala/shell/packaging/__init__.py
David Knupp ba808f67dd IMPALA-1071: Distributable python package for impala-shell
The patch adds a set of scripts for converting the impala-shell
into a true distributable python package. The package can be
installed using familiar python commands, e.g.:

  $ python setup.py (install|develop)

or

  $ pip install -e /path/to/dist/dir

The entry point script, make_python_package.sh, will run as a
part of the standard sequence of steps that results from calling
buildall.sh, and will produce a gzipped tarball inside of
Impala/shell/dist as an artifact. Thereafter, make_python_package.sh
can be run manually any time.

The expectation is that an official maintainer would need to manually
upload official releases to the Python Package Index as appropriate.

Change-Id: Ib8c745bddddf6a16f0c039430152745a2f00e044
Reviewed-on: http://gerrit.cloudera.org:8080/14181
Reviewed-by: David Knupp <dknupp@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2019-10-10 06:50:50 +00:00

41 lines
2.0 KiB
Python

#!/usr/bin/env python
#
# 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.
from os.path import dirname, abspath
import sys
# When installing the python shell as a standalone package, this __init__ is
# used to workaround the issues stemming from IMPALA-6808. Because of the way
# the Impala python environment has been somewhat haphazardly constructed in
# a deployed cluster, it ends up being "polluted" with top-level modules that
# should really be sub-modules. One of the principal places this occurs is with
# the various modules required by the Impala shell. This isn't a concern when
# the shell is invoked via a specially installed version of python that belongs
# to Impala, but it does become an issue when the shell is being run using the
# system python.
#
# If we want to install the shell as a standalone package, we need to construct
# it in such a way that all of the internal modules are contained within a
# top-level impala_shell namespace. However, this then breaks various imports
# throughout the Impala shell code. The way this file corrects that is to add
# the impala_shell directory to PYTHONPATH only when the shell is invoked. As
# far as I can tell, there's no cleaner way to address this without fully
# resolving IMPALA-6808.
impala_shell_dir = dirname(abspath(__file__))
sys.path.append(impala_shell_dir)