Skip to content

Commit

Permalink
chore: get run.sh to be POSIX Compliant (RVC-Project#1649)
Browse files Browse the repository at this point in the history
* Create CONTRIBUTING.md

* Update CONTRIBUTING.md

* Update CONTRIBUTING.md

* fix: get run.sh posix compliant

* Update venv.sh

* Delete CONTRIBUTING.md

---------

Co-authored-by: 源文雨 <[email protected]>
  • Loading branch information
sonphantrung and fumiama authored Dec 26, 2023
1 parent 5449f84 commit 8bd34d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 10 additions & 10 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
#!/bin/bash
#!/bin/sh

if [[ "$(uname)" == "Darwin" ]]; then
if [ "$(uname)" = "Darwin" ]; then
# macOS specific env:
export PYTORCH_ENABLE_MPS_FALLBACK=1
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0
elif [[ "$(uname)" != "Linux" ]]; then
elif [ "$(uname)" != "Linux" ]; then
echo "Unsupported operating system."
exit 1
fi

if [ -d ".venv" ]; then
echo "Activate venv..."
source .venv/bin/activate
. .venv/bin/activate
else
echo "Create venv..."
requirements_file="requirements.txt"

# Check if Python 3.8 is installed
if ! command -v python3 &> /dev/null; then
if ! command -v python3 >/dev/null 2>&1; then
echo "Python 3 not found. Attempting to install 3.8..."
if [[ "$(uname)" == "Darwin" ]] && command -v brew &> /dev/null; then
if [ "$(uname)" = "Darwin" ] && command -v brew >/dev/null 2>&1; then
brew install [email protected]
elif [[ "$(uname)" == "Linux" ]] && command -v apt-get &> /dev/null; then
elif [ "$(uname)" = "Linux" ] && command -v apt-get >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install python3.8
else
Expand All @@ -31,13 +31,13 @@ else
fi

python3 -m venv .venv
source .venv/bin/activate
. .venv/bin/activate

# Check if required packages are installed and install them if not
if [ -f "${requirements_file}" ]; then
installed_packages=$(python3 -m pip freeze)
while IFS= read -r package; do
[[ "${package}" =~ ^#.* ]] && continue
expr "${package}" : "^#.*" > /dev/null && continue
package_name=$(echo "${package}" | sed 's/[<>=!].*//')
if ! echo "${installed_packages}" | grep -q "${package_name}"; then
echo "${package_name} not found. Attempting to install..."
Expand All @@ -53,7 +53,7 @@ fi
# Download models
./tools/dlmodels.sh

if [[ $? -ne 0 ]]; then
if [ $? -ne 0 ]; then
exit 1
fi

Expand Down
2 changes: 2 additions & 0 deletions venv.sh
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#!/bin/sh

python3.8 -m venv .venv

0 comments on commit 8bd34d1

Please sign in to comment.