[CalendarServer-changes] [15190] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Oct 14 11:28:42 PDT 2015
Revision: 15190
http://trac.calendarserver.org//changeset/15190
Author: cdaboo at apple.com
Date: 2015-10-14 11:28:42 -0700 (Wed, 14 Oct 2015)
Log Message:
-----------
Make sure we patch cx_Oracle before building it.
Modified Paths:
--------------
CalendarServer/trunk/bin/_build.sh
CalendarServer/trunk/bin/package
CalendarServer/trunk/requirements-stable.txt
CalendarServer/trunk/setup.py
Added Paths:
-----------
CalendarServer/trunk/lib-patches/
CalendarServer/trunk/lib-patches/cx_Oracle/
CalendarServer/trunk/lib-patches/cx_Oracle/nclob-fixes-and-prefetch.patch
Modified: CalendarServer/trunk/bin/_build.sh
===================================================================
--- CalendarServer/trunk/bin/_build.sh 2015-10-14 17:41:35 UTC (rev 15189)
+++ CalendarServer/trunk/bin/_build.sh 2015-10-14 18:28:42 UTC (rev 15190)
@@ -93,6 +93,7 @@
conditional_set do_setup "true";
conditional_set force_setup "false";
conditional_set requirements "${wd}/requirements-dev.txt"
+ conditional_set virtualenv_opts "";
dev_home="${wd}/.develop";
dev_roots="${dev_home}/roots";
@@ -113,6 +114,9 @@
project="$(setup_print name)" || project="<unknown>";
+ dev_patches="${dev_home}/patches";
+ patches="${wd}/lib-patches";
+
# Find some hashing commands
# sha1() = sha1 hash, if available
# md5() = md5 hash, if available
@@ -169,6 +173,34 @@
}
+# Apply patches from lib-patches to the given dependency codebase.
+apply_patches () {
+ local name="$1"; shift;
+ local path="$1"; shift;
+
+ if [ -d "${patches}/${name}" ]; then
+ echo "";
+ echo "Applying patches to ${name} in ${path}...";
+
+ cd "${path}";
+ find "${patches}/${name}" \
+ -type f \
+ -name '*.patch' \
+ -print \
+ -exec patch -p0 --forward -i '{}' ';';
+ cd /;
+
+ fi;
+
+ echo "";
+ if [ -e "${path}/setup.py" ]; then
+ echo "Removing build directory ${path}/build...";
+ rm -rf "${path}/build";
+ echo "Removing pyc files from ${path}...";
+ find "${path}" -type f -name '*.pyc' -print0 | xargs -0 rm -f;
+ fi;
+}
+
# If do_get is turned on, get an archive file containing a dependency via HTTP.
www_get () {
if ! "${do_get}"; then return 0; fi;
@@ -315,6 +347,7 @@
rm -rf "${path}";
cd "$(dirname "${path}")";
get | ${decompress} | ${unpack};
+ apply_patches "${name}" "${path}";
cd "${wd}";
fi;
}
@@ -566,7 +599,27 @@
}
+#
+# Special cx_Oracle patch handling
+#
+cx_Oracle_patch() {
+ local f_hash="-m 6a49e1aa0e5b48589f8edfe5884ff5a5";
+ local v="5.2";
+ local n="cx_Oracle";
+ local p="${n}-${v}";
+
+ mkdir -p "${dev_patches}";
+
+ local srcdir="${dev_patches}/${p}";
+
+ www_get ${f_hash} "${n}" "${srcdir}" "https://pypi.python.org/packages/source/c/${n}/${p}.tar.gz";
+ cd "${dev_patches}";
+ tar zcf "${p}.tar.gz" "${p}";
+ cd "${wd}";
+ rm -rf "${srcdir}";
+}
+
#
# Build Python dependencies
#
@@ -603,6 +656,7 @@
"${bootstrap_python}" -m virtualenv \
--system-site-packages \
--no-setuptools \
+ ${virtualenv_opts} \
"${py_virtualenv}";
fi;
@@ -622,12 +676,17 @@
echo "";
"${pip_install}" --requirement="${requirements}";
- for option in $("${bootstrap_python}" -c 'import setup; print "\n".join(setup.extras_requirements.keys())'); do
- ruler "Preparing Python requirements for optional feature: ${option}";
+ for extra in $("${bootstrap_python}" -c 'import setup; print "\n".join(setup.extras_requirements.keys())'); do
+ ruler "Preparing Python requirements for optional feature: ${extra}";
echo "";
- if ! "${pip_install}" --editable="${wd}[${option}]"; then
- echo "Feature ${option} is optional; continuing.";
+
+ if [ "${extra}" = "Oracle" ]; then
+ cx_Oracle_patch;
fi;
+
+ if ! "${pip_install}" --editable="${wd}[${extra}]"; then
+ echo "Feature ${extra} is optional; continuing.";
+ fi;
done;
echo "";
@@ -690,6 +749,7 @@
--pre --allow-all-external \
--no-index \
--no-cache-dir \
+ --find-links="${dev_patches}" \
--find-links="${dev_home}/pip_downloads" \
--log-file="${dev_home}/pip.log" \
"$@";
@@ -701,6 +761,7 @@
--disable-pip-version-check \
--pre --allow-all-external \
--no-cache-dir \
+ --find-links="${dev_patches}" \
--log-file="${dev_home}/pip.log" \
"$@";
}
Modified: CalendarServer/trunk/bin/package
===================================================================
--- CalendarServer/trunk/bin/package 2015-10-14 17:41:35 UTC (rev 15189)
+++ CalendarServer/trunk/bin/package 2015-10-14 18:28:42 UTC (rev 15190)
@@ -110,16 +110,9 @@
py_virtualenv="${destination}/virtualenv";
py_bindir="${py_virtualenv}/bin";
py_ve_tools="${dev_home}/ve_tools";
+ virtualenv_opts="--always-copy";
+
- if [ ! -d "${py_virtualenv}" ]; then
- bootstrap_virtualenv;
- "${bootstrap_python}" -m virtualenv \
- --always-copy \
- --system-site-packages \
- --no-setuptools \
- "${py_virtualenv}";
- fi;
-
c_dependencies;
py_dependencies;
Added: CalendarServer/trunk/lib-patches/cx_Oracle/nclob-fixes-and-prefetch.patch
===================================================================
--- CalendarServer/trunk/lib-patches/cx_Oracle/nclob-fixes-and-prefetch.patch (rev 0)
+++ CalendarServer/trunk/lib-patches/cx_Oracle/nclob-fixes-and-prefetch.patch 2015-10-14 18:28:42 UTC (rev 15190)
@@ -0,0 +1,52 @@
+diff -ur ./Connection.c ../cx_Oracle-5.2-patched/Connection.c
+--- ./Connection.c 2015-06-06 23:31:08.000000000 -0400
++++ ../cx_Oracle-5.2-patched/Connection.c 2015-10-14 11:43:01.000000000 -0400
+@@ -747,6 +747,18 @@
+ if (newPasswordObj)
+ return Connection_ChangePassword(self, self->password, newPasswordObj);
+
++ // set lob prefetch attribute to session
++ ub4 default_lobprefetch_size = 4096; // Set default size to 4K
++ status = OCIAttrSet (self->sessionHandle, OCI_HTYPE_SESSION,
++ (void *)&default_lobprefetch_size, 0,
++ OCI_ATTR_DEFAULT_LOBPREFETCH_SIZE,
++ self->environment->errorHandle);
++ if (Environment_CheckForError(self->environment, status,
++ "Connection_Connect(): OCI_ATTR_DEFAULT_LOBPREFETCH_SIZE") < 0) {
++ self->sessionHandle = NULL;
++ return -1;
++ }
++
+ // begin the session
+ Py_BEGIN_ALLOW_THREADS
+ status = OCISessionBegin(self->handle, self->environment->errorHandle,
+diff -ur ./Cursor.c ../cx_Oracle-5.2-patched/Cursor.c
+--- ./Cursor.c 2015-06-06 18:51:44.000000000 -0400
++++ ../cx_Oracle-5.2-patched/Cursor.c 2015-10-14 11:57:02.000000000 -0400
+@@ -1841,8 +1841,8 @@
+ }
+ }
+ Py_BEGIN_ALLOW_THREADS
+- status = OCIStmtFetch(self->handle, self->environment->errorHandle,
+- numRows, OCI_FETCH_NEXT, OCI_DEFAULT);
++ status = OCIStmtFetch2(self->handle, self->environment->errorHandle,
++ numRows, OCI_FETCH_NEXT, 0, OCI_DEFAULT);
+ Py_END_ALLOW_THREADS
+ if (status != OCI_NO_DATA) {
+ if (Environment_CheckForError(self->environment, status,
+diff -ur ./ExternalLobVar.c ../cx_Oracle-5.2-patched/ExternalLobVar.c
+--- ./ExternalLobVar.c 2015-06-15 20:16:14.000000000 -0400
++++ ../cx_Oracle-5.2-patched/ExternalLobVar.c 2015-10-14 12:05:01.000000000 -0400
+@@ -275,10 +275,9 @@
+ else amount = 1;
+ }
+ length = amount;
+- if (var->lobVar->type == &vt_CLOB)
++ if ((var->lobVar->type == &vt_CLOB) || (var->lobVar->type == &vt_NCLOB))
++ // Always use environment setting for character LOBs
+ bufferSize = amount * var->lobVar->environment->maxBytesPerCharacter;
+- else if (var->lobVar->type == &vt_NCLOB)
+- bufferSize = amount * 2;
+ else bufferSize = amount;
+
+ // create a string for retrieving the value
Modified: CalendarServer/trunk/requirements-stable.txt
===================================================================
--- CalendarServer/trunk/requirements-stable.txt 2015-10-14 17:41:35 UTC (rev 15189)
+++ CalendarServer/trunk/requirements-stable.txt 2015-10-14 18:28:42 UTC (rev 15190)
@@ -55,7 +55,7 @@
pg8000==1.10.2
# [Oracle] extra
- #cx_Oracle==5.1.3 # Not in PyPI
+ #cx_Oracle==5.2 # Needs manual patch
pyOpenSSL==0.14
cryptography==0.9
Modified: CalendarServer/trunk/setup.py
===================================================================
--- CalendarServer/trunk/setup.py 2015-10-14 17:41:35 UTC (rev 15189)
+++ CalendarServer/trunk/setup.py 2015-10-14 18:28:42 UTC (rev 15190)
@@ -349,7 +349,7 @@
extras_requirements = {
"LDAP": ["twextpy[LDAP]"],
"OpenDirectory": ["twextpy[OpenDirectory]"],
- "Oracle": ["twextpy[Oracle]", "cx_Oracle"],
+ "Oracle": ["twextpy[Oracle]", "cx_Oracle=5.2"],
"Postgres": ["twextpy[Postgres]", "pg8000"],
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20151014/40efbcf1/attachment-0001.html>
More information about the calendarserver-changes
mailing list