-
Notifications
You must be signed in to change notification settings - Fork 74
/
create_venv.sh
executable file
·50 lines (39 loc) · 1.39 KB
/
create_venv.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -eo pipefail
# Allow overriding Python command via environment variable
if [ -z "$PYTHON_CMD" ]; then
PYTHON_CMD="python3"
else
echo "Using user-specified Python: $PYTHON_CMD"
fi
# Verify Python command exists
if ! command -v $PYTHON_CMD &> /dev/null; then
echo "Python command not found: $PYTHON_CMD"
exit 1
fi
# Set Python environment directory
if [ -z "$PYTHON_ENV_DIR" ]; then
PYTHON_ENV_DIR=$(pwd)/python_env
fi
echo "Creating virtual env in: $PYTHON_ENV_DIR"
# Create and activate virtual environment
$PYTHON_CMD -m venv $PYTHON_ENV_DIR
source $PYTHON_ENV_DIR/bin/activate
echo "Forcefully using a version of pip that will work with our view of editable installs"
pip install --force-reinstall pip==21.2.4
echo "Setting up virtual env"
python3 -m pip config set global.extra-index-url https://download.pytorch.org/whl/cpu
python3 -m pip install setuptools wheel
echo "Installing dev dependencies"
python3 -m pip install -r $(pwd)/tt_metal/python_env/requirements-dev.txt
echo "Installing tt-metal"
pip install -e .
# Do not install hooks when this is a worktree
if [ $(git rev-parse --git-dir) = $(git rev-parse --git-common-dir) ] ; then
echo "Generating git hooks"
pre-commit install
pre-commit install --hook-type commit-msg
else
echo "In worktree: not generating git hooks"
fi
echo "If you want stubs, run ./scripts/build_scripts/create_stubs.sh"