Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9aaf03c
Move riak_pb Python code into this repo as a submodule. Still working…
Nov 24, 2015
498e093
No need to be redundant in namespace. pb instead of riak_pb
Dec 9, 2015
e8ff23d
Revert file deletion.
lukebakken Dec 12, 2015
55dec06
Working on Makefile
Dec 12, 2015
0946771
Use pb subdir instead of riak_pb
Dec 12, 2015
508ad24
Remove Python 2.6 and 2.7.9, ensure latest version of 2.7, 3.3, 3.4 a…
Dec 12, 2015
85c4ed7
Exclude pb files from lint, fix one lint error
Dec 12, 2015
d1de4bb
Restore the buildbot setup target
Dec 12, 2015
20cee68
tox setup script
Dec 12, 2015
3403f91
Improvements to tox_setup.sh to ensure latest bits are used
Dec 12, 2015
4fe3d16
Improve Makefile
Dec 12, 2015
03792c9
Remove install target as it is no longer useful
Dec 12, 2015
c251a00
Final makefile cleanup
Dec 13, 2015
c1f0e37
Modify error to use Gnu make error mechanism
Dec 13, 2015
52ef8d7
Detect PB corectly
lukebakken Dec 14, 2015
88bf9c2
Small changes to the README.rst
lukebakken Dec 14, 2015
8fe089c
Fix the release target.
lukebakken Dec 14, 2015
5dbad5f
Remove git submodule call in tox setup.
lukebakken Dec 14, 2015
76122ef
Improve error text.
lukebakken Dec 14, 2015
b2e1aef
Merge branch 'master' into features/lrb/riak_pb-submodule
lukebakken Dec 14, 2015
3235bee
Restore testing on 2.7.8, clean up from merge
Dec 14, 2015
6bbb3fc
pb namespace cleanup
Dec 14, 2015
477a0ab
Remove THANKS file from manifest
Dec 14, 2015
7885c90
special-case 2.7.8
lukebakken Dec 14, 2015
9c098dd
namespace fixes in timeseries tests
Dec 14, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*.pyc
.python-version
__pycache__/

.tox/

.tox/

Expand All @@ -8,8 +11,9 @@ docs/_build
.*.swp
.coverage

build/
py-build/
dist/

