Skip to content

Commit 01066fa

Browse files
committed
bin/pyspark for Windows
This is tested on Windows 7. The only thing that does not work is having perverse app names with escaped quotes (e.g. "foo \" jam"). App names with spaces are fine. Other than that, the behavior on Windows is the same on OSX.
1 parent c8cb3bf commit 01066fa

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

bin/pyspark2.cmd

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ set FOUND_JAR=0
3131
for %%d in ("%FWDIR%assembly\target\scala-%SCALA_VERSION%\spark-assembly*hadoop*.jar") do (
3232
set FOUND_JAR=1
3333
)
34-
if "%FOUND_JAR%"=="0" (
34+
if [%FOUND_JAR%] == [0] (
3535
echo Failed to find Spark assembly JAR.
3636
echo You need to build Spark with sbt\sbt assembly before running this program.
3737
goto exit
@@ -42,15 +42,30 @@ rem Load environment variables from conf\spark-env.cmd, if it exists
4242
if exist "%FWDIR%conf\spark-env.cmd" call "%FWDIR%conf\spark-env.cmd"
4343

4444
rem Figure out which Python to use.
45-
if "x%PYSPARK_PYTHON%"=="x" set PYSPARK_PYTHON=python
45+
if [%PYSPARK_PYTHON%] == [] set PYSPARK_PYTHON=python
4646

4747
set PYTHONPATH=%FWDIR%python;%PYTHONPATH%
4848
set PYTHONPATH=%FWDIR%python\lib\py4j-0.8.1-src.zip;%PYTHONPATH%
4949

5050
set OLD_PYTHONSTARTUP=%PYTHONSTARTUP%
5151
set PYTHONSTARTUP=%FWDIR%python\pyspark\shell.py
52+
set PYSPARK_SUBMIT_ARGS=%*
5253

5354
echo Running %PYSPARK_PYTHON% with PYTHONPATH=%PYTHONPATH%
5455

55-
"%PYSPARK_PYTHON%" %*
56+
rem Check whether the argument is a file
57+
for /f %%i in ('echo %1^| findstr /R "\.py"') do (
58+
set PYTHON_FILE=%%i
59+
)
60+
61+
if [%PYTHON_FILE%] == [] (
62+
%PYSPARK_PYTHON%
63+
) else (
64+
echo.
65+
echo WARNING: Running python applications through ./bin/pyspark.cmd is deprecated as of Spark 1.0.
66+
echo Use ./bin/spark-submit ^<python file^>
67+
echo.
68+
"%FWDIR%\bin\spark-submit.cmd" %PYSPARK_SUBMIT_ARGS%
69+
)
70+
5671
:exit

0 commit comments

Comments
 (0)