diff --git a/.github/unittest.sh b/.github/unittest.sh index 0109a5cc2b1..0cfb138b444 100755 --- a/.github/unittest.sh +++ b/.github/unittest.sh @@ -7,6 +7,32 @@ CONDA_PATH=$(which conda) eval "$(${CONDA_PATH} shell.bash hook)" conda config --set channel_priority strict +# Setup the OS_TYPE environment variable that should be used for conditions involving the OS below. +case $(uname) in + Linux) + OS_TYPE=linux + ;; + Darwin) + OS_TYPE=macos + ;; + *) + echo "Unknown OS type:" $(uname) + exit 1 + ;; +esac + +echo '::group::Uninstall system JPEG libraries on macOS' +# The x86 macOS runners, e.g. the GitHub Actions native "macos-12" runner, has some JPEG libraries installed by default +# that interfere with our build. We uninstall them here and use the one from conda below. +if [[ "${OS_TYPE}" == "macos" && $(uname -m) == x86_64 ]]; then + JPEG_LIBS=$(brew list | grep jpeg) + echo $JPEG_LIBS + for lib in $JPEG_LIBS; do + brew uninstall --ignore-dependencies --force $lib || true + done +fi +echo '::endgroup::' + echo '::group::Set PyTorch conda channel and wheel index' # TODO: Can we maybe have this as environment variable in the job template? For example, `IS_RELEASE`. if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then diff --git a/.github/workflows/test-m1.yml b/.github/workflows/test-m1.yml deleted file mode 100644 index c03fa9f76e4..00000000000 --- a/.github/workflows/test-m1.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Unit-tests on M1 -on: - pull_request: - push: - branches: - - nightly - - main - - release/* - workflow_dispatch: -env: - CHANNEL: "nightly" -jobs: - tests: - name: "Unit-tests on M1" - runs-on: macos-m1-12 - strategy: - matrix: - py_vers: [ "3.8"] - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - name: Set Release CHANNEL (for release) - if: ${{ (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release')) || startsWith(github.ref, 'refs/heads/release') }} - run: | - echo "CHANNEL=test" >> "$GITHUB_ENV" - - name: Install TorchVision - shell: arch -arch arm64 bash {0} - env: - ENV_NAME: conda-env-${{ github.run_id }} - PY_VERS: ${{ matrix.py_vers }} - run: | - . ~/miniconda3/etc/profile.d/conda.sh - # Needed for JPEG library detection as setup.py detects conda presence by running `shutil.which('conda')` - export PATH=~/miniconda3/bin:$PATH - set -ex - conda create -yp ${ENV_NAME} python=${PY_VERS} numpy libpng jpeg scipy - conda run -p ${ENV_NAME} python3 -mpip install --pre torch --extra-index-url=https://download.pytorch.org/whl/${CHANNEL} - conda run -p ${ENV_NAME} python3 setup.py develop - conda run -p ${ENV_NAME} python3 -mpip install pytest pytest-mock 'av<10' - - name: Run tests - shell: arch -arch arm64 bash {0} - env: - ENV_NAME: conda-env-${{ github.run_id }} - PY_VERS: ${{ matrix.py_vers }} - run: | - . ~/miniconda3/etc/profile.d/conda.sh - set -ex - conda run -p ${ENV_NAME} --no-capture-output python3 -u -mpytest -v --tb=long --durations 20 - conda env remove -p ${ENV_NAME} diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml new file mode 100644 index 00000000000..ce4d8cb1fe3 --- /dev/null +++ b/.github/workflows/test-macos.yml @@ -0,0 +1,37 @@ +name: Unit-tests on macOS + +on: + pull_request: + push: + branches: + - nightly + - main + - release/* + workflow_dispatch: + +jobs: + tests: + strategy: + matrix: + python-version: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + runner: ["macos-12"] + include: + - python-version: "3.8" + runner: macos-m1-12 + fail-fast: false + uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + with: + repository: pytorch/vision + # We need an increased timeout here, since the macos-12 runner is the free one from GH + # and needs roughly 2 hours to just run the test suite + timeout: 240 + runner: ${{ matrix.runner }} + script: | + export PYTHON_VERSION=${{ matrix.python-version }} + export GPU_ARCH_TYPE=cpu + + ./.github/unittest.sh diff --git a/setup.py b/setup.py index 24b7a2edb94..059c4f424fa 100644 --- a/setup.py +++ b/setup.py @@ -298,6 +298,8 @@ def get_extensions(): use_jpeg = use_jpeg and jpeg_found if use_jpeg: print("Building torchvision with JPEG image support") + print(f" libpng include path: {jpeg_include}") + print(f" libpng lib path: {jpeg_lib}") image_link_flags.append("jpeg") if jpeg_conda: image_library += [jpeg_lib]