riak.egg-info/
*.egg
.eggs/
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "riak_pb"]
path = riak_pb
url = git://github.com/basho/riak_pb.git
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
include docs/*
include riak/erl_src/*
include THANKS
include README.rst
include LICENSE
include RELEASE_NOTES.md
include version.py
include commands.py
include commands.py
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.PHONY: pb_clean pb_compile pb_build release

clean: pb_clean

pb_clean:
@echo "==> Python (clean)"
@rm -rf riak/pb/*_pb2.py riak/pb/*.pyc riak/pb/__pycache__ __pycache__ py-build

pb_compile: pb_clean
@echo "==> Python (compile)"
@protoc -Iriak_pb/src --python_out=riak/pb riak_pb/src/*.proto
@python setup.py build_messages

release:
ifeq ($(RELEASE_GPG_KEYNAME),)
$(error RELEASE_GPG_KEYNAME must be set to build a release and deploy this package)
else
@echo "==> Python 2.7 (release)"
@python2.7 setup.py build --build-base=py-build/2.7 bdist_egg upload -s -i $(RELEASE_GPG_KEYNAME)
@echo "==> Python 3.3 (release)"
@python3.3 setup.py build --build-base=py-build/3.3 bdist_egg upload -s -i $(RELEASE_GPG_KEYNAME)
@echo "==> Python 3.4 (release)"
@python3.4 setup.py build --build-base=py-build/3.4 bdist_egg upload -s -i $(RELEASE_GPG_KEYNAME)
@echo "==> Python 3.5 (release)"
@python3.5 setup.py build --build-base=py-build/3.5 bdist_egg upload -s -i $(RELEASE_GPG_KEYNAME)
endif
16 changes: 6 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ Install
=======

The recommended versions of Python for use with this client are Python
`2.7.x` and `3.3/3.4`.

From the Riak Python Client root directory, execute
`2.7.x`, `3.3.x`, `3.4.x` and `3.5.x`.

From Source
-----------
Expand All @@ -28,7 +26,7 @@ From Source

python setup.py install

There is an additional dependency on the Python package `setuptools`.
There are additional dependencies on Python packages `setuptools` and `protobuf`.

From PyPI
---------
Expand Down Expand Up @@ -64,16 +62,14 @@ variable to the root of your Riak installation. Then from the

.. code-block:: console

cd buildbot
make preconfigure
make -C buildbot preconfigure

Start your Riak node with ``riak start`` from the the Riak directory,
then back in ``buildbot`` type
Start your Riak node with ``riak start`` from the the Riak directory, then

.. code-block:: console

make configure
make test
make -C buildbot configure
make -C buildbot test

That will run the test suite twice: once with security enabled and once
without.
Expand Down
34 changes: 15 additions & 19 deletions buildbot/Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
RIAK_CONF = ${RIAK_DIR}/etc/riak.conf
# ADVANCED_CONF = ${RIAK_DIR}/etc/advanced.config
# RIAK = ${RIAK_DIR}/bin/riak
RIAK_ADMIN = ${RIAK_DIR}/bin/riak-admin
CERTS_DIR = $(shell pwd)/../riak/tests/resources
ifndef RIAK_DIR
$(error RIAK_DIR is not set)
endif

RIAK_CONF = $(RIAK_DIR)/etc/riak.conf
RIAK_ADMIN = $(RIAK_DIR)/bin/riak-admin
CERTS_DIR = $(realpath $(CURDIR))/../riak/tests/resources
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure realpath is installed on all platforms by default. On CentOS 6, for example:

$ realpath
-bash: realpath: command not found

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a GNU make built-in, not an external call.

unexport PYENV_VERSION

preconfigure:
@../setup.py preconfigure --riak-conf=${RIAK_CONF}
@../setup.py preconfigure --riak-conf=$(RIAK_CONF)

configure:
@../setup.py configure --riak-admin=${RIAK_ADMIN}
@../setup.py configure --riak-admin=$(RIAK_ADMIN)

compile:
@../setup.py develop

lint:
@pip install --upgrade pep8 flake8
@cd ..; pep8 riak *.py
@cd ..; flake8 riak *.py
@openssl verify -CAfile ${CERTS_DIR}/ca.crt ${CERTS_DIR}/client.crt
@openssl verify -CAfile ${CERTS_DIR}/ca.crt ${CERTS_DIR}/server.crt
@cd ..; pep8 --exclude=riak/pb riak *.py
@cd ..; flake8 --exclude=riak/pb riak *.py
@openssl verify -CAfile $(CERTS_DIR)/ca.crt $(CERTS_DIR)/client.crt
@openssl verify -CAfile $(CERTS_DIR)/ca.crt $(CERTS_DIR)/server.crt

test: setup test_normal test_security

test_normal:
@echo "Testing Riak Python Client (without security)"
@../setup.py disable_security --riak-admin=${RIAK_ADMIN}
@../setup.py disable_security --riak-admin=$(RIAK_ADMIN)
@RIAK_TEST_PROTOCOL='pbc' RUN_YZ=1 RUN_DATATYPES=1 RUN_INDEXES=1 ./tox_runner.sh ..
@RIAK_TEST_PROTOCOL='http' RUN_YZ=1 RUN_DATATYPES=1 RUN_INDEXES=1 ./tox_runner.sh ..

test_security:
@echo "Testing Riak Python Client (with security)"
@../setup.py enable_security --riak-admin=${RIAK_ADMIN}
@../setup.py enable_security --riak-admin=$(RIAK_ADMIN)
@RIAK_TEST_PROTOCOL='pbc' RUN_YZ=1 RUN_INDEXES=1 RUN_SECURITY=1 RUN_POOL=0 RUN_RESOLVE=0 ./tox_runner.sh ..
@RIAK_TEST_PROTOCOL='http' RUN_YZ=1 RUN_INDEXES=1 RUN_SECURITY=1 RUN_POOL=0 RUN_RESOLVE=0 RIAK_TEST_HTTP_PORT=18098 ./tox_runner.sh ..

Expand All @@ -40,11 +42,5 @@ test_timeseries:
@../setup.py disable_security --riak-admin=${RIAK_ADMIN}
@RIAK_TEST_PROTOCOL='pbc' RUN_YZ=0 RUN_DATATYPES=0 RUN_INDEXES=1 RUN_TIMESERIES=1 ./tox_runner.sh ..

# These are required to actually build all the Python versions:
# * pip install tox
# * pyenv - https://github.com/yyuu/pyenv
# And two pyenv plugins:
# * pyenv virtualenv - https://github.com/yyuu/pyenv-virtualenv
# * pyenv alias - https://github.com/s1341/pyenv-alias
setup:
./tox_setup.sh
140 changes: 85 additions & 55 deletions buildbot/tox_setup.sh
Original file line number Diff line number Diff line change
@@ -1,74 +1,104 @@
#!/usr/bin/env bash
# pyenv root
export PYENV_ROOT="$HOME/.pyenv"
TEST_ROOT=$PWD/..

# Install pyenv if it's missing
if [[ ! -d $PYENV_ROOT ]]; then
git clone git://github.com/yyuu/pyenv.git ${PYENV_ROOT}
cd ${PYENV_ROOT}
# Get the latest tagged version
git checkout `git tag | tail -1`
if [[ ! -d $PYENV_ROOT ]]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are only looking for the existence of the variable, you can probably do [[ -z "$PYENV_ROOT" ]] since it looks like you are only setting the variable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intended that to both check for existence of the variable and the directory to which it points, in one shot.

then
export PYENV_ROOT="$HOME/.pyenv"
fi

# Upgrade it, if it's too old
if [[ -z $(pyenv install --list | grep 3.4.3) ]]; then
cd ${PYENV_ROOT}
git pull origin master
git pull -u origin master
# Get the latest tagged version
git checkout `git tag | tail -1`
declare -r PROJDIR="$PWD/.."
if [[ ! -s $PROJDIR/riak/__init__.py ]]
then
echo "[ERROR] script must be run from the buildbot/ dir in github.com/basho/riak-python-client" 1>&2
exit 1
fi

if [[ ! -d ${PYENV_ROOT}/plugins/pyenv-virtualenv ]]; then
git clone https://github.com/yyuu/pyenv-virtualenv.git ${PYENV_ROOT}/plugins/pyenv-virtualenv
cd ${PYENV_ROOT}/plugins/pyenv-virtualenv
git checkout `git tag | tail -1`
# Install pyenv if it's missing
if [[ ! -d $PYENV_ROOT ]]
then
git clone https://github.com/yyuu/pyenv.git $PYENV_ROOT
else
(cd $PYENV_ROOT && git fetch --all)
fi

if [[ ! -d ${PYENV_ROOT}/plugins/pyenv-alias ]]; then
git clone https://github.com/s1341/pyenv-alias.git ${PYENV_ROOT}/plugins/pyenv-alias
(cd $PYENV_ROOT && git checkout $(git describe --tags $(git rev-list --tags --max-count=1)))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


declare -r pyenv_virtualenv_dir="$PYENV_ROOT/plugins/pyenv-virtualenv"
if [[ ! -d $pyenv_virtualenv_dir ]]
then
git clone https://github.com/yyuu/pyenv-virtualenv.git $pyenv_virtualenv_dir
else
(cd $pyenv_virtualenv_dir && git fetch --all)
fi

# Add pyenv root to PATH
# and initialize pyenv
PATH="$PYENV_ROOT/bin:$PATH"
# initialize pyenv
eval "$(pyenv init -)"
# initialize pyenv virtualenv
eval "$(pyenv virtualenv-init -)"
(cd $pyenv_virtualenv_dir && git checkout $(git describe --tags $(git rev-list --tags --max-count=1)))

# Now install (allthethings) versions for testing
if [[ -z $(pyenv versions | grep riak_3.4.3) ]]; then
VERSION_ALIAS="riak_3.4.3" pyenv install 3.4.3
pyenv virtualenv riak_3.4.3 riak-py34
declare -r pyenv_alias_dir="$PYENV_ROOT/plugins/pyenv-alias"
if [[ ! -d $pyenv_alias_dir ]]
then
git clone https://github.com/s1341/pyenv-alias.git $pyenv_alias_dir
else
(cd $pyenv_alias_dir && git pull origin master)
fi
if [[ -z $(pyenv versions | grep riak_3.3.6) ]]; then
VERSION_ALIAS="riak_3.3.6" pyenv install 3.3.6
pyenv virtualenv riak_3.3.6 riak-py33
fi
if [[ -z $(pyenv versions | grep riak_3.5.1) ]]; then
VERSION_ALIAS="riak_3.5.1" pyenv install 3.5.1
pyenv virtualenv riak_3.5.1 riak-py35

# Add pyenv root to PATH
# and initialize pyenv
if [[ $PATH != */.pyenv* ]]
then
echo "[INFO] adding $PYENV_ROOT/bin to PATH"
export PATH="$PYENV_ROOT/bin:$PATH"
fi
if [[ -z $(pyenv versions | grep riak_2.7.11) ]]; then
VERSION_ALIAS="riak_2.7.11" pyenv install 2.7.11
pyenv virtualenv riak_2.7.11 riak-py27

