|
| 1 | +#!/bin/bash |
| 2 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | +# All rights reserved. |
| 4 | +# |
| 5 | +# This source code is licensed under the BSD-style license found in the |
| 6 | +# LICENSE file in the root directory of this source tree. |
| 7 | + |
| 8 | +# Install required python dependencies for developing |
| 9 | +# Dependencies are defined in .pyproject.toml |
| 10 | +if [[ -z $PYTHON_EXECUTABLE ]]; |
| 11 | +then |
| 12 | + if [[ -z $CONDA_DEFAULT_ENV ]] || [[ $CONDA_DEFAULT_ENV == "base" ]] || [[ ! -x "$(command -v python)" ]]; |
| 13 | + then |
| 14 | + PYTHON_EXECUTABLE=python3 |
| 15 | + else |
| 16 | + PYTHON_EXECUTABLE=python |
| 17 | + fi |
| 18 | +fi |
| 19 | + |
| 20 | +if [[ "$PYTHON_EXECUTABLE" == "python" ]]; |
| 21 | +then |
| 22 | + PIP_EXECUTABLE=pip |
| 23 | +else |
| 24 | + PIP_EXECUTABLE=pip3 |
| 25 | +fi |
| 26 | + |
| 27 | +# |
| 28 | +# First install requirements in requirements.txt. Older torch may be |
| 29 | +# installed from the dependency of other models. It will be overridden by |
| 30 | +# newer version of torch nightly installed later in this script. |
| 31 | +# |
| 32 | + |
| 33 | +$PIP_EXECUTABLE install -r requirements.txt |
| 34 | + |
| 35 | +# Since torchchat often uses main-branch features of pytorch, only the nightly |
| 36 | +# pip versions will have the required features. The NIGHTLY_VERSION value should |
| 37 | +# agree with the third-party/pytorch pinned submodule commit. |
| 38 | +# |
| 39 | +# NOTE: If a newly-fetched version of the executorch repo changes the value of |
| 40 | +# NIGHTLY_VERSION, you should re-run this script to install the necessary |
| 41 | +# package versions. |
| 42 | +NIGHTLY_VERSION=dev20240415 |
| 43 | + |
| 44 | +# The pip repository that hosts nightly torch packages. |
| 45 | +TORCH_NIGHTLY_URL="https://download.pytorch.org/whl/nightly/cpu" |
| 46 | + |
| 47 | +# pip packages needed by exir. |
| 48 | +REQUIREMENTS_TO_INSTALL=( |
| 49 | + torch=="2.4.0.${NIGHTLY_VERSION}" |
| 50 | +) |
| 51 | + |
| 52 | +# Install the requirements. `--extra-index-url` tells pip to look for package |
| 53 | +# versions on the provided URL if they aren't available on the default URL. |
| 54 | +$PIP_EXECUTABLE install --extra-index-url "${TORCH_NIGHTLY_URL}" \ |
| 55 | + "${REQUIREMENTS_TO_INSTALL[@]}" |
0 commit comments