[CalendarServer-changes] [12433] twext/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:17:12 PDT 2014
Revision: 12433
http://trac.calendarserver.org//changeset/12433
Author: wsanchez at apple.com
Date: 2014-01-23 15:30:31 -0800 (Thu, 23 Jan 2014)
Log Message:
-----------
Use pip in favor of setuptools.
Modified Paths:
--------------
twext/trunk/bin/_build.sh
twext/trunk/bin/_py.sh
twext/trunk/bin/develop
twext/trunk/bin/install_pip
twext/trunk/bin/pyflakes
twext/trunk/bin/python
twext/trunk/setup.py
Modified: twext/trunk/bin/_build.sh
===================================================================
--- twext/trunk/bin/_build.sh 2014-01-23 20:09:51 UTC (rev 12432)
+++ twext/trunk/bin/_build.sh 2014-01-23 23:30:31 UTC (rev 12433)
@@ -435,11 +435,23 @@
}
+ruler () {
+ echo "____________________________________________________________";
+ echo "";
+
+ if [ $# -gt 0 ]; then
+ echo "$@";
+ fi;
+}
+
+
+
#
# Build C dependencies
#
c_dependencies () {
+ ruler;
if find_header ffi/ffi.h; then
using_system "libffi";
else
@@ -448,6 +460,7 @@
"ftp://sourceware.org/pub/libffi/libffi-3.0.13.tar.gz"
fi;
+ ruler;
if find_header ldap.h 20428 LDAP_VENDOR_VERSION; then
using_system "OpenLDAP";
else
@@ -460,6 +473,7 @@
--disable-bdb --disable-hdb;
fi;
+ ruler;
if find_header sasl/sasl.h && ! find_header sasl.h; then
mkdir -p "${dev_root}/include";
echo "#include <sasl/sasl.h>" > "${dev_root}/include/sasl.h"
@@ -486,25 +500,54 @@
mkdir -p "${dev_root}";
mkdir -p "${dev_libdir}";
- export PYTHONPATH="${dev_libdir}:${PYTHONPATH:-}"
+ # export PYTHONPATH="${dev_libdir}:${PYTHONPATH:-}"
- export PATH="${dev_root}/bin:${PATH}";
- export C_INCLUDE_PATH="${dev_root}/include:${C_INCLUDE_PATH:-}";
- export LD_LIBRARY_PATH="${dev_root}/lib:${dev_root}/lib64:${LD_LIBRARY_PATH:-}";
- export CPPFLAGS="-I${dev_root}/include ${CPPFLAGS:-} ";
- export LDFLAGS="-L${dev_root}/lib -L${dev_root}/lib64 ${LDFLAGS:-} ";
- export DYLD_LIBRARY_PATH="${dev_root}/lib:${dev_root}/lib64:${DYLD_LIBRARY_PATH:-}";
- export PKG_CONFIG_PATH="${dev_root}/lib/pkgconfig:${PKG_CONFIG_PATH:-}";
+ # export PATH="${dev_root}/bin:${PATH}";
+ # export C_INCLUDE_PATH="${dev_root}/include:${C_INCLUDE_PATH:-}";
+ # export LD_LIBRARY_PATH="${dev_root}/lib:${dev_root}/lib64:${LD_LIBRARY_PATH:-}";
+ # export CPPFLAGS="-I${dev_root}/include ${CPPFLAGS:-} ";
+ # export LDFLAGS="-L${dev_root}/lib -L${dev_root}/lib64 ${LDFLAGS:-} ";
+ # export DYLD_LIBRARY_PATH="${dev_root}/lib:${dev_root}/lib64:${DYLD_LIBRARY_PATH:-}";
+ # export PKG_CONFIG_PATH="${dev_root}/lib/pkgconfig:${PKG_CONFIG_PATH:-}";
cd "${wd}";
- if ! "${python}" ./setup.py develop \
- --install-dir "${dev_libdir}" \
- --script-dir "${dev_bindir}" \
- > "${dev_root}/setup.log" 2>&1; then
- err=$?;
- echo "Unable to set up for development:"
- cat "${dev_root}/setup.log";
- exit ${err};
- fi;
+
+ "${bootstrap_python}" -m virtualenv "${dev_root}";
+
+ python="${dev_bindir}/python";
+
+ for requirements in "${wd}/requirements/"*; do
+
+ ruler "Preparing Python requirements: ${requirements}";
+ echo "";
+
+ if ! "${python}" -m pip install \
+ --requirement "${requirements}" \
+ --download-cache "${dev_home}/pip_cache" \
+ ; then
+ err=$?;
+ echo "Unable to set up Python requirements: ${requirements}";
+ if [ "${requirements#${wd}/requirements/opt_}" != "${requirements}" ]; then
+ echo "Requirements ${requirements} are optional; continuing.";
+ else
+ echo "";
+ exit ${err};
+ fi;
+ fi;
+
+ done;
+
+ echo "";
}
+
+
+
+#
+# Set up for development
+#
+develop () {
+ init_build;
+ c_dependencies;
+ py_dependencies;
+}
Modified: twext/trunk/bin/_py.sh
===================================================================
--- twext/trunk/bin/_py.sh 2014-01-23 20:09:51 UTC (rev 12432)
+++ twext/trunk/bin/_py.sh 2014-01-23 23:30:31 UTC (rev 12433)
@@ -48,6 +48,11 @@
#
# Detect which version of Python to use, then print out which one was detected.
#
+# This will prefer the python interpreter in the PYTHON environment variable.
+# If that's not found, it will check for "python2.7", "python2.6" and "python",
+# looking for each in your PATH and, failing that, in a number of well-known
+# locations.
+#
detect_python_version () {
local v;
local p;
@@ -67,9 +72,11 @@
"/sw/bin/python${v}" \
;
do
- if try_python "${p}"; then
- echo "${p}";
- return 0;
+ if p="$(type -p "${p}")"; then
+ if try_python "${p}"; then
+ echo "${p}";
+ return 0;
+ fi;
fi;
done;
done;
@@ -84,6 +91,8 @@
local v="$1"; shift;
local mv="$1"; shift;
+ local vh;
+ local mvh;
local result;
while true; do
@@ -131,7 +140,7 @@
# important on systems with older system pythons (2.4 or earlier) with an
# alternate install of Python, or alternate python installation mechanisms
# like virtualenv.
- python="$(detect_python_version)";
+ bootstrap_python="$(detect_python_version)";
# Set the $PYTHON environment variable to an absolute path pointing at the
# appropriate python executable, a standard-ish mechanism used by certain
@@ -139,10 +148,10 @@
# the part of the PostgreSQL build process which builds pl_python. Note that
# detect_python_version, above, already honors $PYTHON, so if this is already
# set it won't be stomped on, it will just be re-set to the same value.
- export PYTHON="$(type -p ${python})";
+ export PYTHON="$(type -p ${bootstrap_python})";
- if [ -z "${python:-}" ]; then
- echo "No suitable python found. Python 2.6+ is required.";
+ if [ -z "${bootstrap_python:-}" ]; then
+ echo "No suitable python found. Python 2.6 or 2.7 is required.";
exit 1;
- fi
+ fi;
}
Modified: twext/trunk/bin/develop
===================================================================
--- twext/trunk/bin/develop 2014-01-23 20:09:51 UTC (rev 12432)
+++ twext/trunk/bin/develop 2014-01-23 23:30:31 UTC (rev 12433)
@@ -16,6 +16,9 @@
# limitations under the License.
##
+set -e;
+set -u;
+
if [ -z "${wd:-}" ]; then
wd="$(cd "$(dirname "$0")/.." && pwd)";
fi;
@@ -24,6 +27,4 @@
. "${wd}/bin/_build.sh";
-init_build;
-c_dependencies;
-py_dependencies;
+develop;
Modified: twext/trunk/bin/install_pip
===================================================================
--- twext/trunk/bin/install_pip 2014-01-23 20:09:51 UTC (rev 12432)
+++ twext/trunk/bin/install_pip 2014-01-23 23:30:31 UTC (rev 12433)
@@ -25,42 +25,35 @@
cd "${tmp}";
-find_tool ()
-{
- local tool="$1"; shift;
- local version="$1"; shift;
- local cmd;
-
- for cmd in "${tool}-${py_version}" "${tool}${py_version}"; do
- if type -p "${cmd}" > /dev/null; then
- echo "${cmd}";
- return 0
- fi;
- done;
-
- return 1;
-}
-
-
for py_version in "2.7" "2.6"; do
- if ! type -p "python${py_version}" > /dev/null; then
- echo "Python ${py_version} not found.";
- continue;
- fi;
+ python="python${py_version}";
- easy_install="$(find_tool "easy_install" "${py_version}")";
+ if ! "${python}" -V > /dev/null 2>&1; then
+ continue;
+ fi;
- sudo "${easy_install}" --upgrade setuptools;
+ echo "________________________________________";
+ echo "Installing tools for Python ${py_version}...";
- if ! pip="$(find_tool "pip" "${py_version}")"; then
- sudo "python${py_version}" "${wd}/bin/_get_pip";
- fi;
+ if ! "${python}" -m easy_install --help > /dev/null; then
+ echo "Setuptools is not installed; cannot continue.";
+ continue;
+ fi;
- pip="$(find_tool "pip" "${py_version}")";
+ echo "";
+ sudo "${python}" -m easy_install --upgrade setuptools;
- sudo "${pip}" install --upgrade pip;
+ if ! python -m pip -V > /dev/null; then
+ echo "";
+ sudo "${python}" "${wd}/bin/_get_pip";
+ fi;
+ echo "";
+ sudo python -m pip install --upgrade pip;
+ echo "";
+ sudo python -m pip install --upgrade virtualenv;
+
done;
rm -rf "${tmp}";
Modified: twext/trunk/bin/pyflakes
===================================================================
--- twext/trunk/bin/pyflakes 2014-01-23 20:09:51 UTC (rev 12432)
+++ twext/trunk/bin/pyflakes 2014-01-23 23:30:31 UTC (rev 12433)
@@ -21,7 +21,11 @@
wd="$(cd "$(dirname "$0")/.." && pwd -L)";
-. "${wd}/bin/develop";
+export TWEXT_DEVELOP="true";
+. "${wd}/bin/_build.sh";
+
+develop;
+
pip install pyflakes --no-use-wheel --upgrade --target="${dev_libdir}" > "${dev_root}/pip_pyflakes.log" || true;
exec "${python}" -m pyflakes "$@";
Modified: twext/trunk/bin/python
===================================================================
--- twext/trunk/bin/python 2014-01-23 20:09:51 UTC (rev 12432)
+++ twext/trunk/bin/python 2014-01-23 23:30:31 UTC (rev 12433)
@@ -21,6 +21,10 @@
wd="$(cd "$(dirname "$0")/.." && pwd)";
-. "${wd}/bin/develop";
+export TWEXT_DEVELOP="true";
+. "${wd}/bin/_build.sh";
+
+develop;
+
exec "${python}" "$@";
Modified: twext/trunk/setup.py
===================================================================
--- twext/trunk/setup.py 2014-01-23 20:09:51 UTC (rev 12432)
+++ twext/trunk/setup.py 2014-01-23 23:30:31 UTC (rev 12433)
@@ -20,11 +20,12 @@
import sys
import errno
-import os
+from os import listdir, environ as environment
from os.path import dirname, abspath, join as joinpath
+from itertools import chain
import subprocess
-from itertools import chain
from setuptools import setup, find_packages as setuptools_find_packages
+from pip.req import parse_requirements
#
@@ -119,37 +120,39 @@
# Dependencies
#
-setup_requirements = [
-]
+requirements_dir = joinpath(dirname(__file__), "requirements")
-install_requirements = [
- "cffi==0.6",
- "twisted>=13.2.0",
-]
-extras_requirements = {
- "LDAP": ["python-ldap>=2.4.13"],
- "DAL": ["sqlparse==0.1.2"],
-}
+def read_requirements(reqs_filename):
+ return [
+ str(r.req) for r in
+ parse_requirements(joinpath(requirements_dir, reqs_filename))
+ ]
+
+setup_requirements = []
+
+install_requirements = read_requirements("base.txt")
+
+extras_requirements = dict(
+ (reqs_filename[4:-4], read_requirements(reqs_filename))
+ for reqs_filename in listdir(requirements_dir)
+ if reqs_filename.startswith("opt_") and reqs_filename.endswith(".txt")
+)
+
# Requirements for development and testing
-develop_requirements = [
- "docutils>=0.11",
- "mockldap>=0.1.4",
-]
+develop_requirements = read_requirements("develop.txt")
-if os.environ.get("TWEXT_DEVELOP", "false") == "true":
+if environment.get("TWEXT_DEVELOP", "false") == "true":
install_requirements.extend(develop_requirements)
-
- # FIXME: It would be better to figure out how to get `setup.py develop` to
- # fetch the extras_requirements...
install_requirements.extend(chain(*extras_requirements.values()))
-# Add oracle after defining the development requirements, because it's
-# not exactly super portable and so it's potentially a major pain to
-# install.
+ # Remove cx_Oracle here because we don't automate it's installation.
+ install_requirements = [
+ r for r in install_requirements
+ if not r.startswith("cx-Oracle")
+ ]
-extras_requirements["Oracle"] = ["cx_Oracle==5.1.2"]
#
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/bff09b72/attachment.html>
More information about the calendarserver-changes
mailing list