build_wheels.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. #
  3. # Convenience script to build wheel files in Docker, and copy them out of the
  4. # container.
  5. #
  6. # Usage: docker-devel/build_wheels.sh (takes no arguments; run it from the base
  7. # directory).
  8. set -e
  9. docker build -t dragnn-oss .
  10. # Start building the wheels.
  11. script="bazel run //dragnn/tools:build_pip_package \
  12. -- --output-dir=/opt/tensorflow/syntaxnet; \
  13. bazel run //dragnn/tools:build_pip_package \
  14. -- --output-dir=/opt/tensorflow/syntaxnet --include-tensorflow"
  15. container_id="$(docker run -d dragnn-oss /bin/bash -c "${script}")"
  16. echo "Waiting for container ${container_id} to finish building the wheel ..."
  17. if [[ "$(docker wait "${container_id}")" != 0 ]]; then
  18. echo "Container failed! Please run \`docker logs <id>\` to see errors." >&2
  19. exit 1
  20. fi
  21. # The build_pip_package.py script prints lines like "Wrote x.whl". The wheel
  22. # names are prefixed by architecture and such, so don't guess them.
  23. wheels=(
  24. $(docker logs "${container_id}" 2>/dev/null | grep Wrote | awk '{print $2;}'))
  25. for wheel in "${wheels[@]}"; do
  26. output=./"$(basename "${wheel}")"
  27. docker cp "${container_id}:${wheel}" "${output}"
  28. echo "Wrote ${output} ($(du -h "${output}" | awk '{print $1;}'))"
  29. done
  30. echo "Removing ${container_id} ..."
  31. docker rm "${container_id}" >/dev/null