Skip to content

Commit

Permalink
0.9.19
Browse files Browse the repository at this point in the history
  • Loading branch information
divideconcept authored Apr 30, 2024
1 parent 97e6660 commit 15630c9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
27 changes: 18 additions & 9 deletions torchstudio/pythoninstall.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ cd "$SCRIPTDIR"
cd ..

pythonpath="$(pwd)/python"
channel="pytorch"
cuda=""
packages=""
uninstall=""
while [ "$1" != "" ]; do
if [ $1 == "--path" ]; then
shift; pythonpath=$1
elif [ $1 == "--channel" ]; then
shift; channel=$1
elif [ $1 == "--cuda" ]; then
cuda="--cuda"
elif [ $1 == "--package" ]; then
Expand Down Expand Up @@ -100,7 +97,15 @@ fi
rm -f "$file"

PATH="$PATH;$pythonpath/bin"
"$pythonpath/bin/python" -u -B -X utf8 -m torchstudio.pythoninstall --channel $channel $cuda $packages

"$pythonpath/bin/conda" install -y python-graphviz -c conda-forge
if [ $? != 0 ]; then
echo "" 1>&2
echo "Error while installing python-graphviz" 1>&2
exit 1
fi

"$pythonpath/bin/python" -u -B -X utf8 -m torchstudio.pythoninstall $cuda $packages
if [ $? != 0 ]; then
echo "" 1>&2
echo "Error while installing packages" 1>&2
Expand All @@ -121,17 +126,13 @@ cd /D "%~dp0"
cd ..

set pythonpath=%cd%\python
set channel=pytorch
set cuda=
set packages=
set uninstall=
:args
if "%~1" == "--path" (
set pythonpath=%~2
shift
) else if "%~1" == "--channel" (
set channel=%~2
shift
) else if "%~1" == "--cuda" (
set cuda=--cuda
) else if "%~1" == "--package" (
Expand Down Expand Up @@ -194,7 +195,15 @@ if ERRORLEVEL 1 (
del %file% 2>nul

set PATH=%PATH%;%pythonpath%;%pythonpath%\Library\mingw-w64\bin;%pythonpath%\Library\bin;%pythonpath%\bin
"%pythonpath%\python" -u -B -X utf8 -m torchstudio.pythoninstall --channel %channel% %cuda% %packages%

call "%pythonpath%\condabin\conda" install -y python-graphviz -c conda-forge
if ERRORLEVEL 1 (
echo. 1>&2
echo Error while installing python-graphviz 1>&2
exit /B 1
)

"%pythonpath%\python" -u -B -X utf8 -m torchstudio.pythoninstall %cuda% %packages%
if ERRORLEVEL 1 (
echo. 1>&2
echo Error while installing packages 1>&2
Expand Down
13 changes: 1 addition & 12 deletions torchstudio/pythoninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,7 @@
exit()

if not args.package:
#first install python-graphviz as it only exist as a conda package, and conda is recommended before pip: https://www.anaconda.com/blog/using-pip-in-a-conda-environment
if importlib.util.find_spec("conda") is None:
print("Error: Conda is required to install the graphviz package.", file=sys.stderr)
exit()
else:
print("Downloading and installing the graphviz package...")
print("")
result = subprocess.run([sys.executable, "-m", "conda", "install", "-y", "python-graphviz", "-c", "conda-forge"])
if result.returncode != 0:
exit(result.returncode)
print("")

#NB: conda install are recommended before pip: https://www.anaconda.com/blog/using-pip-in-a-conda-environment
pip_install="torch torchvision torchaudio torchtext"
if (sys.platform.startswith('win') or sys.platform.startswith('linux')):
if args.cuda:
Expand Down

0 comments on commit 15630c9

Please sign in to comment.