if [[ $(type -t pyenv) != 'function' ]]
then
echo "[INFO] init pyenv"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
fi
if [[ -z $(pyenv versions | grep riak_2.7.8) ]]; then
VERSION_ALIAS="riak_2.7.8" pyenv install 2.7.8
pyenv virtualenv riak_2.7.8 riak-py278

# NB: 2.7.8 is special-cased
for pyver in 2.7 3.3 3.4 3.5
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love how compact this is, but we also need to install Python 2.7.8 to test older versions of Python which still require PyOpenSSL for their security layer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexmoore

Do we need to test and support that version as it's more than a year old and not the latest version in the 2.7 series? The 2.7.X Python series end-of-life isn't until 2020, but that (in my opinion) means we only need to test on the latest version of that series.

I can put code back to test this specific version (2.7.8) if we need to.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that relatively current distros ship with old Pythons as their defaults. Ubuntu 14.04 ships with 2.7.3 and Centos 7 ships with 2.7.5, for example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh! I'll put 2.7.8 back in.

do
if ! pyenv versions | fgrep -v 'riak_2.7.8' | fgrep -q "riak_$pyver"
then
declare -i pymaj="${pyver%.*}"
declare -i pymin="${pyver#*.}"
pyver_latest="$(pyenv install --list | grep -E "^[[:space:]]+$pymaj\\.$pymin\\.[[:digit:]]+\$" | tail -n1 | sed -e 's/[[:space:]]//g')"

