|
2 | 2 |
|
3 | 3 | RED="\e[31m" |
4 | 4 | GREEN="\e[32m" |
| 5 | +BLUE="\e[34m" |
| 6 | +YELLOW="\e[33m" |
5 | 7 | ENDCOLOR="\e[0m" |
6 | 8 |
|
7 | | -echo -e "\n${GREEN}> Configure environment.${ENDCOLOR}\n" |
| 9 | +echo -e "\n${BLUE}################################" |
| 10 | +echo -e "${BLUE}#### INSTALL.SH ####${ENDCOLOR}" |
| 11 | +echo -e "${BLUE}################################" |
| 12 | + |
| 13 | +echo -e "\n${GREEN}> Configure virtual environment.${ENDCOLOR}\n" |
8 | 14 |
|
9 | 15 | sudo chgrp vscode /workspaces/app/.venv |
10 | 16 | sudo chown vscode /workspaces/app/.venv |
11 | 17 |
|
12 | 18 | git config --global --add safe.directory /workspaces/app |
13 | | -git config core.eol lf |
14 | | -git config core.autocrlf false |
| 19 | +git config --global core.eol lf |
| 20 | +git config --global core.autocrlf false |
15 | 21 |
|
16 | 22 | python3 -m venv /workspaces/app/.venv |
17 | 23 | PATH="/workspaces/app/.venv/bin:$PATH" |
18 | 24 |
|
19 | 25 | echo -e "Done.\n" |
20 | 26 |
|
21 | | -echo -e "${GREEN}> Update pip tool and install dependencies.${ENDCOLOR}\n" |
| 27 | +echo -e "${GREEN}> Identify the packaging and dependency manager to install.${ENDCOLOR}\n" |
| 28 | + |
| 29 | +PIP_MANAGER=false |
| 30 | +POETRY_MANAGER=false |
| 31 | + |
| 32 | +NEW_POETRY_INSTALL=false |
| 33 | + |
| 34 | +FILE=/workspaces/app/requirements.txt |
| 35 | + |
| 36 | +if [ -f "$FILE" ]; |
| 37 | +then |
| 38 | + echo -e "PIP configuration file was found (requirements.txt).\n" |
| 39 | + PIP_MANAGER=true |
| 40 | +fi |
| 41 | + |
| 42 | +FILE=/workspaces/app/pyproject.toml |
| 43 | + |
| 44 | +if [ -f "$FILE" ]; |
| 45 | +then |
| 46 | + echo -e "POETRY configuration file was found (pyproject.toml).${ENDCOLOR}" |
| 47 | + POETRY_MANAGER=true |
| 48 | +fi |
| 49 | + |
| 50 | +if [ "$POETRY_MANAGER" = true ] && [ "$PIP_MANAGER" = true ]; |
| 51 | +then |
| 52 | + echo -e "${RED}> ERROR: You cannot define two packaging and dependency manager in the same time.${ENDCOLOR}\n" |
| 53 | + exit 1 |
| 54 | +fi |
| 55 | + |
| 56 | +if [ "$POETRY_MANAGER" = false ] && [ "$PIP_MANAGER" = false ]; |
| 57 | +then |
| 58 | + |
| 59 | + echo -e "${YELLOW}No packaging and dependency manager was found.${ENDCOLOR}" |
| 60 | + echo -e "${YELLOW}Type 'PIP' or 'POETRY' if you want to install a packaging and dependency manager !${ENDCOLOR}" |
| 61 | + echo -e "${YELLOW}Another option will install no packaging and dependency manager.${ENDCOLOR}" |
| 62 | + echo -e "${YELLOW}Your selection :${ENDCOLOR}" |
| 63 | + |
| 64 | + read MANAGER |
| 65 | + echo -e "The following packaging and dependency manager will be installed : $MANAGER\n" |
| 66 | + |
| 67 | + if [ "${MANAGER^^}" = "POETRY" ] |
| 68 | + then |
| 69 | + POETRY_MANAGER=true |
| 70 | + NEW_POETRY_INSTALL=true |
| 71 | + fi |
| 72 | + |
| 73 | + if [ "${MANAGER^^}" = "PIP" ] |
| 74 | + then |
| 75 | + PIP_MANAGER=true |
| 76 | + touch /workspaces/app/requirements.txt |
| 77 | + touch /workspaces/app/requirements-dev.txt |
| 78 | + fi |
| 79 | + |
| 80 | +fi |
22 | 81 |
|
23 | 82 | source /workspaces/app/.venv/bin/activate |
24 | | -pip install --upgrade pip |
25 | 83 |
|
26 | | -# pip install keyring artifacts-keyring |
| 84 | +if [ "$PIP_MANAGER" = true ]; |
| 85 | +then |
| 86 | + |
| 87 | + echo -e "${GREEN}> Update PIP tool and install dependencies.${ENDCOLOR}\n" |
| 88 | + |
| 89 | + pip install --upgrade pip |
| 90 | + |
| 91 | + # pip install keyring artifacts-keyring |
| 92 | + |
| 93 | + # cat <<EOF >> /workspaces/app/.venv/pip.conf |
| 94 | + # [global] |
| 95 | + # extra-index-url=https://pkgs.dev.azure.com/... |
| 96 | + # EOF |
| 97 | + |
| 98 | + pip install -r /workspaces/app/requirements-dev.txt |
| 99 | + pip install -r /workspaces/app/requirements.txt |
| 100 | + |
| 101 | +fi |
| 102 | + |
| 103 | +if [ "$POETRY_MANAGER" = true ]; |
| 104 | +then |
| 105 | + |
| 106 | + echo -e "${GREEN}> Install POETRY tool and install dependencies.${ENDCOLOR}\n" |
| 107 | + curl -sSL https://install.python-poetry.org | python3 - |
| 108 | + poetry completions bash >> ~/.bash_completion |
| 109 | + |
| 110 | + if [ "$POETRY_MANAGER" = true ]; |
| 111 | + then |
| 112 | + poetry init |
| 113 | + fi |
27 | 114 |
|
28 | | -# cat <<EOF >> /workspaces/app/.venv/pip.conf |
29 | | -# [global] |
30 | | -# extra-index-url=https://pkgs.dev.azure.com/... |
31 | | -# EOF |
| 115 | + poetry install |
32 | 116 |
|
33 | | -pip install -r /workspaces/app/requirements-dev.txt |
34 | | -pip install -r /workspaces/app/requirements.txt |
| 117 | +fi |
35 | 118 |
|
36 | 119 | /workspaces/app/.devcontainer/check-post-install.sh |
0 commit comments