Skip to content
This repository was archived by the owner on Dec 21, 2023. It is now read-only.

Commit c44d323

Browse files
author
Hoyt Koepke
committed
Updated make_wheel script.
1 parent d8e29d9 commit c44d323

File tree

1 file changed

+23
-106
lines changed

1 file changed

+23
-106
lines changed

scripts/make_wheel.sh

Lines changed: 23 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ fi
166166

167167
push_ld_library_path() {
168168
OLD_LIBRARY_PATH=$LD_LIBRARY_PATH
169-
export LD_LIBRARY_PATH=${WORKSPACE}/deps/local/lib:${WORKSPACE}/deps/local/lib64:$LD_LIBRARY_PATH
169+
export LD_LIBRARY_PATH=${WORKSPACE}/targets/lib;$LD_LIBRARY_PATH
170170
}
171171

172172
pop_ld_library_path() {
@@ -186,7 +186,7 @@ build_source() {
186186

187187
# make src/
188188
cd ${WORKSPACE}/${build_type}/src
189-
make -j${NUM_PROCS}
189+
make -j${NUM_PROCS} install
190190

191191
# make test/
192192
if [[ -z $SKIP_TEST ]]; then
@@ -197,6 +197,7 @@ build_source() {
197197
make -j${NUM_PROCS}
198198
fi
199199
fi
200+
200201
pop_ld_library_path
201202

202203
echo -e "\n\n================= Done Build Source ================\n\n"
@@ -222,126 +223,42 @@ unit_test() {
222223
echo -e "\n\n================= Done Python Unit Tests ================\n\n"
223224
}
224225

225-
mac_patch_rpath() {
226-
echo -e "\n\n\n================= Patching Mac RPath ================\n\n\n"
227-
# on mac we need to do a little work to fix up RPaths
228-
cd ${WORKSPACE}/${build_type}/src/python
229-
# - look for all files
230-
# - run 'file' on it
231-
# - look for binary files (shared libraries, executables)
232-
# - output is in the form [file]: type, so cut on ":", we just want the file
233-
flist=`find . -type f -not -path "*/CMakeFiles/*" -not -path "./dist/*" | xargs -L 1 file | grep x86_64 | cut -f 1 -d :`
234-
235-
# We are generally going to be installed in
236-
# a place of the form
237-
# PREFIX/lib/python2.7/site-packages/[module]
238-
# libpython2.7 will probably in PREFIX/lib
239-
# So for instance if I am in
240-
# PREFIX/lib/python2.7/site-packages/turicreate/unity_server
241-
# I need to add
242-
# ../../../ to the rpath (to make it to lib/)
243-
# But if I am in
244-
#
245-
# PREFIX/lib/python2.7/site-packages/turicreate/something/somewhere
246-
# I need to add
247-
# ../../../../ to the rpath
248-
for f in $flist; do
249-
# Lets explain the regexes
250-
# - The first regex removes "./"
251-
# - The second regex replaces the string "[something]/" with "../"
252-
# (making sure something does not contain '/' characters)
253-
# - The 3rd regex removes the last "filename" bit
254-
#
255-
# Example:
256-
# Input: ./turicreate/cython/cy_ipc.so
257-
# After 1st regex: turicreate/cython/cy_ipc.so
258-
# After 2nd regex: ../../cy_ipc.so
259-
# After 3rd regex: ../../
260-
relative=`echo $f | sed 's:\./::g' | sed 's:[^/]*/:../:g' | sed 's:[^/]*$::'`
261-
# Now we need ../../ to get to PREFIX/lib
262-
rpath="@loader_path/../../$relative"
263-
install_name_tool -add_rpath $rpath $f || true
264-
done
265-
}
266226

267227

268228
### Package the release folder into a wheel, and strip the binaries ###
269229
package_wheel() {
270-
if [[ $OSTYPE == darwin* ]]; then
271-
mac_patch_rpath
272-
fi
273-
echo -e "\n\n\n================= Packaging Wheel ================\n\n\n"
274-
cd ${WORKSPACE}/${build_type}/src/python
275-
276-
# strip binaries
277-
if [[ ! $OSTYPE == darwin* ]]; then
278-
cd ${WORKSPACE}/${build_type}/src/python/turicreate
279-
BINARY_LIST=`find . -type f -exec file {} \; | grep x86 | cut -d: -f 1`
280-
echo "Stripping binaries: $BINARY_LIST"
281-
282-
# make newline the separator for items in for loop - default is whitespace
283-
OLD_IFS=${IFS}
284-
IFS=$'\n'
285-
286-
for f in $BINARY_LIST; do
287-
if [ $OSTYPE == "msys" ] && [ $f == "./pylambda_worker.exe" ]; then
288-
echo "Skipping pylambda_worker"
289-
else
290-
echo "Stripping $f"
291-
strip -Sx $f;
292-
fi
293-
done
294-
295-
# set IFS back to default
296-
IFS=${OLD_IFS}
297-
cd ..
298-
fi
230+
cd ${WORKSPACE}/src/python
299231

232+
echo -e "\n\n\n================= Building Wheel ================\n\n\n"
300233
cd ${WORKSPACE}/${build_type}/src/python
301-
dist_type="bdist_wheel"
302234

303-
VERSION_NUMBER=`${PYTHON_EXECUTABLE} -c "from turicreate.version_info import version; print(version)"`
304-
${PYTHON_EXECUTABLE} setup.py ${dist_type} # This produced an wheel starting with turicreate-${VERSION_NUMBER} under dist/
235+
VERSION_NUMBER=`${PYTHON_EXECUTABLE} -c "import setup; print(setup.VERSION)"`
236+
wheel_name=`${PYTHON_EXECUTABLE} setup.py -q bdist_wheel_name`
237+
old_platform_tag=`${PYTHON_EXECUTABLE} -c "import distutils; print(distutils.util.get_platform())"`
238+
LD_LIBRARY_PATH='${WORKSPACE}/targets/lib' CPATH='${WORKSPACE}/targets/include' ${PYTHON_EXECUTABLE} setup.py bdist_wheel
239+
305240

306241
cd ${WORKSPACE}
307242

308-
WHEEL_PATH=`ls ${WORKSPACE}/${build_type}/src/python/dist/turicreate-${VERSION_NUMBER}*.whl`
243+
WHEEL_PATH=`ls ${WORKSPACE}/src/python/dist/${wheel_name}.whl`
244+
309245
if [[ $OSTYPE == darwin* ]]; then
310-
# Change the platform tag embedded in the file name
311-
temp=`echo $WHEEL_PATH | perl -ne 'print m/(^.*-).*$/'`
312-
temp=${temp/-cpdarwin-/-cp35m-}
246+
247+
DYLD_LIBRARY_PATH="${WORKSPACE}/targets/lib" delocate-wheel -v ${WHEEL_PATH}
313248

314249
platform_tag="macosx_10_12_intel.macosx_10_12_x86_64.macosx_10_13_intel.macosx_10_13_x86_64.macosx_10_14_intel.macosx_10_14_x86_64"
315-
# sdk_version=`xcrun --show-sdk-version`
316-
# if [[ $sdk_version =~ ^10\.13 ]]; then
317-
# platform_tag="macosx_10_13_intel.macosx_10_12_x86_64"
318-
# elif [[ $sdk_version =~ ^10\.12 ]]; then
319-
# platform_tag="macosx_10_12_intel.macosx_10_12_x86_64"
320-
# fi
321-
322-
NEW_WHEEL_PATH=${temp}${platform_tag}".whl"
323-
mv ${WHEEL_PATH} ${NEW_WHEEL_PATH}
324-
WHEEL_PATH=${NEW_WHEEL_PATH}
325-
else
326-
# Don't pick up -manylinux1 wheels, since those may have been created by a later step from a previous build.
327-
# Ignore those for now by selecting only -linux wheels.
328-
WHEEL_PATH=`ls ${WORKSPACE}/${build_type}/src/python/dist/turicreate-${VERSION_NUMBER}*-linux*.whl`
329-
fi
330250

331-
# Set Python Language Version Number
332-
NEW_WHEEL_PATH=${WHEEL_PATH}
333-
if [[ "$python35" == "1" ]]; then
334-
NEW_WHEEL_PATH=${WHEEL_PATH/-py3-/-cp35-}
335-
elif [[ "$python36" == "1" ]]; then
336-
NEW_WHEEL_PATH=${WHEEL_PATH/-py3-/-cp36-}
251+
NEW_WHEEL_PATH=${WORKSPACE}/targets/${wheel_name/$old_platform_tag/$platform_tag}.whl
252+
337253
else
338-
NEW_WHEEL_PATH=${WHEEL_PATH/-py2-/-cp27-}
339-
fi
340-
NEW_WHEEL_PATH=${NEW_WHEEL_PATH/linux/manylinux1}
341-
if [[ ! "${WHEEL_PATH}" == "${NEW_WHEEL_PATH}" ]]; then
342-
mv "${WHEEL_PATH}" "${NEW_WHEEL_PATH}"
343-
WHEEL_PATH=${NEW_WHEEL_PATH}
254+
LD_LIBRARY_PATH="${WORKSPACE}/targets/lib" auditwheel repair ${WHEEL_PATH}
255+
256+
NEW_WHEEL_PATH=${WORKSPACE}/targets/${wheel_name}.whl
344257
fi
258+
259+
mv ${WHEEL_PATH} ${NEW_WHEEL_PATH}
260+
WHEEL_PATH=${NEW_WHEEL_PATH}
261+
345262

346263
if [[ -z $SKIP_SMOKE_TEST ]]; then
347264
# Install the wheel and do a smoke test

0 commit comments

Comments
 (0)