echo "[INFO] installing Python $pyver_latest"
riak_pyver="riak_$pyver_latest"
VERSION_ALIAS="$riak_pyver" pyenv install "$pyver_latest"
pyenv virtualenv "$riak_pyver" "riak-py$pymaj$pymin"
fi
done

if ! pyenv versions | fgrep -q 'riak_2.7.8'
then
echo "[INFO] installing Python 2.7.8"
VERSION_ALIAS='riak_2.7.8' pyenv install '2.7.8'
pyenv virtualenv 'riak_2.7.8' 'riak-py278'
fi
pyenv global riak-py34 riak-py33 riak-py35 riak-py27 riak-py278

(cd $PROJDIR && pyenv local riak-py35 riak-py34 riak-py33 riak-py27 riak-py278)

pyenv versions

# Now install tox
pip install --upgrade pip
if [ -z "`pip show tox`" ]; then
pip install -Iv tox
if [ -z "`pip show tox`" ]; then
echo "ERROR: Install of tox failed"
exit 1
fi
if [[ $(python --version) == Python\ 3.* ]]
then
pip install --upgrade pip
for module in six tox python3-protobuf
do
if ! pip show --quiet $module
then
pip install --ignore-installed $module
if ! pip show --quiet $module
then
echo "[ERROR] install of $module failed" 1>&2
exit 1
fi
fi
done
pyenv rehash
else
echo "[ERROR] expected Python 3 to be 'python' at this point" 1>&2
exit 1
fi
Loading