PHOENIX-4688 Support SPNEGO for python driver via requests-kerberos

Includes updated L&N for requests-kerberos. Tries to detect when the
host system doesn't have necessary dependencies to run the test

Closes #344

Signed-off-by: Josh Elser <els...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/ec3542d6
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ec3542d6
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ec3542d6

Branch: refs/heads/4.x-HBase-1.2
Commit: ec3542d6fdd21adc82ce881772130fdb9a054e6c
Parents: 8aff895
Author: Lev Bronshtein <lbronsht...@bloomberg.net>
Authored: Wed Aug 29 17:19:51 2018 -0400
Committer: Josh Elser <els...@apache.org>
Committed: Fri Oct 5 18:48:21 2018 -0400

----------------------------------------------------------------------
 LICENSE                                         |   18 +
 NOTICE                                          |    2 +
 dev/release_files/LICENSE                       |   18 +
 dev/release_files/NOTICE                        |    4 +
 .../src/it/bin/test_phoenixdb.py                |   39 +
 .../src/it/bin/test_phoenixdb.sh                |   79 +
 .../end2end/SecureQueryServerPhoenixDBIT.java   |  424 +++++
 pom.xml                                         |   14 +-
 python/NEWS.rst                                 |   44 -
 python/README.md                                |   93 +
 python/README.rst                               |  136 --
 python/RELEASING.rst                            |   12 -
 python/ci/build-env/Dockerfile                  |    7 -
 python/ci/phoenix/Dockerfile                    |   33 -
 python/ci/phoenix/docker-entrypoint.sh          |   24 -
 python/ci/phoenix/hbase-site.xml                |   12 -
 python/doc/Makefile                             |  192 --
 python/doc/api.rst                              |   30 -
 python/doc/conf.py                              |  287 ---
 python/doc/index.rst                            |   27 -
 python/doc/versions.rst                         |    3 -
 python/docker-compose.yml                       |   21 -
 python/examples/basic.py                        |   27 -
 python/examples/shell.py                        |   33 -
 python/gen-protobuf.sh                          |   38 -
 python/phoenixdb/NEWS.rst                       |   44 +
 python/phoenixdb/README.rst                     |  136 ++
 python/phoenixdb/RELEASING.rst                  |   12 +
 python/phoenixdb/__init__.py                    |   68 -
 python/phoenixdb/avatica/__init__.py            |   16 -
 python/phoenixdb/avatica/client.py              |  510 ------
 python/phoenixdb/avatica/proto/__init__.py      |    0
 python/phoenixdb/avatica/proto/common_pb2.py    | 1667 ------------------
 python/phoenixdb/avatica/proto/requests_pb2.py  | 1206 -------------
 python/phoenixdb/avatica/proto/responses_pb2.py |  917 ----------
 python/phoenixdb/ci/build-env/Dockerfile        |    7 +
 python/phoenixdb/ci/phoenix/Dockerfile          |   33 +
 .../phoenixdb/ci/phoenix/docker-entrypoint.sh   |   24 +
 python/phoenixdb/ci/phoenix/hbase-site.xml      |   12 +
 python/phoenixdb/connection.py                  |  187 --
 python/phoenixdb/cursor.py                      |  347 ----
 python/phoenixdb/doc/Makefile                   |  192 ++
 python/phoenixdb/doc/api.rst                    |   30 +
 python/phoenixdb/doc/conf.py                    |  287 +++
 python/phoenixdb/doc/index.rst                  |   27 +
 python/phoenixdb/doc/versions.rst               |    3 +
 python/phoenixdb/docker-compose.yml             |   21 +
 python/phoenixdb/errors.py                      |   93 -
 python/phoenixdb/examples/basic.py              |   27 +
 python/phoenixdb/examples/shell.py              |   33 +
 python/phoenixdb/gen-protobuf.sh                |   39 +
 python/phoenixdb/phoenixdb/__init__.py          |   72 +
 python/phoenixdb/phoenixdb/avatica/__init__.py  |   16 +
 python/phoenixdb/phoenixdb/avatica/client.py    |  502 ++++++
 .../phoenixdb/avatica/proto/__init__.py         |    0
 .../phoenixdb/avatica/proto/common_pb2.py       | 1667 ++++++++++++++++++
 .../phoenixdb/avatica/proto/requests_pb2.py     | 1206 +++++++++++++
 .../phoenixdb/avatica/proto/responses_pb2.py    |  917 ++++++++++
 python/phoenixdb/phoenixdb/connection.py        |  187 ++
 python/phoenixdb/phoenixdb/cursor.py            |  347 ++++
 python/phoenixdb/phoenixdb/errors.py            |   93 +
 python/phoenixdb/phoenixdb/tests/__init__.py    |   44 +
 python/phoenixdb/phoenixdb/tests/dbapi20.py     |  857 +++++++++
 .../phoenixdb/phoenixdb/tests/test_avatica.py   |   25 +
 .../phoenixdb/tests/test_connection.py          |   42 +
 python/phoenixdb/phoenixdb/tests/test_db.py     |   99 ++
 .../phoenixdb/phoenixdb/tests/test_dbapi20.py   |  122 ++
 python/phoenixdb/phoenixdb/tests/test_errors.py |   60 +
 python/phoenixdb/phoenixdb/tests/test_types.py  |  327 ++++
 python/phoenixdb/phoenixdb/types.py             |  202 +++
 python/phoenixdb/requirements.txt               |   25 +
 python/phoenixdb/setup.cfg                      |   34 +
 python/phoenixdb/setup.py                       |   69 +
 python/phoenixdb/tests/__init__.py              |   44 -
 python/phoenixdb/tests/dbapi20.py               |  857 ---------
 python/phoenixdb/tests/test_avatica.py          |   25 -
 python/phoenixdb/tests/test_connection.py       |   42 -
 python/phoenixdb/tests/test_db.py               |   99 --
 python/phoenixdb/tests/test_dbapi20.py          |  122 --
 python/phoenixdb/tests/test_errors.py           |   60 -
 python/phoenixdb/tests/test_types.py            |  327 ----
 python/phoenixdb/tox.ini                        |   24 +
 python/phoenixdb/types.py                       |  202 ---
 python/requests-kerberos/.travis.sh             |  202 +++
 python/requests-kerberos/.travis.yml            |   36 +
 python/requests-kerberos/AUTHORS                |    3 +
 python/requests-kerberos/HISTORY.rst            |  102 ++
 python/requests-kerberos/LICENSE                |   15 +
 python/requests-kerberos/MANIFEST.in            |    5 +
 python/requests-kerberos/README.rst             |  173 ++
 .../requests_kerberos/__init__.py               |   25 +
 .../requests_kerberos/compat.py                 |   14 +
 .../requests_kerberos/exceptions.py             |   15 +
 .../requests_kerberos/kerberos_.py              |  457 +++++
 python/requests-kerberos/requirements-test.txt  |    4 +
 python/requests-kerberos/requirements.txt       |    6 +
 python/requests-kerberos/setup.cfg              |    2 +
 python/requests-kerberos/setup.py               |   64 +
 python/requests-kerberos/tests/__init__.py      |    0
 .../tests/test_functional_kerberos.py           |   47 +
 .../tests/test_requests_kerberos.py             |  904 ++++++++++
 python/requirements.txt                         |   20 -
 python/setup.cfg                                |   34 -
 python/setup.py                                 |   64 -
 python/tox.ini                                  |   24 -
 105 files changed, 10623 insertions(+), 7863 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index 7bd8ad1..d820ad7 100644
--- a/LICENSE
+++ b/LICENSE
@@ -373,3 +373,21 @@ fonts, including any derivative works, can be bundled, 
embedded,
   DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
   OTHER DEALINGS IN THE FONT SOFTWARE.
+
+---
+
+ISC License
+
+Copyright (c) 2012 Kenneth Reitz
+
+Permission to use, copy, modify and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS-IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
index 8b2b647..58b8f67 100644
--- a/NOTICE
+++ b/NOTICE
@@ -21,3 +21,5 @@ The file bin/daemon.py is based on the file of the same name 
in python-daemon 2.
 # Copyright © 2001 Jürgen Hermann
 
 The file bin/argparse-1.4.0/argparse.py is (c) 2006-2009 Steven J. Bethard 
<steven.beth...@gmail.com>.
+
+python/requests-kerberos contains the Requests-Kerberos project which carries 
"Copyright (c) 2012 Kenneth Reitz"

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/dev/release_files/LICENSE
----------------------------------------------------------------------
diff --git a/dev/release_files/LICENSE b/dev/release_files/LICENSE
index 0fd0255..4577518 100644
--- a/dev/release_files/LICENSE
+++ b/dev/release_files/LICENSE
@@ -1813,3 +1813,21 @@ Creative Commons Attribution 3.0
       Except for the limited purpose of indicating to the public that the Work 
is licensed under the CCPL, Creative Commons does not authorize the use by 
either party of the trademark "Creative Commons" or any related trademark or 
logo of Creative Commons without the prior written consent of Creative Commons. 
Any permitted use will be in compliance with Creative Commons' then-current 
trademark usage guidelines, as may be published on its website or otherwise 
made available upon request from time to time. For the avoidance of doubt, this 
trademark restriction does not form part of this License.
 
       Creative Commons may be contacted at https://creativecommons.org/.
+
+---
+
+ISC License
+
+Copyright (c) 2012 Kenneth Reitz
+
+Permission to use, copy, modify and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS-IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/dev/release_files/NOTICE
----------------------------------------------------------------------
diff --git a/dev/release_files/NOTICE b/dev/release_files/NOTICE
index b7b40c0..a8da9c8 100644
--- a/dev/release_files/NOTICE
+++ b/dev/release_files/NOTICE
@@ -285,3 +285,7 @@ stream-lib
   This product also includes code adapted from:
     - software copyright (c) 2014 The Apache Software Foundation., 
