This repository has been archived by the owner on Oct 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making installation script more robust:
- Updated script SHEBANG to point to env instead of directly to bash. This allows end systems to start with the appropriate bash installation (in case a different version is installed to a different location) - Script creates virtual environment for python3, this mitigates the need to manually check for python3 and safely isolates the installation of packages from the system's packages - Changed the way the installer detects package managers. Prior way checked for a the presence of a folder and assumed the os, which then assumed the installation command. If we check for the installation command directly, we make fewer asumptions and have the flexibility to check for different package managers in a miriade of ways (some OSes can have different package managers. EG: osx can have homebrew or macports.) - Added shebangs to python scripts, they can utilize the appropriate python. When the venv python is activate, env will use it.
- Loading branch information
1 parent
157558b
commit bc02183
Showing
5 changed files
with
39 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ AI-Adventure-2bb65e3a4e2f.json | |
*.py[cod] | ||
data/text_adventures.txt | ||
venv/ | ||
.vscode/ | ||
generator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,46 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
set -e | ||
cd "$(dirname "${0}")" | ||
BASE_DIR="$(pwd)" | ||
|
||
declare -A OS_INFO; | ||
OS_INFO[/etc/debian_version]="apt-get install" | ||
OS_INFO[/etc/alpine-release]="apk --update add" | ||
OS_INFO[/etc/centos-release]="yum install" | ||
OS_INFO[/etc/fedora-release]="dnf install" | ||
OS_INFO[/etc/arch-release]="pacman -S" | ||
PYTHON_VER=$(python --version | sed -En "s/Python //p" | cut -c1-3) | ||
PACKAGES=(aria2 git unzip wget) | ||
|
||
pip_install () { | ||
if [ "$PYTHON_VER" != "3.6" ]; then | ||
echo "One of the packages 'Tensorflow 1.15' only supports Python 3.6.x" | ||
echo "Your default Python installation is $PYTHON_VER.x." | ||
echo "You'll need to install Python 3.6 manually and then do" | ||
echo "pip install -r ./requirements.txt" | ||
echo "If you have 3.6 installed, please enter the full path of pip3.6." | ||
echo "Leave blank to exit the installation." | ||
read PIP36 | ||
else | ||
PIP36=$(which pip) | ||
|
||
fi | ||
if [[ ! -z "$PIP36" ]]; then | ||
echo "Installing Python packages." | ||
sudo ${PIP36} install --upgrade pip setuptools | ||
sudo ${PIP36} install -r $BASE_DIR/requirements.txt | ||
if [ ! -d "./venv" ]; then | ||
python3 -m venv ./venv | ||
fi | ||
echo "Once everything is installed, play the game with 'python3.6 ./play.py'" | ||
exit | ||
source "${BASE_DIR}/venv/bin/activate" | ||
pip install --upgrade pip setuptools | ||
pip install -r "${BASE_DIR}/requirements.txt" | ||
} | ||
|
||
aid_install () { | ||
echo "Determining package manager." | ||
for f in ${!OS_INFO[@]} | ||
do | ||
if [[ -f $f ]]; then | ||
echo "Found $f." | ||
PACKAGE_MANAGER=${OS_INFO[$f]} | ||
fi | ||
done | ||
if [ -z "$PACKAGE_MANAGER" ]; then | ||
is_command() { | ||
command -v "${@}" > /dev/null | ||
} | ||
|
||
system_package_install() { | ||
PACKAGES=(aria2 git unzip wget) | ||
if is_command 'apt-get'; then | ||
sudo apt-get install ${PACKAGES[@]} | ||
elif is_command 'brew'; then | ||
brew install ${PACKAGES[@]} | ||
elif is_command 'yum'; then | ||
sudo yum install ${PACKAGES[@]} | ||
elif is_command 'dnf'; then | ||
sudo dnf install ${PACKAGES[@]} | ||
elif is_command 'packman'; then | ||
sudo packman -S ${PACKAGES[@]} | ||
elif is_command 'apk'; then | ||
sudo apk --update add ${PACKAGES[@]} | ||
else | ||
echo "You do not seem to be using a supported package manager." | ||
echo "Please make sure ${PACKAGES[@]} are installed then press [ENTER]" | ||
read NOT_USED | ||
else | ||
sudo ${PACKAGE_MANAGER} ${PACKAGES[@]} | ||
fi | ||
pip_install | ||
else | ||
echo "aria2c isn't available in PATH." | ||
echo "Exiting." | ||
exit | ||
fi | ||
} | ||
|
||
aid_install | ||
install_aid () { | ||
pip_install | ||
system_package_install | ||
} | ||
|
||
install_aid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
import sys | ||
import time | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
import sys | ||
import time | ||
|