pre_build_script.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. if [[ "$(uname)" == Darwin ]]; then
  3. # Uninstall Conflicting jpeg brew formulae
  4. jpeg_packages=$(brew list | grep jpeg)
  5. echo "Existing Jpeg-related Brew libraries"
  6. echo $jpeg_packages
  7. for pkg in $jpeg_packages; do
  8. brew uninstall --ignore-dependencies --force $pkg || true
  9. done
  10. conda install -yq wget
  11. fi
  12. if [[ "$(uname)" == Darwin || "$OSTYPE" == "msys" ]]; then
  13. # Install libpng from Anaconda (defaults)
  14. conda install libpng -yq
  15. conda install -yq ffmpeg=4.2 libjpeg-turbo -c pytorch
  16. # Copy binaries to be included in the wheel distribution
  17. if [[ "$OSTYPE" == "msys" ]]; then
  18. python_exec="$(which python)"
  19. bin_path=$(dirname $python_exec)
  20. cp "$bin_path/Library/bin/libjpeg.dll" torchvision
  21. fi
  22. else
  23. if [[ "$ARCH" == "aarch64" ]]; then
  24. conda install libpng -yq
  25. conda install -yq ffmpeg=4.2 libjpeg-turbo -c pytorch-nightly
  26. fi
  27. # Install native CentOS libJPEG, freetype and GnuTLS
  28. yum install -y libjpeg-turbo-devel freetype gnutls
  29. # Download all the dependencies required to compile image and video_reader
  30. # extensions
  31. mkdir -p ext_libraries
  32. pushd ext_libraries
  33. popd
  34. export PATH="$(pwd)/ext_libraries/bin:$PATH"
  35. pip install auditwheel
  36. # Point to custom libraries
  37. export LD_LIBRARY_PATH=$(pwd)/ext_libraries/lib:$LD_LIBRARY_PATH
  38. export TORCHVISION_INCLUDE=$(pwd)/ext_libraries/include
  39. export TORCHVISION_LIBRARY=$(pwd)/ext_libraries/lib
  40. fi
  41. pip install numpy pyyaml future ninja
  42. pip install --upgrade setuptools