http://lucene.apache.org/solr/
     - software copyright (c) 2014 The Apache Software Foundation., 
http://mahout.apache.org/
+
+requests-kerberos
+
+  Copyright (c) 2012 Kenneth Reitz

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/phoenix-queryserver/src/it/bin/test_phoenixdb.py
----------------------------------------------------------------------
diff --git a/phoenix-queryserver/src/it/bin/test_phoenixdb.py 
b/phoenix-queryserver/src/it/bin/test_phoenixdb.py
new file mode 100644
index 0000000..0d5d0c6
--- /dev/null
+++ b/phoenix-queryserver/src/it/bin/test_phoenixdb.py
@@ -0,0 +1,39 @@
+############################################################################
+#
+# 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.
+#
+############################################################################
+
+import phoenixdb
+import phoenixdb.cursor
+import sys
+
+
+if __name__ == '__main__':
+    pqs_port = sys.argv[1]
+    database_url = 'http://localhost:' + str(pqs_port) + '/'
+
+    print("CREATING PQS CONNECTION")
+    conn = phoenixdb.connect(database_url, autocommit=True, auth="SPNEGO")
+    cursor = conn.cursor()
+
+    cursor.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username 
VARCHAR)")
+    cursor.execute("UPSERT INTO users VALUES (?, ?)", (1, 'admin'))
+    cursor.execute("UPSERT INTO users VALUES (?, ?)", (2, 'user'))
+    cursor.execute("SELECT * FROM users")
+    print("RESULTS")
+    print(cursor.fetchall())

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/phoenix-queryserver/src/it/bin/test_phoenixdb.sh
----------------------------------------------------------------------
diff --git a/phoenix-queryserver/src/it/bin/test_phoenixdb.sh 
b/phoenix-queryserver/src/it/bin/test_phoenixdb.sh
new file mode 100755
index 0000000..7309dbe
--- /dev/null
+++ b/phoenix-queryserver/src/it/bin/test_phoenixdb.sh
@@ -0,0 +1,79 @@
+#!/usr/bin/env 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 -u
+set -x
+set -e
+
+function cleanup {
+    # Capture last command status
+    RCODE=$?
+    set +e
+    set +u
+    kdestroy
+    rm -rf $PY_ENV_PATH
+    exit $RCODE
+}
+
+trap cleanup EXIT
+
+echo "LAUNCHING SCRIPT"
+
+LOCAL_PY=$1
+PRINC=$2
+KEYTAB_LOC=$3
+KRB5_CFG_FILE=$4
+PQS_PORT=$5
+PYTHON_SCRIPT=$6
+
+PY_ENV_PATH=$( mktemp -d )
+
+virtualenv $PY_ENV_PATH
+
+pushd ${PY_ENV_PATH}/bin
+
+# conda activate does stuff with unbound variables :(
+set +u
+. activate ""
+
+popd
+
+set -u
+echo "INSTALLING COMPONENTS"
+pip install -e file:///${LOCAL_PY}/requests-kerberos
+pip install -e file:///${LOCAL_PY}/phoenixdb
+
+export KRB5_CONFIG=$KRB5_CFG_FILE
+cat $KRB5_CONFIG
+export KRB5_TRACE=/dev/stdout
+
+echo "RUNNING KINIT"
+kinit -kt $KEYTAB_LOC $PRINC
+klist
+
+unset http_proxy
+unset https_proxy
+
+echo "Working Directory is ${PWD}"
+
+echo "RUN PYTHON TEST on port $PQS_PORT"
+python $PYTHON_SCRIPT $PQS_PORT

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/phoenix-queryserver/src/it/java/org/apache/phoenix/end2end/SecureQueryServerPhoenixDBIT.java
----------------------------------------------------------------------
diff --git 
a/phoenix-queryserver/src/it/java/org/apache/phoenix/end2end/SecureQueryServerPhoenixDBIT.java
 
