From b04694b99edc954afc4a3d75af0912994e8828aa Mon Sep 17 00:00:00 2001
From: Nikita Shulga <nshulga@meta.com>
Date: Tue, 29 Nov 2022 15:34:46 -0800
Subject: [PATCH] Delete unmaintaned torchvision build scripts

All build logic has long moved to torchvision repo and now is executed
by reusable workflow from https://github.com/pytorch/test-infra/tree/main/.github/workflows
---
 conda/build_vision.sh                     | 94 -----------------------
 conda/torchvision/bld.bat                 | 24 ------
 conda/torchvision/conda_build_config.yaml | 24 ------
 conda/torchvision/meta.yaml               | 53 -------------
 4 files changed, 195 deletions(-)
 delete mode 100755 conda/build_vision.sh
 delete mode 100644 conda/torchvision/bld.bat
 delete mode 100644 conda/torchvision/conda_build_config.yaml
 delete mode 100644 conda/torchvision/meta.yaml

diff --git a/conda/build_vision.sh b/conda/build_vision.sh
deleted file mode 100755
index 3061e4740..000000000
--- a/conda/build_vision.sh
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/usr/bin/env bash
-if [[ -x "/remote/anaconda_token" ]]; then
-    . /remote/anaconda_token || true
-fi
-
-set -ex
-
-# Function to retry functions that sometimes timeout or have flaky failures
-retry () {
-    $*  || (sleep 1 && $*) || (sleep 2 && $*) || (sleep 4 && $*) || (sleep 8 && $*)
-}
-
-if [ "$#" -ne 1 ]; then
-    echo "Illegal number of parameters. Pass cuda version"
-    echo "CUDA version should be M.m with no dot, e.g. '8.0' or 'cpu'"
-    exit 1
-fi
-desired_cuda="$1"
-
-export TORCHVISION_BUILD_VERSION="0.3.0"
-export TORCHVISION_BUILD_NUMBER=1
-
-SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
-
-if [[ -z "$WIN_PACKAGE_WORK_DIR" ]]; then
-    WIN_PACKAGE_WORK_DIR="$(echo $(pwd -W) | tr '/' '\\')\\tmp_conda_$(date +%H%M%S)"
-fi
-
-if [[ "$OSTYPE" == "msys" ]]; then
-    mkdir -p "$WIN_PACKAGE_WORK_DIR" || true
-    vision_rootdir="$(realpath ${WIN_PACKAGE_WORK_DIR})/torchvision-src"
-    git config --system core.longpaths true
-else
-    vision_rootdir="$(pwd)/torchvision-src"
-fi
-
-if [[ ! -d "$vision_rootdir" ]]; then
-    rm -rf "$vision_rootdir"
-    git clone "https://github.com/pytorch/vision" "$vision_rootdir"
-    pushd "$vision_rootdir"
-    git checkout v$TORCHVISION_BUILD_VERSION
-    popd
-fi
-
-cd "$SOURCE_DIR"
-
-if [[ "$OSTYPE" == "msys" ]]; then
-    export tmp_conda="${WIN_PACKAGE_WORK_DIR}\\conda"
-    export miniconda_exe="${WIN_PACKAGE_WORK_DIR}\\miniconda.exe"
-    rm -rf "$tmp_conda"
-    rm -f "$miniconda_exe"
-    curl -sSk https://repo.continuum.io/miniconda/Miniconda3-latest-Windows-x86_64.exe -o "$miniconda_exe"
-    "$SOURCE_DIR/install_conda.bat" && rm "$miniconda_exe"
-    pushd $tmp_conda
-    export PATH="$(pwd):$(pwd)/Library/usr/bin:$(pwd)/Library/bin:$(pwd)/Scripts:$(pwd)/bin:$PATH"
-    popd
-    # We have to skip 3.17 because of the following bug.
-    # https://github.com/conda/conda-build/issues/3285
-    retry conda install -yq conda-build
-fi
-
-ANACONDA_USER=pytorch
-conda config --set anaconda_upload no
-
-
-export TORCHVISION_PACKAGE_SUFFIX=""
-if [[ "$desired_cuda" == 'cpu' ]]; then
-    export CONDA_CUDATOOLKIT_CONSTRAINT=""
-    export CUDA_VERSION="None"
-    if [[ "$OSTYPE" != "darwin"* ]]; then
-        export TORCHVISION_PACKAGE_SUFFIX="-cpu"
-    fi
-else
-    . ./switch_cuda_version.sh $desired_cuda
-    if [[ "$desired_cuda" == "10.0" ]]; then
-	export CONDA_CUDATOOLKIT_CONSTRAINT="    - cudatoolkit >=10.0,<10.1 # [not osx]"
-    elif [[ "$desired_cuda" == "9.0" ]]; then
-	export CONDA_CUDATOOLKIT_CONSTRAINT="    - cudatoolkit >=9.0,<9.1 # [not osx]"
-    else
-	echo "unhandled desired_cuda: $desired_cuda"
-	exit 1
-    fi
-fi
-
-if [[ "$OSTYPE" == "msys" ]]; then
-    time conda build -c $ANACONDA_USER --no-anaconda-upload vs2017
-else
-    time conda build -c $ANACONDA_USER --no-anaconda-upload --python 2.7 torchvision
-fi
-time conda build -c $ANACONDA_USER --no-anaconda-upload --python 3.5 torchvision
-time conda build -c $ANACONDA_USER --no-anaconda-upload --python 3.6 torchvision
-time conda build -c $ANACONDA_USER --no-anaconda-upload --python 3.7 torchvision
-
-set +e
diff --git a/conda/torchvision/bld.bat b/conda/torchvision/bld.bat
deleted file mode 100644
index 14f6935fb..000000000
--- a/conda/torchvision/bld.bat
+++ /dev/null
@@ -1,24 +0,0 @@
-@echo on
-
-set TORCHVISION_BUILD_VERSION=%PKG_VERSION%
-set TORCHVISION_BUILD_NUMBER=%PKG_BUILDNUM%
-
-if not "%CUDA_VERSION%" == "None" (
-    set build_with_cuda=1
-    set desired_cuda=%CUDA_VERSION:~0,-1%.%CUDA_VERSION:~-1,1%
-) else (
-    set build_with_cuda=
-)
-
-if "%build_with_cuda%" == "" goto cuda_flags_end
-
-set CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v%desired_cuda%
-set CUDA_BIN_PATH=%CUDA_PATH%\bin
-set NVCC_FLAGS=-D__CUDA_NO_HALF_OPERATORS__ --expt-relaxed-constexpr
-if "%desired_cuda%" == "9.0" set NVCC_FLAGS=%NVCC_FLAGS% -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_50,code=compute_50
-if "%desired_cuda%" == "10.0" set NVCC_FLAGS=%NVCC_FLAGS% -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_50,code=compute_50
-
-:cuda_flags_end
-
-python setup.py install --single-version-externally-managed --record=record.txt
-if errorlevel 1 exit /b 1
diff --git a/conda/torchvision/conda_build_config.yaml b/conda/torchvision/conda_build_config.yaml
deleted file mode 100644
index 5188bb0eb..000000000
--- a/conda/torchvision/conda_build_config.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-blas_impl:
-  - mkl                        # [x86_64]
-c_compiler:
-  - vs2017                     # [win]
-cxx_compiler:
-  - vs2017                     # [win]
-python:
-  - 3.5
-  - 3.6
-# This differs from target_platform in that it determines what subdir the compiler
-#    will target, not what subdir the compiler package will be itself.
-#    For example, we need a win-64 vs2008_win-32 package, so that we compile win-32
-#    code on win-64 miniconda.
-cross_compiler_target_platform:
-  - win-64                     # [win]
-target_platform:
-  - win-64                     # [win]
-vc:
-  - 14
-zip_keys:
-  -                             # [win]
-    - vc                        # [win]
-    - c_compiler                # [win]
-    - cxx_compiler              # [win]
diff --git a/conda/torchvision/meta.yaml b/conda/torchvision/meta.yaml
deleted file mode 100644
index caa439c7d..000000000
--- a/conda/torchvision/meta.yaml
+++ /dev/null
@@ -1,53 +0,0 @@
-package:
-  name: torchvision{{ environ.get('TORCHVISION_PACKAGE_SUFFIX') }}
-  version: "{{ environ.get('TORCHVISION_BUILD_VERSION') }}"
-
-source:
- git_rev: v{{ environ.get('TORCHVISION_BUILD_VERSION') }}
- git_url: https://github.com/pytorch/vision.git
-   
-
-requirements:
-  build:
-    - {{ compiler('c') }} # [win]
-
-  host:
-    - python
-    - setuptools
-    - pytorch{{ environ.get('TORCHVISION_PACKAGE_SUFFIX') }} >=1.1.0
-{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}
-
-  run:
-    - python
-    - pillow >=4.1.1
-    - numpy >=1.11
-    - pytorch{{ environ.get('TORCHVISION_PACKAGE_SUFFIX') }} >=1.1.0
-    - six
-{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}
-
-build:
-  number: {{ environ.get('TORCHVISION_BUILD_NUMBER') }}
-  string: py{{py}}_cu{{ environ['CUDA_VERSION'] }}_{{environ.get('TORCHVISION_BUILD_NUMBER')}}
-  script: python setup.py install --single-version-externally-managed --record=record.txt # [not win]
-  script_env:
-    - CUDA_VERSION
-
-test:
-  imports:
-    - torchvision
-    - torchvision.datasets
-    - torchvision.transforms
-  source_files:
-    - test
-  requires:
-    - pytest
-    - scipy
-  commands:
-    pytest .
-
-
-about:
-  home: https://github.com/pytorch/vision
-  license: BSD
-  license_file: LICENSE
-  summary: 'image and video datasets and models for torch deep learning'