aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kevi...@apache.org
Subject git commit: AURORA-183: Upgrade twitter.common.python to 0.3.0
Date Tue, 04 Feb 2014 01:13:20 GMT
Updated Branches:
  refs/heads/master 18267bfd2 -> 1e810e70a


AURORA-183: Upgrade twitter.common.python to 0.3.0

Use the new "pex" utility from twitter.common.python to bootstrap pants
rather than relying on knowledge of the inner workings of
twitter.common.python APIs. I also took the opportunity to refactor the
common "maybe bootstrap a virtualenv" pattern used with some support
tools to use a consistent build-support/NAME.venv pattern.

Testing Done:
Ran ./pants, ./rbt, ./build-support/pex,
./build-support/release/make-python-sdists from clean and dirty repos.

./pants src/test/python:all

Bugs closed: AURORA-183

Reviewed at https://reviews.apache.org/r/17679/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/1e810e70
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/1e810e70
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/1e810e70

Branch: refs/heads/master
Commit: 1e810e70a75c5b26f4ba10d4cc7deb28bf084418
Parents: 18267bf
Author: Kevin Sweeney <kevints@apache.org>
Authored: Mon Feb 3 17:13:05 2014 -0800
Committer: Kevin Sweeney <kevints@apache.org>
Committed: Mon Feb 3 17:13:05 2014 -0800

----------------------------------------------------------------------
 .gitignore                               |  5 +-
 build-support/pex                        | 33 +++++++++++
 build-support/release/make-python-sdists |  8 +--
 pants                                    | 81 +++++----------------------
 rbt                                      | 14 ++---
 5 files changed, 59 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/1e810e70/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 25114b9..7e43385 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,11 +8,10 @@
 .pants.*
 .vagrant/
 build/
