1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
|
<!--
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.
-->
<project name="Avro" default="dist" xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- Load user's default properties. -->
<property file="${user.home}/build.properties"/>
<!-- Shared directories -->
<property name="share.dir" value="${basedir}/../../share"/>
<property name="share.schema.dir" value="${share.dir}/schemas/"/>
<property name="dist.dir" value="${basedir}/../../dist/py"/>
<property name="top.build" value="${basedir}/../../build"/>
<property name="interop.data.dir" value="${top.build}/interop/data"/>
<property name="python" value="python"/>
<!-- Python implementation directories -->
<property name="build.dir" value="${basedir}/build"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="test.dir" value="${basedir}/test"/>
<property name="ivy.version" value="2.2.0"/>
<property name="ivy.jar" value="${basedir}/lib/ivy-${ivy.version}.jar"/>
<!-- Load shared properties -->
<loadfile srcFile="${share.dir}/VERSION.txt" property="avro.version">
<filterchain>
<striplinebreaks/>
</filterchain>
</loadfile>
<loadfile srcFile="${share.schema.dir}/org/apache/avro/ipc/HandshakeRequest.avsc" property="handshake.request.json"/>
<loadfile srcFile="${share.schema.dir}/org/apache/avro/ipc/HandshakeResponse.avsc" property="handshake.response.json"/>
<path id="java.classpath">
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</path>
<path id="test.path">
<pathelement location="${build.dir}/src"/>
<pathelement location="${build.dir}/test"/>
<pathelement location="${build.dir}/lib"/>
</path>
<target name="init" description="Create the build directory.">
<mkdir dir="${build.dir}"/>
<available file="${ivy.jar}" property="ivy.jar.found"/>
<antcall target="ivy-download"/>
<typedef uri="antlib:org.apache.ivy.ant">
<classpath>
<pathelement location="${ivy.jar}" />
</classpath>
</typedef>
</target>
<target name="ivy-download" unless="ivy.jar.found" >
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar" dest="${ivy.jar}" usetimestamp="true" />
</target>
<target name="build"
description="Copy project files to build/ and do string replacement."
depends="init">
<!-- Copy src/, test/, lib/ -->
<copy todir="${build.dir}/src">
<fileset dir="${src.dir}">
<exclude name="**/*.pyc"/>
<exclude name="**/*.py~"/>
</fileset>
</copy>
<copy todir="${build.dir}/test">
<fileset dir="${test.dir}">
<exclude name="**/*.pyc"/>
<exclude name="**/*.py~"/>
</fileset>
</copy>
<copy todir="${build.dir}/lib">
<fileset dir="${lib.dir}" />
</copy>
<!--Copy the protocols used for tethering -->
<copy todir="${build.dir}/src/avro/tether">
<fileset dir="${share.schema.dir}/org/apache/avro/mapred/tether/">
<include name="*.avpr"/>
</fileset>
</copy>
<!-- Inline the handshake schemas -->
<copy file="${src.dir}/avro/ipc.py"
toFile="${build.dir}/src/avro/ipc.py"
overwrite="true">
<filterset>
<filter token="HANDSHAKE_REQUEST_SCHEMA"
value="${handshake.request.json}"/>
<filter token="HANDSHAKE_RESPONSE_SCHEMA"
value="${handshake.response.json}"/>
</filterset>
</copy>
<!-- Inline the Avro version -->
<copy file="${basedir}/setup.py"
toFile="${build.dir}/setup.py"
overwrite="true">
<filterset>
<filter token="AVRO_VERSION" value="${avro.version}"/>
</filterset>
</copy>
<!-- Inline the Avro version -->
<copy file="${basedir}/scripts/avro"
toFile="${build.dir}/scripts/avro"
overwrite="true">
<filterset>
<filter token="AVRO_VERSION" value="${avro.version}"/>
</filterset>
</copy>
<!-- Make executable (Ant does not preseve executable bit) -->
<exec executable="chmod">
<arg value="a+x" />
<arg value="${build.dir}/scripts/avro" />
</exec>
<!-- Inline the interop data directory -->
<copy file="${test.dir}/test_datafile_interop.py"
toFile="${build.dir}/test/test_datafile_interop.py"
overwrite="true">
<filterset>
<filter token="INTEROP_DATA_DIR" value="${interop.data.dir}"/>
</filterset>
</copy>
<!-- Ensure we have a local copy of the tools jar -->
<ivy:retrieve
pattern="${basedir}/../java/tools/target/[artifact]-[revision].[ext]"/>
<!-- Inline the location of the tools jar -->
<copy file="${test.dir}/test_tether_word_count.py"
toFile="${build.dir}/test/test_tether_word_count.py"
overwrite="true">
<filterset>
<filter token="AVRO_VERSION" value="${avro.version}"/>
<filter token="TOPDIR" value="${basedir}"/>
</filterset>
</copy>
</target>
<target name="test"
description="Run python unit tests"
depends="build">
<taskdef name="py-test" classname="org.pyant.tasks.PythonTestTask"
classpathref="java.classpath"/>
<py-test python="${python}" pythonpathref="test.path" >
<fileset dir="${build.dir}/test">
<include name="test_*.py"/>
<exclude name="test_datafile_interop.py"/>
</fileset>
</py-test>
</target>
<!--Created a unittest to run just the tests for tethered jobs.
-->
<target name="test-tether"
description="Run unit tests for a hadoop python-tethered job."
depends="build">
<taskdef name="py-test" classname="org.pyant.tasks.PythonTestTask"
classpathref="java.classpath"/>
<py-test python="${python}" pythonpathref="test.path">
<fileset dir="${build.dir}/test">
<include name="test_tether*.py"/>
<!--<exclude name="test_datafile_interop.py"/>-->
</fileset>
</py-test>
</target>
<target name="interop-data-test"
description="Run python interop data tests"
depends="build">
<taskdef name="py-test" classname="org.pyant.tasks.PythonTestTask"
classpathref="java.classpath"/>
<py-test python="${python}" pythonpathref="test.path" >
<fileset dir="${build.dir}/test">
<include name="test_datafile_interop.py"/>
</fileset>
</py-test>
</target>
<target name="interop-data-generate"
description="Generate Python interop data files."
depends="build">
<mkdir dir="${interop.data.dir}"/>
<exec executable="${python}">
<env key="PYTHONPATH" value="$PYTHONPATH:${build.dir}/src"/>
<arg value="${build.dir}/test/gen_interop_data.py"/>
<arg value="${share.dir}/test/schemas/interop.avsc"/>
<arg value="${interop.data.dir}/py.avro"/>
</exec>
</target>
<target name="dist"
description="Build source distribution"
depends="build">
<mkdir dir="${dist.dir}"/>
<exec executable="${python}" failonerror="true" dir="${build.dir}">
<arg value="${build.dir}/setup.py"/>
<arg value="sdist"/>
<arg value="--dist-dir=${dist.dir}"/>
</exec>
</target>
<target name="clean"
description="Delete build files and their directories">
<delete includeemptydirs="true" failonerror="false">
<fileset file="MANIFEST"/>
<fileset dir="${build.dir}"/>
</delete>
</target>
</project>
|