b/phoenix-queryserver/src/it/java/org/apache/phoenix/end2end/SecureQueryServerPhoenixDBIT.java
new file mode 100644
index 0000000..205a831
--- /dev/null
+++ 
b/phoenix-queryserver/src/it/java/org/apache/phoenix/end2end/SecureQueryServerPhoenixDBIT.java
@@ -0,0 +1,424 @@
+/*
+ * 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.
+ */
+package org.apache.phoenix.end2end;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.lang.reflect.Field;
+import java.nio.file.Paths;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.LocalHBaseCluster;
+import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
+import org.apache.hadoop.hbase.http.ssl.KeyStoreTestUtil;
+import org.apache.hadoop.hbase.security.HBaseKerberosUtils;
+import org.apache.hadoop.hbase.security.token.TokenProvider;
+import org.apache.hadoop.hbase.util.FSUtils;
+import org.apache.hadoop.hdfs.DFSConfigKeys;
+import org.apache.hadoop.http.HttpConfig;
+import org.apache.hadoop.minikdc.MiniKdc;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.security.authentication.util.KerberosName;
+import org.apache.phoenix.query.ConfigurationFactory;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.queryserver.client.ThinClientUtil;
+import org.apache.phoenix.queryserver.server.QueryServer;
+import org.apache.phoenix.util.InstanceResolver;
+import org.junit.AfterClass;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+
+/**
+ * This integration test stands up a secured PQS and runs Python code against 
it. See supporting
+ * files in phoenix-queryserver/src/it/bin.
+ */
+@Category(NeedsOwnMiniClusterTest.class)
+public class SecureQueryServerPhoenixDBIT {
+    private static enum Kdc {
+      MIT,
+      HEIMDAL;
+    }
+    private static final Logger LOG = 
LoggerFactory.getLogger(SecureQueryServerPhoenixDBIT.class);
+
+    private static final File TEMP_DIR = new File(getTempDirForClass());
+    private static final File KEYTAB_DIR = new File(TEMP_DIR, "keytabs");
+    private static final List<File> USER_KEYTAB_FILES = new ArrayList<>();
+
+    private static final String SPNEGO_PRINCIPAL = "HTTP/localhost";
+    private static final String PQS_PRINCIPAL = "phoenixqs/localhost";
+    private static final String SERVICE_PRINCIPAL = "securecluster/localhost";
+    private static File KEYTAB;
+
+    private static MiniKdc KDC;
+    private static HBaseTestingUtility UTIL = new HBaseTestingUtility();
+    private static LocalHBaseCluster HBASE_CLUSTER;
+    private static int NUM_CREATED_USERS;
+
+    private static ExecutorService PQS_EXECUTOR;
+    private static QueryServer PQS;
+    private static int PQS_PORT;
+    private static String PQS_URL;
+
+    private static String getTempDirForClass() {
+        StringBuilder sb = new StringBuilder(32);
+        sb.append(System.getProperty("user.dir")).append(File.separator);
+        sb.append("target").append(File.separator);
+        sb.append(SecureQueryServerPhoenixDBIT.class.getSimpleName());
+        return sb.toString();
+    }
+
+    private static void updateDefaultRealm() throws Exception {
+        // (at least) one other phoenix test triggers the caching of this 
field before the KDC is up
+        // which causes principal parsing to fail.
+        Field f = KerberosName.class.getDeclaredField("defaultRealm");
+        f.setAccessible(true);
+        // Default realm for MiniKDC
+        f.set(null, "EXAMPLE.COM");
+    }
+
+    private static void createUsers(int numUsers) throws Exception {
+        assertNotNull("KDC is null, was setup method called?", KDC);
+        NUM_CREATED_USERS = numUsers;
+        for (int i = 1; i <= numUsers; i++) {
+            String principal = "user" + i;
+            File keytabFile = new File(KEYTAB_DIR, principal + ".keytab");
+            KDC.createPrincipal(keytabFile, principal);
+            USER_KEYTAB_FILES.add(keytabFile);
+        }
+    }
+
+    private static Entry<String,File> getUser(int offset) {
+        Preconditions.checkArgument(offset > 0 && offset <= NUM_CREATED_USERS);
+        return Maps.immutableEntry("user" + offset, 
USER_KEYTAB_FILES.get(offset - 1));
+    }
+
+    /**
+     * Setup the security configuration for hdfs.
+     */
+    private static void setHdfsSecuredConfiguration(Configuration conf) throws 
Exception {
+        // Set principal+keytab configuration for HDFS
+        conf.set(DFSConfigKeys.DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY, 
SERVICE_PRINCIPAL + "@" + KDC.getRealm());
+        conf.set(DFSConfigKeys.DFS_NAMENODE_KEYTAB_FILE_KEY, 
KEYTAB.getAbsolutePath());
+        conf.set(DFSConfigKeys.DFS_DATANODE_KERBEROS_PRINCIPAL_KEY, 
SERVICE_PRINCIPAL + "@" + KDC.getRealm());
+        conf.set(DFSConfigKeys.DFS_DATANODE_KEYTAB_FILE_KEY, 
KEYTAB.getAbsolutePath());
+        conf.set(DFSConfigKeys.DFS_WEB_AUTHENTICATION_KERBEROS_PRINCIPAL_KEY, 
SPNEGO_PRINCIPAL + "@" + KDC.getRealm());
+        // Enable token access for HDFS blocks
+        conf.setBoolean(DFSConfigKeys.DFS_BLOCK_ACCESS_TOKEN_ENABLE_KEY, true);
+        // Only use HTTPS (required because we aren't using "secure" ports)
+        conf.set(DFSConfigKeys.DFS_HTTP_POLICY_KEY, 
HttpConfig.Policy.HTTPS_ONLY.name());
+        // Bind on localhost for spnego to have a chance at working
+        conf.set(DFSConfigKeys.DFS_NAMENODE_HTTPS_ADDRESS_KEY, "localhost:0");
+        conf.set(DFSConfigKeys.DFS_DATANODE_HTTPS_ADDRESS_KEY, "localhost:0");
+
+        // Generate SSL certs
+        File keystoresDir = new 
File(UTIL.getDataTestDir("keystore").toUri().getPath());
+        keystoresDir.mkdirs();
+        String sslConfDir = 
KeyStoreTestUtil.getClasspathDir(SecureQueryServerPhoenixDBIT.class);
+        KeyStoreTestUtil.setupSSLConfig(keystoresDir.getAbsolutePath(), 
sslConfDir, conf, false);
+
+        // Magic flag to tell hdfs to not fail on using ports above 1024
+        conf.setBoolean("ignore.secure.ports.for.testing", true);
+    }
+
+    private static void ensureIsEmptyDirectory(File f) throws IOException {
+        if (f.exists()) {
+            if (f.isDirectory()) {
+                FileUtils.deleteDirectory(f);
+            } else {
+                assertTrue("Failed to delete keytab directory", f.delete());
+            }
+        }
+        assertTrue("Failed to create keytab directory", f.mkdirs());
+    }
+
+    /**
+     * Verifies that there is a python Executable on the PATH
+     */
+    private static void checkForCommandOnPath(String command) throws Exception 
{
+        Process runPythonProcess = new ProcessBuilder(Arrays.asList("which", 
command)).start();
+        BufferedReader processOutput = new BufferedReader(new 
InputStreamReader(runPythonProcess.getInputStream()));
+        BufferedReader processError = new BufferedReader(new 
InputStreamReader(runPythonProcess.getErrorStream()));
+        int exitCode = runPythonProcess.waitFor();
+        // dump stdout and stderr
+        while (processOutput.ready()) {
+            LOG.info(processOutput.readLine());
+        }
+        while (processError.ready()) {
+            LOG.error(processError.readLine());
+        }
+        Assume.assumeTrue("Could not find '" + command + "' on the PATH", 
exitCode == 0);
+    }
+
+    /**
+     * Setup and start kerberos, hbase
+     */
+    @BeforeClass
+    public static void setUp() throws Exception {
+        checkForCommandOnPath("python");
+        checkForCommandOnPath("virtualenv");
+        checkForCommandOnPath("kinit");
+
+        final Configuration conf = UTIL.getConfiguration();
+        // Ensure the dirs we need are created/empty
+        ensureIsEmptyDirectory(TEMP_DIR);
+        ensureIsEmptyDirectory(KEYTAB_DIR);
+        KEYTAB = new File(KEYTAB_DIR, "test.keytab");
+        // Start a MiniKDC
+        KDC = UTIL.setupMiniKdc(KEYTAB);
+        // Create a service principal and spnego principal in one keytab
+        // NB. Due to some apparent limitations between HDFS and HBase in the 
same JVM, trying to
+        //     use separate identies for HBase and HDFS results in a GSS 
initiate error. The quick
+        //     solution is to just use a single "service" principal instead of 
"hbase" and "hdfs"
+        //     (or "dn" and "nn") per usual.
+        KDC.createPrincipal(KEYTAB, SPNEGO_PRINCIPAL, PQS_PRINCIPAL, 
SERVICE_PRINCIPAL);
+        // Start ZK by hand
+        UTIL.startMiniZKCluster();
+
+        // Create a number of unprivileged users
+        createUsers(3);
+
+        // Set configuration for HBase
+        HBaseKerberosUtils.setPrincipalForTesting(SERVICE_PRINCIPAL + "@" + 
KDC.getRealm());
+        HBaseKerberosUtils.setSecuredConfiguration(conf);
+        setHdfsSecuredConfiguration(conf);
+        UserGroupInformation.setConfiguration(conf);
+        conf.setInt(HConstants.MASTER_PORT, 0);
+        conf.setInt(HConstants.MASTER_INFO_PORT, 0);
+        conf.setInt(HConstants.REGIONSERVER_PORT, 0);
+        conf.setInt(HConstants.REGIONSERVER_INFO_PORT, 0);
+        conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
+            TokenProvider.class.getName());
+
+        // Secure Phoenix setup
+        conf.set("phoenix.queryserver.kerberos.http.principal", 
SPNEGO_PRINCIPAL + "@" + KDC.getRealm());
+        conf.set("phoenix.queryserver.http.keytab.file", 
KEYTAB.getAbsolutePath());
+        conf.set("phoenix.queryserver.kerberos.principal", PQS_PRINCIPAL + "@" 
+ KDC.getRealm());
+        conf.set("phoenix.queryserver.keytab.file", KEYTAB.getAbsolutePath());
+        conf.setBoolean(QueryServices.QUERY_SERVER_DISABLE_KERBEROS_LOGIN, 
true);
+        conf.setInt(QueryServices.QUERY_SERVER_HTTP_PORT_ATTRIB, 0);
+        // Required so that PQS can impersonate the end-users to HBase
+        conf.set("hadoop.proxyuser.phoenixqs.groups", "*");
+        conf.set("hadoop.proxyuser.phoenixqs.hosts", "*");
+
+        // Clear the cached singletons so we can inject our own.
+        InstanceResolver.clearSingletons();
+        // Make sure the ConnectionInfo doesn't try to pull a default 
Configuration
+        InstanceResolver.getSingleton(ConfigurationFactory.class, new 
ConfigurationFactory() {
+            @Override
+            public Configuration getConfiguration() {
+                return conf;
+            }
+            @Override
+            public Configuration getConfiguration(Configuration confToClone) {
+                Configuration copy = new Configuration(conf);
+                copy.addResource(confToClone);
+                return copy;
+            }
+        });
+        updateDefaultRealm();
+
+        // Start HDFS
+        UTIL.startMiniDFSCluster(1);
+        // Use LocalHBaseCluster to avoid HBaseTestingUtility from doing 
something wrong
+        // NB. I'm not actually sure what HTU does incorrect, but this was 
pulled from some test
+        //     classes in HBase itself. I couldn't get HTU to work myself 
(2017/07/06)
+        Path rootdir = 
UTIL.getDataTestDirOnTestFS(SecureQueryServerPhoenixDBIT.class.getSimpleName());
+        FSUtils.setRootDir(conf, rootdir);
+        HBASE_CLUSTER = new LocalHBaseCluster(conf, 1);
+        HBASE_CLUSTER.startup();
+
+        // Then fork a thread with PQS in it.
+        startQueryServer();
+    }
+
+    private static void startQueryServer() throws Exception {
+        PQS = new QueryServer(new String[0], UTIL.getConfiguration());
+        // Get the PQS ident for PQS to use
+        final UserGroupInformation ugi = 
UserGroupInformation.loginUserFromKeytabAndReturnUGI(PQS_PRINCIPAL, 
KEYTAB.getAbsolutePath());
+        PQS_EXECUTOR = Executors.newSingleThreadExecutor();
+        // Launch PQS, doing in the Kerberos login instead of letting PQS do 
it itself (which would
+        // break the HBase/HDFS logins also running in the same test case).
+        PQS_EXECUTOR.submit(new Runnable() {
+            @Override public void run() {
+                ugi.doAs(new PrivilegedAction<Void>() {
+                    @Override public Void run() {
+                        PQS.run();
+                        return null;
+                    }
+                });
+            }
+        });
+        PQS.awaitRunning();
+        PQS_PORT = PQS.getPort();
+        PQS_URL = ThinClientUtil.getConnectionUrl("localhost", PQS_PORT) + 
";authentication=SPNEGO";
+    }
+
+    @AfterClass
+    public static void stopKdc() throws Exception {
+        // Remove our custom ConfigurationFactory for future tests
+        InstanceResolver.clearSingletons();
+        if (PQS_EXECUTOR != null) {
+            PQS.stop();
+            PQS_EXECUTOR.shutdown();
+            if (!PQS_EXECUTOR.awaitTermination(5, TimeUnit.SECONDS)) {
+                LOG.info("PQS didn't exit in 5 seconds, proceeding anyways.");
+            }
+        }
+        if (HBASE_CLUSTER != null) {
+            HBASE_CLUSTER.shutdown();
+            HBASE_CLUSTER.join();
+        }
+        if (UTIL != null) {
+            UTIL.shutdownMiniZKCluster();
+        }
+        if (KDC != null) {
+            KDC.stop();
+        }
+    }
+
+    @Test
+    public void testBasicReadWrite() throws Exception {
+        final Entry<String,File> user1 = getUser(1);
+        String currentDirectory;
+        File file = new File(".");
+        currentDirectory = file.getAbsolutePath();
+        LOG.debug("Current working directory : "+currentDirectory);
+        LOG.debug("PQS_PORT:" + PQS_PORT);
+        LOG.debug("PQS_URL: " + PQS_URL);
+        ArrayList<String> cmdList = new ArrayList<>();
+        // This assumes the test is being run from phoenix/phoenix-queryserver
+        cmdList.add(Paths.get(currentDirectory, "src", "it", "bin", 
"test_phoenixdb.sh").toString());
+        cmdList.add(Paths.get(currentDirectory, "..", "python").toString());
+        cmdList.add(user1.getKey() + "@" + KDC.getRealm());
+        cmdList.add(user1.getValue().getAbsolutePath());
+        final String osName = System.getProperty("os.name").toLowerCase();
+        final Kdc kdcType;
+        final String kdcImpl = System.getProperty("PHOENIXDB_KDC_IMPL", "");
+        if (kdcImpl.isEmpty()) {
+          if (osName.indexOf("mac") >= 0) {
+            kdcType = Kdc.HEIMDAL;
+          } else {
+            kdcType = Kdc.MIT;
+          }
+        } else if (kdcImpl.trim().equalsIgnoreCase(Kdc.HEIMDAL.name())) {
+          kdcType = Kdc.HEIMDAL;
+        } else {
+          kdcType = Kdc.MIT;
+        }
+        LOG.info("Generating krb5.conf for KDC type:'{}'. OS='{}', 
PHOENIXDB_KDC_IMPL='{}'", kdcType, osName, kdcImpl);
+        File krb5ConfFile = null;
+        switch (kdcType) {
+            // It appears that we cannot generate a krb5.conf that is 
compatible with both MIT Kerberos
+            // and Heimdal Kerberos that works with MiniKdc. MiniKdc forces a 
choice between either UDP or
+            // or TCP for the KDC port. If we could have MiniKdc support both 
UDP and TCP, then we might be
+            // able to converge on a single krb5.conf for both MIT and Heimdal.
+            //
+            // With the below Heimdal configuration, MIT kerberos will fail on 
a DNS lookup to the hostname
+            // "tcp/localhost" instead of pulling off the "tcp/" prefix.
+            case HEIMDAL:
+                int kdcPort = KDC.getPort();
+                LOG.info("MINIKDC PORT " + kdcPort);
+                // Render a Heimdal compatible krb5.conf
+                // Currently kinit will only try tcp if the KDC is defined as
+                // kdc = tcp/hostname:port
+                StringBuilder krb5conf = new StringBuilder();
+                krb5conf.append("[libdefaults]\n");
+                krb5conf.append("     default_realm = EXAMPLE.COM\n");
+                krb5conf.append("     udp_preference_limit = 1\n");
+                krb5conf.append("\n");
+                krb5conf.append("[realms]\n");
+                krb5conf.append("    EXAMPLE.COM = {\n");
+                krb5conf.append("       kdc = localhost:");
+                krb5conf.append(kdcPort);
+                krb5conf.append("\n");
+                krb5conf.append("       kdc = tcp/localhost:");
+                krb5conf.append(kdcPort);
+                krb5conf.append("\n");
+                krb5conf.append("    }\n");
+
+                LOG.info("Writing Heimdal style krb5.conf");
+                LOG.info(krb5conf.toString());
+                krb5ConfFile = File.createTempFile("krb5.conf", null);
+                FileOutputStream fos = new FileOutputStream(krb5ConfFile);
+                fos.write(krb5conf.toString().getBytes());
+                fos.close();
+                LOG.info("krb5.conf written to " + 
krb5ConfFile.getAbsolutePath());
+                cmdList.add(krb5ConfFile.getAbsolutePath());
+                break;
+            case MIT:
+                cmdList.add(System.getProperty("java.security.krb5.conf"));
+                LOG.info("Using miniKDC provided krb5.conf  " + 
KDC.getKrb5conf().getAbsolutePath());
+                break;
+            default:
+                throw new RuntimeException("Unhandled KDC type: " + kdcType);
+        }
+
+        cmdList.add(Integer.toString(PQS_PORT));
+        cmdList.add(Paths.get(currentDirectory, "src", "it", "bin", 
"test_phoenixdb.py").toString());
+
+        Process runPythonProcess = new ProcessBuilder(cmdList).start();
+        BufferedReader processOutput = new BufferedReader(new 
InputStreamReader(runPythonProcess.getInputStream()));
+        BufferedReader processError = new BufferedReader(new 
InputStreamReader(runPythonProcess.getErrorStream()));
+        int exitCode = runPythonProcess.waitFor();
+
+        // dump stdout and stderr
+        while (processOutput.ready()) {
+            LOG.info(processOutput.readLine());
+        }
+        while (processError.ready()) {
+            LOG.error(processError.readLine());
+        }
+
+        // Not managed by miniKDC so we have to clean up
+        if (krb5ConfFile != null)
+            krb5ConfFile.delete();
+
+        assertEquals("Subprocess exited with errors", 0, exitCode);
+    }
+
+    byte[] copyBytes(byte[] src, int offset, int length) {
+        byte[] dest = new byte[length];
+        System.arraycopy(src, offset, dest, 0, length);
+        return dest;
+    }
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0aaedbd..5594b88 100644
--- a/pom.xml
+++ b/pom.xml
@@ -498,12 +498,14 @@
             <!-- Argparse is bundled to work around system Python version
                  issues, compatibile with ALv2 -->
             <exclude>bin/argparse-1.4.0/argparse.py</exclude>
-            <exclude>python/ci/**</exclude>
-            <exclude>python/phoenixdb/avatica/proto/*</exclude>
-            <exclude>python/*.rst</exclude>
-            <exclude>python/doc/*.rst</exclude>
-            <exclude>python/doc/conf.py</exclude>
-            <exclude>python/doc/Makefile</exclude>
+            <!-- Not our code -->
+            <exclude>python/requests-kerberos/**</exclude>
+            <exclude>python/phoenixdb/phoenixdb/avatica/proto/*</exclude>
+            <exclude>python/phoenixdb/*.rst</exclude>
+            <exclude>python/phoenixdb/ci/**</exclude>
+            <exclude>python/phoenixdb/doc/*.rst</exclude>
+            <exclude>python/phoenixdb/doc/conf.py</exclude>
+            <exclude>python/phoenixdb/doc/Makefile</exclude>
           </excludes>
         </configuration>
       </plugin>

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/NEWS.rst
----------------------------------------------------------------------
diff --git a/python/NEWS.rst b/python/NEWS.rst
deleted file mode 100644
index 21e2277..0000000
--- a/python/NEWS.rst
+++ /dev/null
@@ -1,44 +0,0 @@
-Changelog
-=========
-
-Version 0.7
------------
-
-- Added DictCursor for easier access to columns by their names.
-- Support for Phoenix versions from 4.8 to 4.11.
-
-Version 0.6
------------
-
-- Fixed result fetching when using a query with parameters.
-- Support for Phoenix 4.9.
-
-Version 0.5
------------
-
-- Added support for Python 3.
-- Switched from the JSON serialization to Protocol Buffers, improved 
compatibility with Phoenix 4.8.
-- Phoenix 4.6 and older are no longer supported.
-
-Version 0.4
------------
-
-- Fixes for the final version of Phoenix 4.7.
-
-Version 0.3
------------
-
-- Compatible with Phoenix 4.7.
-
-Version 0.2
------------
-
-- Added (configurable) retry on connection errors.
-- Added Vagrantfile for easier testing.
-- Compatible with Phoenix 4.6.
-
-Version 0.1
------------
-
-- Initial release.
-- Compatible with Phoenix 4.4.

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/README.md
----------------------------------------------------------------------
diff --git a/python/README.md b/python/README.md
new file mode 100644
index 0000000..6ea5fc9
--- /dev/null
+++ b/python/README.md
@@ -0,0 +1,93 @@
+<!--
+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.
+-->
+
+# Apache Phoenix Python Driver "PhoenixDB"
+
+This directory contains the Python driver for Apache Phoenix called "Python 
PhoenixDB" or just "PhoenixDB".
+
+This driver implements the Python DB 2.0 API for database drivers as described 
by [PEP-249](https://www.python.org/dev/peps/pep-0249/).
+This driver is implemented using the Phoenix Query Server (PQS) and the 
[Apache Calcite
+Avatica](https://calcite.apache.org/avatica) project.
+
+This driver should be compatible with Python 2.7 and Python 3.3+ and support 
both unauthenticated access and
+authenticated access via SPNEGO to PQS.
+
+## Usage
+
+The use of a virtual Python environment is strongly recommended, e.g. 
[virtualenv](https://virtualenv.pypa.io/en/stable/) or 
[conda](https://conda.io/docs/). You can install one of these using the Python 
package manager [pip](https://pypi.org/project/pip/). For developers who need 
to support multiple versions of Python, Python version managers, such as 
[pyenv](https://github.com/pyenv/pyenv), can drastically improve your quality 
of life.
+
+When connecting to an unsecured PQS instance, install the phoenixdb module 
into your local environment and write your
+application.
+
+```bash
+$ virtualenv e
+$ source e/bin/activate
+$ pip install file:///path/to/phoenix-x.y.z/phoenix/python/phoenixdb
+$ cat <<EOF
+import phoenixdb
+import phoenixdb.cursor
+
+if __name__ == '__main__':
+  database_url = 'http://localhost:8765/'
+  conn = phoenixdb.connect(database_url, autocommit=True)
+  cursor = conn.cursor()
+  cursor.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username 
VARCHAR)")
+  cursor.execute("UPSERT INTO users VALUES (?, ?)", (1, 'admin'))
+  cursor.execute("SELECT * FROM users")
+  print(cursor.fetchall())
+EOF > test-client.py
+$ python test-client.py
+```
+
+When using a PQS instance secured via SPNEGO with Kerberos-based 
authentication, you must also install the custom
+release of requests-kerberos provided with PhoenixDB.
+
+
+```bash
+$ virtualenv e
+$ source e/bin/activate
+$ pip install file:///path/to/phoenix-x.y.z/phoenix/python/phoenixdb
+$ pip install file:///path/to/phoenix-x.y.z/phoenix/python/requests-kerberos
+$ cat <<EOF
+import phoenixdb
+import phoenixdb.cursor
+
+if __name__ == '__main__':
+  database_url = 'http://localhost:8765/'
+  conn = phoenixdb.connect(database_url, autocommit=True, auth="SPNEGO")
+  cursor = conn.cursor()
+  cursor.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username 
VARCHAR)")
+  cursor.execute("UPSERT INTO users VALUES (?, ?)", (1, 'admin'))
+  cursor.execute("SELECT * FROM users")
+  print(cursor.fetchall())
+EOF > test-client.py
+$ python test-client.py
+```
+
+Please see the README included with PhoenixDB for more information on using 
the Python driver.
+
+## Kerberos support in testing
+
+An integration test, `SecureQueryServerPhoenixDBIT`, is included with Phoenix 
that sets up a secured Phoenix installation with PQS, then
+uses the driver to interact with that installation. We have observed that, 
with a correct krb5.conf for
+the Kerberos installation (MIT or Heimdal), this driver and the patched 
requests-kerberos library can
+communicate with the secured PQS instance.
+
+This test will guess at the flavor of Kerberos that you have installed on your 
local system. There is an option
+exposed which will force a specific flavor to be assumed: 
`PHOENIXDB_KDC_IMPL`. Valid options are `MIT` and `HEIMDAL`.
+You specify this as a Java system property from Maven, e.g. `mvn verify 
-Dtest=foo -Did.test=SecureQueryServerPhoenixDBIT -DPHOENIXDB_KDC_IMPL=MIT`
+forces an MIT Kerberos style krb5.conf to be used for the test.

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/README.rst
----------------------------------------------------------------------
diff --git a/python/README.rst b/python/README.rst
deleted file mode 100644
index c74104c..0000000
--- a/python/README.rst
+++ /dev/null
@@ -1,136 +0,0 @@
-Phoenix database adapter for Python
-===================================
-
-.. image:: 
https://code.oxygene.sk/lukas/python-phoenixdb/badges/master/pipeline.svg
-    :target: https://code.oxygene.sk/lukas/python-phoenixdb/commits/master
-    :alt: Build Status
-
-.. image:: 
https://readthedocs.org/projects/python-phoenixdb/badge/?version=latest
-    :target: http://python-phoenixdb.readthedocs.io/en/latest/?badge=latest
-    :alt: Documentation Status
-
-``phoenixdb`` is a Python library for accessing the
-`Phoenix SQL database <http://phoenix.apache.org/>`_
-using the
-`remote query server <http://phoenix.apache.org/server.html>`_.
-The library implements the
-standard `DB API 2.0 <https://www.python.org/dev/peps/pep-0249/>`_ interface,
-which should be familiar to most Python programmers.
-
-Installation
-------------
-
-The easiest way to install the library is using `pip 
<https://pip.pypa.io/en/stable/>`_::
-
-    pip install phoenixdb
-
-You can also download the source code from `here 
<https://phoenix.apache.org/download.html>`_,
-extract the archive and then install it manually::
-
-    cd /path/to/apache-phoenix-x.y.z/phoenix
-    python setup.py install
-
-Usage
------
-
-The library implements the standard DB API 2.0 interface, so it can be
-used the same way you would use any other SQL database from Python, for 
example::
-
-    import phoenixdb
-    import phoenixdb.cursor
-
-    database_url = 'http://localhost:8765/'
-    conn = phoenixdb.connect(database_url, autocommit=True)
-
-    cursor = conn.cursor()
-    cursor.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username 
VARCHAR)")
-    cursor.execute("UPSERT INTO users VALUES (?, ?)", (1, 'admin'))
-    cursor.execute("SELECT * FROM users")
-    print(cursor.fetchall())
-
-    cursor = conn.cursor(cursor_factory=phoenixdb.cursor.DictCursor)
-    cursor.execute("SELECT * FROM users WHERE id=1")
-    print(cursor.fetchone()['USERNAME'])
-
-
-Setting up a development environment
-------------------------------------
-
-If you want to quickly try out the included examples, you can set up a
-local `virtualenv <https://virtualenv.pypa.io/en/latest/>`_ with all the
-necessary requirements::
-
-    virtualenv e
-    source e/bin/activate
-    pip install -r requirements.txt
-    python setup.py develop
-
-To create or update the Avatica protobuf classes, change the tag in 
``gen-protobuf.sh``
-and run the script.
-
-If you need a Phoenix query server for experimenting, you can get one running
-quickly using `Docker <https://www.docker.com/>`_::
-
-    docker-compose up
-
-Or if you need an older version of Phoenix::
-
-    PHOENIX_VERSION=4.9 docker-compose up
-
-If you want to use the library without installing the phoenixdb library, you 
can use
-the `PYTHONPATH` environment variable to point to the library directly::
-
-    cd $PHOENIX_HOME/python
-    python setup.py build
-    cd ~/my_project
-    PYTHONPATH=$PHOENIX_HOME/build/lib python my_app.py
-
-Interactive SQL shell
----------------------
-
-There is a Python-based interactive shell include in the examples folder, 
which can be
-used to connect to Phoenix and execute queries::
-
-    ./examples/shell.py http://localhost:8765/
-    db=> CREATE TABLE test (id INTEGER PRIMARY KEY, name VARCHAR);
-    no rows affected (1.363 seconds)
-    db=> UPSERT INTO test (id, name) VALUES (1, 'Lukas');
-    1 row affected (0.004 seconds)
-    db=> SELECT * FROM test;
-    +------+-------+
-    |   ID | NAME  |
-    +======+=======+
-    |    1 | Lukas |
-    +------+-------+
-    1 row selected (0.019 seconds)
-
-Running the test suite
-----------------------
-
-The library comes with a test suite for testing Python DB API 2.0 compliance 
and
-various Phoenix-specific features. In order to run the test suite, you need a
-working Phoenix database and set the ``PHOENIXDB_TEST_DB_URL`` environment 
variable::
-
-    export PHOENIXDB_TEST_DB_URL='http://localhost:8765/'
-    nosetests
-
-Similarly, tox can be used to run the test suite against multiple Python 
versions::
-
-    pyenv install 3.5.5
-    pyenv install 3.6.4
-    pyenv install 2.7.14
-    pyenv global 2.7.14 3.5.5 3.6.4
-    PHOENIXDB_TEST_DB_URL='http://localhost:8765' tox
-
-Known issues
-------------
-
-- You can only use the library in autocommit mode. The native Java Phoenix 
library also implements batched upserts, which can be committed at once, but 
this is not exposed over the remote server. This was previously unimplemented 
due to CALCITE-767, however this functionality exists in the server, but is 
lacking in the driver.
-  (`CALCITE-767 <https://issues.apache.org/jira/browse/CALCITE-767>`_)
-- TIME and DATE columns in Phoenix are stored as full timestamps with a 
millisecond accuracy,
-  but the remote protocol only exposes the time (hour/minute/second) or date 
(year/month/day)
-  parts of the columns. (`CALCITE-797 
<https://issues.apache.org/jira/browse/CALCITE-797>`_, `CALCITE-798 
<https://issues.apache.org/jira/browse/CALCITE-798>`_)
-- TIMESTAMP columns in Phoenix are stored with a nanosecond accuracy, but the 
remote protocol truncates them to milliseconds. (`CALCITE-796 
<https://issues.apache.org/jira/browse/CALCITE-796>`_)
-- ARRAY columns are not supported. Again, this previously lacked server-side 
support which has since been built. The
-  driver needs to be updated to support this functionality.
-  (`CALCITE-1050 <https://issues.apache.org/jira/browse/CALCITE-1050>`_, 
`PHOENIX-2585 <https://issues.apache.org/jira/browse/PHOENIX-2585>`_)

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/RELEASING.rst
----------------------------------------------------------------------
diff --git a/python/RELEASING.rst b/python/RELEASING.rst
deleted file mode 100644
index d996cfe..0000000
--- a/python/RELEASING.rst
+++ /dev/null
@@ -1,12 +0,0 @@
-Releasing a new version
-=======================
-
-Change the version number ``setup.py`` and ``NEWS.rst``.
-
-Commit the changes and tag the repository::
-
-    git tag -s vX.Y
-
-Upload the package to PyPI::
-
-    python setup.py clean sdist upload

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/ci/build-env/Dockerfile
----------------------------------------------------------------------
diff --git a/python/ci/build-env/Dockerfile b/python/ci/build-env/Dockerfile
deleted file mode 100644
index 08ce45c..0000000
--- a/python/ci/build-env/Dockerfile
+++ /dev/null
@@ -1,7 +0,0 @@
-FROM ubuntu:xenial
-
-RUN apt-get update && \
-    DEBIAN_FRONTEND=noninteractive apt-get install -y python-dev python3-dev 
tox
-
-RUN apt-get update && \
-    DEBIAN_FRONTEND=noninteractive apt-get install -y git

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/ci/phoenix/Dockerfile
----------------------------------------------------------------------
diff --git a/python/ci/phoenix/Dockerfile b/python/ci/phoenix/Dockerfile
deleted file mode 100644
index fc6fadc..0000000
--- a/python/ci/phoenix/Dockerfile
+++ /dev/null
@@ -1,33 +0,0 @@
-FROM openjdk:8
-
-ARG HBASE_VERSION
-ARG HBASE_DIR
-ARG PHOENIX_VERSION
-ARG PHOENIX_NAME=apache-phoenix
-
-ENV HBASE_URL 
https://archive.apache.org/dist/hbase/$HBASE_DIR/hbase-$HBASE_VERSION-bin.tar.gz
-
-RUN wget --no-verbose -O hbase.tar.gz "$HBASE_URL" && \
-    mkdir /opt/hbase && \
-    tar xf hbase.tar.gz --strip-components=1 -C /opt/hbase && \
-    rm hbase.tar.gz
-
-ENV PHOENIX_URL 
https://archive.apache.org/dist/phoenix/apache-phoenix-$PHOENIX_VERSION/bin/apache-phoenix-$PHOENIX_VERSION-bin.tar.gz
-
-RUN wget --no-verbose -O phoenix.tar.gz "$PHOENIX_URL" && \
-    mkdir /opt/phoenix && \
-    tar xf phoenix.tar.gz --strip-components=1 -C /opt/phoenix && \
-    rm phoenix.tar.gz
-
-RUN ln -sv /opt/phoenix/phoenix-*-server.jar /opt/hbase/lib/
-
-ADD hbase-site.xml /opt/hbase/conf/hbase-site.xml
-
-ENV HBASE_CONF_DIR /opt/hbase/conf
-ENV HBASE_CP /opt/hbase/lib
-ENV HBASE_HOME /opt/hbase
-
-EXPOSE 8765
-
-COPY docker-entrypoint.sh /usr/local/bin/
-ENTRYPOINT ["docker-entrypoint.sh"]

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/ci/phoenix/docker-entrypoint.sh
----------------------------------------------------------------------
diff --git a/python/ci/phoenix/docker-entrypoint.sh 
b/python/ci/phoenix/docker-entrypoint.sh
deleted file mode 100755
index 0bcc6da..0000000
--- a/python/ci/phoenix/docker-entrypoint.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env bash
-
-pids=()
-
-/opt/hbase/bin/hbase-daemon.sh foreground_start master &
-pids+=($!)
-
-/opt/phoenix/bin/queryserver.py &
-pids+=($!)
-
-cleanup() {
-    if [ ${#pids[@]} -ne 0 ]
-    then
-        pids=($(ps -o pid= -p "${pids[@]}"))
-        if [ ${#pids[@]} -ne 0 ]
-        then
-            kill "${pids[@]}"
-        fi
-    fi
-}
-
-trap cleanup SIGCHLD SIGINT SIGTERM
-
-wait

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/ci/phoenix/hbase-site.xml
----------------------------------------------------------------------
diff --git a/python/ci/phoenix/hbase-site.xml b/python/ci/phoenix/hbase-site.xml
deleted file mode 100644
index 0e9a1b1..0000000
--- a/python/ci/phoenix/hbase-site.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-<configuration>
-    <property>
-        <name>hbase.regionserver.wal.codec</name>
-        
<value>org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec</value>
-    </property>
-       <property>
-               <name>phoenix.schema.isNamespaceMappingEnabled</name>
-               <value>true</value>
-       </property>
-</configuration>

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/doc/Makefile
----------------------------------------------------------------------
diff --git a/python/doc/Makefile b/python/doc/Makefile
deleted file mode 100644
index 31eb086..0000000
--- a/python/doc/Makefile
+++ /dev/null
@@ -1,192 +0,0 @@
-# Makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line.
-SPHINXOPTS    =
-SPHINXBUILD   = sphinx-build
-PAPER         =
-BUILDDIR      = _build
-
-# User-friendly check for sphinx-build
-ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
-$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx 
installed, then set the SPHINXBUILD environment variable to point to the full 
path of the '$(SPHINXBUILD)' executable. Alternatively you can add the 
directory with the executable to your PATH. If you don't have Sphinx installed, 
grab it from http://sphinx-doc.org/)
-endif
-
-# Internal variables.
-PAPEROPT_a4     = -D latex_paper_size=a4
-PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-# the i18n builder cannot share the environment and doctrees with the others
-I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-
-.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp 
epub latex latexpdf text man changes linkcheck doctest coverage gettext
-
-help:
-       @echo "Please use \`make <target>' where <target> is one of"
-       @echo "  html       to make standalone HTML files"
-       @echo "  dirhtml    to make HTML files named index.html in directories"
-       @echo "  singlehtml to make a single large HTML file"
-       @echo "  pickle     to make pickle files"
-       @echo "  json       to make JSON files"
-       @echo "  htmlhelp   to make HTML files and a HTML help project"
-       @echo "  qthelp     to make HTML files and a qthelp project"
-       @echo "  applehelp  to make an Apple Help Book"
-       @echo "  devhelp    to make HTML files and a Devhelp project"
-       @echo "  epub       to make an epub"
-       @echo "  latex      to make LaTeX files, you can set PAPER=a4 or 
PAPER=letter"
-       @echo "  latexpdf   to make LaTeX files and run them through pdflatex"
-       @echo "  latexpdfja to make LaTeX files and run them through 
platex/dvipdfmx"
-       @echo "  text       to make text files"
-       @echo "  man        to make manual pages"
-       @echo "  texinfo    to make Texinfo files"
-       @echo "  info       to make Texinfo files and run them through makeinfo"
-       @echo "  gettext    to make PO message catalogs"
-       @echo "  changes    to make an overview of all changed/added/deprecated 
items"
-       @echo "  xml        to make Docutils-native XML files"
-       @echo "  pseudoxml  to make pseudoxml-XML files for display purposes"
-       @echo "  linkcheck  to check all external links for integrity"
-       @echo "  doctest    to run all doctests embedded in the documentation 
(if enabled)"
-       @echo "  coverage   to run coverage check of the documentation (if 
enabled)"
-
-clean:
-       rm -rf $(BUILDDIR)/*
-
-html:
-       $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
-       @echo
-       @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
-
-dirhtml:
-       $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
-       @echo
-       @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
-
-singlehtml:
-       $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
-       @echo
-       @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
-
-pickle:
-       $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
-       @echo
-       @echo "Build finished; now you can process the pickle files."
-
-json:
-       $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
-       @echo
-       @echo "Build finished; now you can process the JSON files."
-
-htmlhelp:
-       $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
-       @echo
-       @echo "Build finished; now you can run HTML Help Workshop with the" \
-             ".hhp project file in $(BUILDDIR)/htmlhelp."
-
-qthelp:
-       $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
-       @echo
-       @echo "Build finished; now you can run "qcollectiongenerator" with the" 
\
-             ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
-       @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/phoenixdb.qhcp"
-       @echo "To view the help file:"
-       @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/phoenixdb.qhc"
-
-applehelp:
-       $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
-       @echo
-       @echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
-       @echo "N.B. You won't be able to view it unless you put it in" \
-             "~/Library/Documentation/Help or install it in your application" \
-             "bundle."
-
-devhelp:
-       $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
-       @echo
-       @echo "Build finished."
-       @echo "To view the help file:"
-       @echo "# mkdir -p $$HOME/.local/share/devhelp/phoenixdb"
-       @echo "# ln -s $(BUILDDIR)/devhelp 
$$HOME/.local/share/devhelp/phoenixdb"
-       @echo "# devhelp"
-
-epub:
-       $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
-       @echo
-       @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
-
-latex:
-       $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-       @echo
-       @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
-       @echo "Run \`make' in that directory to run these through (pdf)latex" \
-             "(use \`make latexpdf' here to do that automatically)."
-
-latexpdf:
-       $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-       @echo "Running LaTeX files through pdflatex..."
-       $(MAKE) -C $(BUILDDIR)/latex all-pdf
-       @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
-
-latexpdfja:
-       $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-       @echo "Running LaTeX files through platex and dvipdfmx..."
-       $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
-       @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
-
-text:
-       $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
-       @echo
-       @echo "Build finished. The text files are in $(BUILDDIR)/text."
-
-man:
-       $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
-       @echo
-       @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
-
-texinfo:
-       $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
-       @echo
-       @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
-       @echo "Run \`make' in that directory to run these through makeinfo" \
-             "(use \`make info' here to do that automatically)."
-
-info:
-       $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
-       @echo "Running Texinfo files through makeinfo..."
-       make -C $(BUILDDIR)/texinfo info
-       @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
-
-gettext:
-       $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
-       @echo
-       @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
-
-changes:
-       $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
-       @echo
-       @echo "The overview file is in $(BUILDDIR)/changes."
-
-linkcheck:
-       $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
-       @echo
-       @echo "Link check complete; look for any errors in the above output " \
-             "or in $(BUILDDIR)/linkcheck/output.txt."
-
-doctest:
-       $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
-       @echo "Testing of doctests in the sources finished, look at the " \
-             "results in $(BUILDDIR)/doctest/output.txt."
-
-coverage:
-       $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
-       @echo "Testing of coverage in the sources finished, look at the " \
-             "results in $(BUILDDIR)/coverage/python.txt."
-
-xml:
-       $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
-       @echo
-       @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
-
-pseudoxml:
-       $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
-       @echo
-       @echo "Build finished. The pseudo-XML files are in 
$(BUILDDIR)/pseudoxml."

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/doc/api.rst
----------------------------------------------------------------------
diff --git a/python/doc/api.rst b/python/doc/api.rst
deleted file mode 100644
index cac317c..0000000
--- a/python/doc/api.rst
+++ /dev/null
@@ -1,30 +0,0 @@
-API Reference
-=============
-
-phoenixdb module
-----------------
-
-.. automodule:: phoenixdb
-    :members:
-    :undoc-members:
-
-phoenixdb.connection module
----------------------------
-
-.. automodule:: phoenixdb.connection
-    :members:
-    :undoc-members:
-
-phoenixdb.cursor module
------------------------
-
-.. automodule:: phoenixdb.cursor
-    :members:
-    :undoc-members:
-
-phoenixdb.avatica module
-------------------------
-
-.. automodule:: phoenixdb.avatica
-    :members:
-    :undoc-members:

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/doc/conf.py
----------------------------------------------------------------------
diff --git a/python/doc/conf.py b/python/doc/conf.py
deleted file mode 100644
index 21898d7..0000000
--- a/python/doc/conf.py
+++ /dev/null
@@ -1,287 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# phoenixdb documentation build configuration file, created by
-# sphinx-quickstart on Sun Jun 28 18:07:35 2015.
-#
-# This file is execfile()d with the current directory set to its
-# containing dir.
-#
-# Note that not all possible configuration values are present in this
-# autogenerated file.
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
-
-import sys
-import os
-import shlex
-
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-sys.path.insert(0, os.path.abspath('../phoenixdb'))
-
-# -- General configuration ------------------------------------------------
-
-# If your documentation needs a minimal Sphinx version, state it here.
-#needs_sphinx = '1.0'
-
-# Add any Sphinx extension module names here, as strings. They can be
-# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
-# ones.
-extensions = [
-    'sphinx.ext.autodoc',
-    'sphinx.ext.doctest',
-    'sphinx.ext.intersphinx',
-]
-
-# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
-
-# The suffix(es) of source filenames.
-# You can specify multiple suffix as a list of string:
-# source_suffix = ['.rst', '.md']
-source_suffix = '.rst'
-
-# The encoding of source files.
-source_encoding = 'utf-8-sig'
-
-# The master toctree document.
-master_doc = 'index'
-
-# General information about the project.
-project = u'phoenixdb'
-copyright = u'2015, Lukas Lalinsky'
-author = u'Lukas Lalinsky'
-
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-#
-# This is also used if you do content translation via gettext catalogs.
-# Usually you set "language" from the command line for these cases.
-language = None
-
-# There are two options for replacing |today|: either, you set today to some
-# non-false value, then it is used:
-#today = ''
-# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
-
-# List of patterns, relative to source directory, that match files and
-# directories to ignore when looking for source files.
-exclude_patterns = ['_build']
-
-# The reST default role (used for this markup: `text`) to use for all
-# documents.
-#default_role = None
-
-# If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
-
-# If true, the current module name will be prepended to all description
-# unit titles (such as .. function::).
-#add_module_names = True
-
-# If true, sectionauthor and moduleauthor directives will be shown in the
-# output. They are ignored by default.
-#show_authors = False
-
-# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
-
-# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
-
-# If true, keep warnings as "system message" paragraphs in the built documents.
-#keep_warnings = False
-
-# If true, `todo` and `todoList` produce output, else they produce nothing.
-todo_include_todos = False
-
-
-# -- Options for HTML output ----------------------------------------------
-
-# The theme to use for HTML and HTML Help pages.  See the documentation for
-# a list of builtin themes.
-html_theme = 'classic'
-
-# Theme options are theme-specific and customize the look and feel of a theme
-# further.  For a list of options available for each theme, see the
-# documentation.
-#html_theme_options = {}
-
-# Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
-
-# The name for this set of Sphinx documents.  If None, it defaults to
-# "<project> v<release> documentation".
-#html_title = None
-
-# A shorter title for the navigation bar.  Default is the same as html_title.
-#html_short_title = None
-
-# The name of an image file (relative to this directory) to place at the top
-# of the sidebar.
-#html_logo = None
-
-# The name of an image file (within the static path) to use as favicon of the
-# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
-# pixels large.
-#html_favicon = None
-
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
-
-# Add any extra paths that contain custom files (such as robots.txt or
-# .htaccess) here, relative to this directory. These files are copied
-# directly to the root of the documentation.
-#html_extra_path = []
-
-# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
-# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
-
-# If true, SmartyPants will be used to convert quotes and dashes to
-# typographically correct entities.
-#html_use_smartypants = True
-
-# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
-
-# Additional templates that should be rendered to pages, maps page names to
-# template names.
-#html_additional_pages = {}
-
-# If false, no module index is generated.
-#html_domain_indices = True
-
-# If false, no index is generated.
-#html_use_index = True
-
-# If true, the index is split into individual pages for each letter.
-#html_split_index = False
-
-# If true, links to the reST sources are added to the pages.
-html_show_sourcelink = False
-
-# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
-#html_show_sphinx = True
-
-# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-#html_show_copyright = True
-
-# If true, an OpenSearch description file will be output, and all pages will
-# contain a <link> tag referring to it.  The value of this option must be the
-# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
-
-# This is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = None
-
-# Language to be used for generating the HTML full-text search index.
-# Sphinx supports the following languages:
-#   'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
-#   'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
-#html_search_language = 'en'
-
-# A dictionary with options for the search language support, empty by default.
-# Now only 'ja' uses this config value
-#html_search_options = {'type': 'default'}
-
-# The name of a javascript file (relative to the configuration directory) that
-# implements a search results scorer. If empty, the default will be used.
-#html_search_scorer = 'scorer.js'
-
-# Output file base name for HTML help builder.
-htmlhelp_basename = 'phoenixdbdoc'
-
-# -- Options for LaTeX output ---------------------------------------------
-
-#latex_elements = {
-# The paper size ('letterpaper' or 'a4paper').
-#'papersize': 'letterpaper',
-
-# The font size ('10pt', '11pt' or '12pt').
-#'pointsize': '10pt',
-
-# Additional stuff for the LaTeX preamble.
-#'preamble': '',
-
-# Latex figure (float) alignment
-#'figure_align': 'htbp',
-#}
-
-# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title,
-#  author, documentclass [howto, manual, or own class]).
-#latex_documents = [
-#  (master_doc, 'phoenixdb.tex', u'phoenixdb Documentation',
-#   u'Lukas Lalinsky', 'manual'),
-#]
-
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-#latex_logo = None
-
-# For "manual" documents, if this is true, then toplevel headings are parts,
-# not chapters.
-#latex_use_parts = False
-
-# If true, show page references after internal links.
-#latex_show_pagerefs = False
-
-# If true, show URL addresses after external links.
-#latex_show_urls = False
-
-# Documents to append as an appendix to all manuals.
-#latex_appendices = []
-
-# If false, no module index is generated.
-#latex_domain_indices = True
-
-
-# -- Options for manual page output ---------------------------------------
-
-# One entry per manual page. List of tuples
-# (source start file, name, description, authors, manual section).
-man_pages = [
-    (master_doc, 'phoenixdb', u'phoenixdb Documentation',
-     [author], 1)
-]
-
-# If true, show URL addresses after external links.
-#man_show_urls = False
-
-
-# -- Options for Texinfo output -------------------------------------------
-
-# Grouping the document tree into Texinfo files. List of tuples
-# (source start file, target name, title, author,
-#  dir menu entry, description, category)
-texinfo_documents = [
-  (master_doc, 'phoenixdb', u'phoenixdb Documentation',
-   author, 'phoenixdb', 'One line description of project.',
-   'Miscellaneous'),
-]
-
-# Documents to append as an appendix to all manuals.
-#texinfo_appendices = []
-
-# If false, no module index is generated.
-#texinfo_domain_indices = True
-
-# How to display URL addresses: 'footnote', 'no', or 'inline'.
-#texinfo_show_urls = 'footnote'
-
-# If true, do not generate a @detailmenu in the "Top" node's menu.
-#texinfo_no_detailmenu = False
-
-
-# Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {'https://docs.python.org/': None}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/doc/index.rst
----------------------------------------------------------------------
diff --git a/python/doc/index.rst b/python/doc/index.rst
deleted file mode 100644
index ada7fb8..0000000
--- a/python/doc/index.rst
+++ /dev/null
@@ -1,27 +0,0 @@
-.. include:: ../README.rst
-
-API Reference
--------------
-
-.. toctree::
-   :maxdepth: 2
-
-   api
-
-Changelog
--------------
-
-.. toctree::
-   :maxdepth: 2
-
-   versions
-
-Indices and tables
-==================
-
-* :ref:`genindex`
-* :ref:`modindex`
-* :ref:`search`
-
-
-.. _

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/doc/versions.rst
----------------------------------------------------------------------
diff --git a/python/doc/versions.rst b/python/doc/versions.rst
deleted file mode 100644
index f3830fd..0000000
--- a/python/doc/versions.rst
+++ /dev/null
@@ -1,3 +0,0 @@
-.. include:: ../NEWS.rst
-
-.. _

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/docker-compose.yml
----------------------------------------------------------------------
diff --git a/python/docker-compose.yml b/python/docker-compose.yml
deleted file mode 100644
index bf398ec..0000000
--- a/python/docker-compose.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-# 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.
-
-version: "3"
-services:
-  phoenix:
-    image: 
docker.oxygene.sk/lukas/python-phoenixdb/phoenix:${PHOENIX_VERSION:-4.11}
-    ports:
-      - "127.0.0.1:8765:8765"

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/examples/basic.py
----------------------------------------------------------------------
diff --git a/python/examples/basic.py b/python/examples/basic.py
deleted file mode 100755
index 4894d21..0000000
--- a/python/examples/basic.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/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.
-
-import phoenixdb
-
-with phoenixdb.connect('http://localhost:8765/', autocommit=True) as 
connection:
-    with connection.cursor() as cursor:
-        cursor.execute("DROP TABLE IF EXISTS test")
-        cursor.execute("CREATE TABLE test (id INTEGER PRIMARY KEY, text 
VARCHAR)")
-        cursor.executemany("UPSERT INTO test VALUES (?, ?)", [[1, 'hello'], 
[2, 'world']])
-        cursor.execute("SELECT * FROM test ORDER BY id")
-        for row in cursor:
-            print(row)

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/examples/shell.py
----------------------------------------------------------------------
diff --git a/python/examples/shell.py b/python/examples/shell.py
deleted file mode 100755
index 820435e..0000000
--- a/python/examples/shell.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/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.
-
-import logging
-import argparse
-import sqlline
-
-parser = argparse.ArgumentParser()
-parser.add_argument('--debug', '-d', action='store_true')
-parser.add_argument('url')
-args = parser.parse_args()
-
-if args.debug:
-    logging.basicConfig(level=logging.DEBUG)
-
-with sqlline.SqlLine() as sqlline:
-    sqlline.connect('phoenixdb', args.url)
-    sqlline.connection.autocommit = True
-    sqlline.run()

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/gen-protobuf.sh
----------------------------------------------------------------------
diff --git a/python/gen-protobuf.sh b/python/gen-protobuf.sh
deleted file mode 100755
index f483561..0000000
--- a/python/gen-protobuf.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/env 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.
-
-AVATICA_VER=rel/avatica-1.10.0
-
-set -e
-
-rm -rf avatica-tmp
-
-mkdir avatica-tmp
-cd avatica-tmp
-wget -O avatica.tar.gz 
https://github.com/apache/calcite-avatica/archive/$AVATICA_VER.tar.gz
-tar -x --strip-components=1 -f avatica.tar.gz
-
-cd ..
-rm -f phoenixdb/avatica/proto/*_pb2.py
-protoc --proto_path=avatica-tmp/core/src/main/protobuf/ 
--python_out=phoenixdb/avatica/proto avatica-tmp/core/src/main/protobuf/*.proto
-if [[ "$(uname)" == "Darwin" ]]; then
-  sed -i '' 's/import common_pb2/from . import common_pb2/' 
phoenixdb/avatica/proto/*_pb2.py
-else
-  sed -i 's/import common_pb2/from . import common_pb2/' 
phoenixdb/avatica/proto/*_pb2.py
-fi
-
-rm -rf avatica-tmp

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/phoenixdb/NEWS.rst
----------------------------------------------------------------------
diff --git a/python/phoenixdb/NEWS.rst b/python/phoenixdb/NEWS.rst
new file mode 100644
index 0000000..21e2277
--- /dev/null
+++ b/python/phoenixdb/NEWS.rst
@@ -0,0 +1,44 @@
+Changelog
+=========
+
+Version 0.7
+-----------
+
+- Added DictCursor for easier access to columns by their names.
+- Support for Phoenix versions from 4.8 to 4.11.
+
+Version 0.6
+-----------
+
+- Fixed result fetching when using a query with parameters.
+- Support for Phoenix 4.9.
+
+Version 0.5
+-----------
+
+- Added support for Python 3.
+- Switched from the JSON serialization to Protocol Buffers, improved 
compatibility with Phoenix 4.8.
+- Phoenix 4.6 and older are no longer supported.
+
+Version 0.4
+-----------
+
+- Fixes for the final version of Phoenix 4.7.
+
+Version 0.3
+-----------
+
+- Compatible with Phoenix 4.7.
+
+Version 0.2
+-----------
+
+- Added (configurable) retry on connection errors.
+- Added Vagrantfile for easier testing.
+- Compatible with Phoenix 4.6.
+
+Version 0.1
+-----------
+
+- Initial release.
+- Compatible with Phoenix 4.4.

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/phoenixdb/README.rst
----------------------------------------------------------------------
diff --git a/python/phoenixdb/README.rst b/python/phoenixdb/README.rst
new file mode 100644
index 0000000..c74104c
--- /dev/null
+++ b/python/phoenixdb/README.rst
@@ -0,0 +1,136 @@
+Phoenix database adapter for Python
+===================================
+
+.. image:: 
https://code.oxygene.sk/lukas/python-phoenixdb/badges/master/pipeline.svg
+    :target: https://code.oxygene.sk/lukas/python-phoenixdb/commits/master
+    :alt: Build Status
+
+.. image:: 
https://readthedocs.org/projects/python-phoenixdb/badge/?version=latest
+    :target: http://python-phoenixdb.readthedocs.io/en/latest/?badge=latest
+    :alt: Documentation Status
+
+``phoenixdb`` is a Python library for accessing the
+`Phoenix SQL database <http://phoenix.apache.org/>`_
+using the
+`remote query server <http://phoenix.apache.org/server.html>`_.
+The library implements the
+standard `DB API 2.0 <https://www.python.org/dev/peps/pep-0249/>`_ interface,
+which should be familiar to most Python programmers.
+
+Installation
+------------
+
+The easiest way to install the library is using `pip 
<https://pip.pypa.io/en/stable/>`_::
+
+    pip install phoenixdb
+
+You can also download the source code from `here 
<https://phoenix.apache.org/download.html>`_,
+extract the archive and then install it manually::
+
+    cd /path/to/apache-phoenix-x.y.z/phoenix
+    python setup.py install
+
+Usage
+-----
+
+The library implements the standard DB API 2.0 interface, so it can be
+used the same way you would use any other SQL database from Python, for 
example::
+
+    import phoenixdb
+    import phoenixdb.cursor
+
+    database_url = 'http://localhost:8765/'
+    conn = phoenixdb.connect(database_url, autocommit=True)
+
+    cursor = conn.cursor()
+    cursor.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, username 
VARCHAR)")
+    cursor.execute("UPSERT INTO users VALUES (?, ?)", (1, 'admin'))
+    cursor.execute("SELECT * FROM users")
+    print(cursor.fetchall())
+
+    cursor = conn.cursor(cursor_factory=phoenixdb.cursor.DictCursor)
+    cursor.execute("SELECT * FROM users WHERE id=1")
+    print(cursor.fetchone()['USERNAME'])
+
+
+Setting up a development environment
+------------------------------------
+
+If you want to quickly try out the included examples, you can set up a
+local `virtualenv <https://virtualenv.pypa.io/en/latest/>`_ with all the
+necessary requirements::
+
+    virtualenv e
+    source e/bin/activate
+    pip install -r requirements.txt
+    python setup.py develop
+
+To create or update the Avatica protobuf classes, change the tag in 
``gen-protobuf.sh``
+and run the script.
+
+If you need a Phoenix query server for experimenting, you can get one running
+quickly using `Docker <https://www.docker.com/>`_::
+
+    docker-compose up
+
+Or if you need an older version of Phoenix::
+
+    PHOENIX_VERSION=4.9 docker-compose up
+
+If you want to use the library without installing the phoenixdb library, you 
can use
+the `PYTHONPATH` environment variable to point to the library directly::
+
+    cd $PHOENIX_HOME/python
+    python setup.py build
+    cd ~/my_project
+    PYTHONPATH=$PHOENIX_HOME/build/lib python my_app.py
+
+Interactive SQL shell
+---------------------
+
+There is a Python-based interactive shell include in the examples folder, 
which can be
+used to connect to Phoenix and execute queries::
+
+    ./examples/shell.py http://localhost:8765/
+    db=> CREATE TABLE test (id INTEGER PRIMARY KEY, name VARCHAR);
+    no rows affected (1.363 seconds)
+    db=> UPSERT INTO test (id, name) VALUES (1, 'Lukas');
+    1 row affected (0.004 seconds)
+    db=> SELECT * FROM test;
+    +------+-------+
+    |   ID | NAME  |
+    +======+=======+
+    |    1 | Lukas |
+    +------+-------+
+    1 row selected (0.019 seconds)
+
+Running the test suite
+----------------------
+
+The library comes with a test suite for testing Python DB API 2.0 compliance 
and
+various Phoenix-specific features. In order to run the test suite, you need a
+working Phoenix database and set the ``PHOENIXDB_TEST_DB_URL`` environment 
variable::
+
+    export PHOENIXDB_TEST_DB_URL='http://localhost:8765/'
+    nosetests
+
+Similarly, tox can be used to run the test suite against multiple Python 
versions::
+
+    pyenv install 3.5.5
+    pyenv install 3.6.4
+    pyenv install 2.7.14
+    pyenv global 2.7.14 3.5.5 3.6.4
+    PHOENIXDB_TEST_DB_URL='http://localhost:8765' tox
+
+Known issues
+------------
+
+- You can only use the library in autocommit mode. The native Java Phoenix 
library also implements batched upserts, which can be committed at once, but 
this is not exposed over the remote server. This was previously unimplemented 
due to CALCITE-767, however this functionality exists in the server, but is 
lacking in the driver.
+  (`CALCITE-767 <https://issues.apache.org/jira/browse/CALCITE-767>`_)
+- TIME and DATE columns in Phoenix are stored as full timestamps with a 
millisecond accuracy,
+  but the remote protocol only exposes the time (hour/minute/second) or date 
(year/month/day)
+  parts of the columns. (`CALCITE-797 
<https://issues.apache.org/jira/browse/CALCITE-797>`_, `CALCITE-798 
<https://issues.apache.org/jira/browse/CALCITE-798>`_)
+- TIMESTAMP columns in Phoenix are stored with a nanosecond accuracy, but the 
remote protocol truncates them to milliseconds. (`CALCITE-796 
<https://issues.apache.org/jira/browse/CALCITE-796>`_)
+- ARRAY columns are not supported. Again, this previously lacked server-side 
support which has since been built. The
+  driver needs to be updated to support this functionality.
+  (`CALCITE-1050 <https://issues.apache.org/jira/browse/CALCITE-1050>`_, 
`PHOENIX-2585 <https://issues.apache.org/jira/browse/PHOENIX-2585>`_)

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/phoenixdb/RELEASING.rst
----------------------------------------------------------------------
diff --git a/python/phoenixdb/RELEASING.rst b/python/phoenixdb/RELEASING.rst
new file mode 100644
index 0000000..d996cfe
--- /dev/null
+++ b/python/phoenixdb/RELEASING.rst
@@ -0,0 +1,12 @@
+Releasing a new version
+=======================
+
+Change the version number ``setup.py`` and ``NEWS.rst``.
+
+Commit the changes and tag the repository::
+
+    git tag -s vX.Y
+
+Upload the package to PyPI::
+
+    python setup.py clean sdist upload

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ec3542d6/python/phoenixdb/__init__.py
----------------------------------------------------------------------
diff --git a/python/phoenixdb/__init__.py b/python/phoenixdb/__init__.py
deleted file mode 100644
index ae7dd39..0000000
--- a/python/phoenixdb/__init__.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# 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 phoenixdb import errors, types
-from phoenixdb.avatica import AvaticaClient
-from phoenixdb.connection import Connection
-from phoenixdb.errors import *  # noqa: F401,F403
-from phoenixdb.types import *  # noqa: F401,F403
-
-__all__ = ['connect', 'apilevel', 'threadsafety', 'paramstyle'] + 
types.__all__ + errors.__all__
-
-
-apilevel = "2.0"
-"""
-This module supports the `DB API 2.0 interface 
<https://www.python.org/dev/peps/pep-0249/>`_.
-"""
-
-threadsafety = 1
-"""
-Multiple threads can share the module, but neither connections nor cursors.
-"""
-
-paramstyle = 'qmark'
-"""
-Parmetrized queries should use the question mark as a parameter placeholder.
-
-For example::
-
- cursor.execute("SELECT * FROM table WHERE id = ?", [my_id])
-"""
-
-
-def connect(url, max_retries=None, **kwargs):
-    """Connects to a Phoenix query server.
-
-    :param url:
-        URL to the Phoenix query server, e.g. ``http://localhost:8765/``
-
-    :param autocommit:
-        Switch the connection to autocommit mode.
-
-    :param readonly:
-        Switch the connection to readonly mode.
-
-    :param max_retries:
-        The maximum number of retries in case there is a connection error.
-
-    :param cursor_factory:
-        If specified, the connection's 
:attr:`~phoenixdb.connection.Connection.cursor_factory` is set to it.
-
-    :returns:
-        :class:`~phoenixdb.connection.Connection` object.
-    """
-    client = AvaticaClient(url, max_retries=max_retries)
-    client.connect()
-    return Connection(client, **kwargs)

Reply via email to