-build-support/rbtools/
+build-support/*.pex
+build-support/*.venv
 build-support/virtualenv-*
-build-support/make-python-sdists.virtualenv
 dist/
 gradle-app.setting
 out/
-pants.pex
 third_party/

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/1e810e70/build-support/pex
----------------------------------------------------------------------
diff --git a/build-support/pex b/build-support/pex
new file mode 100755
index 0000000..cd083d9
--- /dev/null
+++ b/build-support/pex
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+#
+# Copyright 2013 Apache Software Foundation
+#
+# Licensed 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.
+#
+# Wrapper script for self-bootstrapping pex.
+set -e
+
+TWITTER_COMMON_PYTHON_VERSION=0.3.0
+
+if ! [ -f build-support/pex.venv/BOOTSTRAPPED ] || \
+    [ $(< build-support/pex.venv/BOOTSTRAPPED) != $TWITTER_COMMON_PYTHON_VERSION ]; then
+
+  echo Bootstrapping twitter.common.python @ $TWITTER_COMMON_PYTHON_VERSION
+  rm -fr build-support/pex.venv
+  ./build-support/virtualenv build-support/pex.venv
+  source build-support/pex.venv/bin/activate
+  pip install "twitter.common.python==$TWITTER_COMMON_PYTHON_VERSION"
+  echo $TWITTER_COMMON_PYTHON_VERSION > build-support/pex.venv/BOOTSTRAPPED
+fi
+source build-support/pex.venv/bin/activate
+exec pex "$@"

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/1e810e70/build-support/release/make-python-sdists
----------------------------------------------------------------------
diff --git a/build-support/release/make-python-sdists b/build-support/release/make-python-sdists
index b2314d7..43e74be 100755
--- a/build-support/release/make-python-sdists
+++ b/build-support/release/make-python-sdists
@@ -32,11 +32,11 @@ cd "`git rev-parse --show-toplevel`"
 # Without this indirection pants will use the system setuptools, which on Ubuntu 12.04 is
old,
 # buggy, and produces a broken apache.thermos.observer.
 # TODO(ksweeney): Remove this indirection when pants supports this natively.
-if [[ ! -f build-support/make-python-sdists.virtualenv/BOOTSTRAPPED ]]; then
-  ./build-support/virtualenv build-support/make-python-sdists.virtualenv
-  touch build-support/make-python-sdists.virtualenv/BOOTSTRAPPED
+if [[ ! -f build-support/make-python-sdists.venv/BOOTSTRAPPED ]]; then
+  ./build-support/virtualenv build-support/make-python-sdists.venv
+  touch build-support/make-python-sdists.venv/BOOTSTRAPPED
 fi
-source build-support/make-python-sdists.virtualenv/bin/activate
+source build-support/make-python-sdists.venv/bin/activate
 
 for t in "${TARGETS[@]}"; do
   ./pants setup_py $t

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/1e810e70/pants
----------------------------------------------------------------------
diff --git a/pants b/pants
index 229e201..3980345 100755
--- a/pants
+++ b/pants
@@ -14,73 +14,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-PANTS_ROOT=$(dirname "$0")
-PANTS_VERSION=$(cat "$PANTS_ROOT/.pantsversion")
-
-if [[ -e "$PANTS_ROOT/pants.pex" ]]; then
-  cat <<EOF | PANTS_ROOT="$PANTS_ROOT" PANTS_VERSION=$PANTS_VERSION python
-from contextlib import closing
-import json
-import os
-import sys
-import zipfile
-
-with closing(zipfile.ZipFile(os.path.join(os.environ['PANTS_ROOT'], 'pants.pex'))) as zf:
-  pex_info = json.loads(zf.read('PEX-INFO'))
-
-for requirement, _, _ in pex_info['requirements']:
-  if '==' in requirement:
-    req, version = requirement.split('==', 2)
-    if req == 'twitter.pants' and version == os.environ['PANTS_VERSION']:
-      sys.exit(0)
-
-sys.exit(1)
-EOF
-
-  if [ $? -eq 0 ]; then
-    exec "$PANTS_ROOT/pants.pex" "$@"
-  fi
+set -o errexit
+set -o nounset
+
+PANTS_VERSION=0.0.13
+if ! [[ -e build-support/pants-$PANTS_VERSION.pex ]]; then
+  echo "Building pants.pex @ $PANTS_VERSION"
+  ./build-support/pex \
+    --requirement "twitter.pants==$PANTS_VERSION" \
+    --entry-point twitter.pants.bin.pants_exe:main \
+    -p build-support/pants-$PANTS_VERSION.pex.tmp
+  mv build-support/pants-$PANTS_VERSION.pex.tmp build-support/pants-$PANTS_VERSION.pex  #
2PC
+  echo "Built pants-$PANTS_VERSION.pex"
 fi
 
-PANTS_TEMP=$(mktemp -d /tmp/pants.XXXXXX)
-
-./build-support/virtualenv "$PANTS_TEMP/tcp"
-pushd "$PANTS_TEMP"
-
-source tcp/bin/activate
-
-pip install twitter.common.python==0.2.0
-
-PYTHON_VERBOSE=1 PEX_VERBOSE=1 python <<EOF
-from twitter.common.python.fetcher import Fetcher, PyPIFetcher
-from twitter.common.python.http import Crawler
-from twitter.common.python.obtainer import Obtainer
-from twitter.common.python.pex_builder import PEXBuilder
-from twitter.common.python.resolver import Resolver
-from twitter.common.python.translator import Translator
-
-pb = PEXBuilder()
-resolver = Resolver(crawler=Crawler(), fetchers=[PyPIFetcher()])
-req = 'twitter.pants==$PANTS_VERSION'
-pb.add_requirement(req)
-for dist in resolver.resolve(req):
-  pb.add_distribution(dist)
-pb.info.entry_point = 'twitter.pants.bin.pants_exe:main'
-pb.build('dist/pants.pex')
-EOF
-
-BUILD_SUCCESS=$?
-
-deactivate
-
-popd
-
-if [ $BUILD_SUCCESS -ne 0 ]; then
-  echo 'Failed to build pants.'
-  exit 1
-fi
-
-cp -f -- "$PANTS_TEMP/dist/pants.pex" "$PANTS_ROOT"
-rm -rf "$PANTS_TEMP"
-
-exec "$PANTS_ROOT/pants.pex" "$@"
+exec ./build-support/pants-$PANTS_VERSION.pex "$@"

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/1e810e70/rbt
----------------------------------------------------------------------
diff --git a/rbt b/rbt
index 8828ead..c03c4c4 100755
--- a/rbt
+++ b/rbt
@@ -18,16 +18,16 @@
 set -e
 
 RBTOOLS_VERSION=0.5.5
-if ! [ -f build-support/rbtools/BOOTSTRAPPED ] || \
-    [ x`cat build-support/rbtools/BOOTSTRAPPED` != x$RBTOOLS_VERSION ]; then
+if ! [ -f build-support/rbt.venv/BOOTSTRAPPED ] || \
+    [ x`cat build-support/rbt.venv/BOOTSTRAPPED` != x$RBTOOLS_VERSION ]; then
 
   echo Bootstrapping rbtools @ $RBTOOLS_VERSION
-  rm -fr build-support/rbtools
-  ./build-support/virtualenv build-support/rbtools
-  source build-support/rbtools/bin/activate
+  rm -fr build-support/rbt.venv
+  ./build-support/virtualenv build-support/rbt.venv
+  source build-support/rbt.venv/bin/activate
   pip install "RBTools==$RBTOOLS_VERSION"
-  echo $RBTOOLS_VERSION > build-support/rbtools/BOOTSTRAPPED
+  echo $RBTOOLS_VERSION > build-support/rbt.venv/BOOTSTRAPPED
 fi
-source build-support/rbtools/bin/activate
+source build-support/rbt.venv/bin/activate
 # TODO(kevints): Use ./pants py here instead of virtualenv.
 exec rbt "$@"


Mime
View raw message