@@ -171,7 +171,7 @@ def _do_init(self, master, appName, sparkHome, pyFiles, environment, batchSize,
171
171
172
172
SparkFiles ._sc = self
173
173
root_dir = SparkFiles .getRootDirectory ()
174
- sys .path .append ( root_dir )
174
+ sys .path .insert ( 1 , root_dir )
175
175
176
176
# Deploy any code dependencies specified in the constructor
177
177
self ._python_includes = list ()
@@ -183,10 +183,9 @@ def _do_init(self, master, appName, sparkHome, pyFiles, environment, batchSize,
183
183
for path in self ._conf .get ("spark.submit.pyFiles" , "" ).split ("," ):
184
184
if path != "" :
185
185
(dirname , filename ) = os .path .split (path )
186
- self ._python_includes .append (filename )
187
- sys .path .append (path )
188
- if dirname not in sys .path :
189
- sys .path .append (dirname )
186
+ if filename .lower ().endswith ("zip" ) or filename .lower ().endswith ("egg" ):
187
+ self ._python_includes .append (filename )
188
+ sys .path .insert (1 , os .path .join (SparkFiles .getRootDirectory (), filename ))
190
189
191
190
# Create a temporary directory inside spark.local.dir:
192
191
local_dir = self ._jvm .org .apache .spark .util .Utils .getLocalDir (self ._jsc .sc ().conf ())
@@ -667,7 +666,7 @@ def addPyFile(self, path):
667
666
if filename .endswith ('.zip' ) or filename .endswith ('.ZIP' ) or filename .endswith ('.egg' ):
668
667
self ._python_includes .append (filename )
669
668
# for tests in local mode
670
- sys .path .append ( os .path .join (SparkFiles .getRootDirectory (), filename ))
669
+ sys .path .insert ( 1 , os .path .join (SparkFiles .getRootDirectory (), filename ))
671
670
672
671
def setCheckpointDir (self , dirName ):
673
672
"""
0 commit comments