2525import java .util .HashSet ;
2626import java .util .List ;
2727import java .util .Map ;
28+ import java .util .Properties ;
2829import java .util .Set ;
2930import java .util .logging .Level ;
3031import java .util .regex .Pattern ;
@@ -102,11 +103,11 @@ public Plugin loadPlugin(File file, boolean ignoreSoftDependencies)
102103
103104 PluginDataFile data = null ;
104105
105- if (file .getName ().endsWith ("dir" )) {
106+ if (file .getName ().endsWith (". dir" ) || file . getName (). endsWith ( "_dir " )) {
106107 if (!file .isDirectory ())
107108 throw new InvalidPluginException (new Exception ("python directories cannot be normal files! try .py or .py.zip instead." ));
108109 data = new PluginPythonDirectory (file );
109- } else if (file .getName ().endsWith ("zip" ) || file .getName ().endsWith ("pyp" )) {
110+ } else if (file .getName ().endsWith (". zip" ) || file .getName ().endsWith (". pyp" )) {
110111 if (file .isDirectory ())
111112 throw new InvalidPluginException (new Exception ("python zips cannot be directories! try .py.dir instead." ));
112113 data = new PluginPythonZip (file );
@@ -124,9 +125,23 @@ public Plugin loadPlugin(File file, boolean ignoreSoftDependencies)
124125 }
125126 }
126127 }
128+
129+ private Properties setDefaultPythonPath (Properties props , String file_path ) {
130+ String pythonPathProp = props .getProperty ("python.path" );
131+ String new_value ;
132+ if (pythonPathProp ==null )
133+ {
134+ new_value = file_path ;
135+ } else {
136+ new_value = pythonPathProp +java .io .File .pathSeparator + file_path + java .io .File .pathSeparator ;
137+ }
138+ props .setProperty ("python.path" ,new_value );
139+ return props ;
140+ }
127141
128142 private Plugin loadPlugin (File file , boolean ignoreSoftDependencies , PluginDataFile data ) throws InvalidPluginException /*, InvalidDescriptionException, UnknownDependencyException*/ {
129- System .out .println ("[PPLoader] Loading Plugin " + file .getName ());
143+ Properties props ;
144+ System .out .println ("[PPLoader] Loading Plugin " + file .getName ());
130145 PythonPlugin result = null ;
131146 PluginDescriptionFile description = null ;
132147 try {
@@ -177,7 +192,11 @@ private Plugin loadPlugin(File file, boolean ignoreSoftDependencies, PluginDataF
177192 throw new UnknownDependencyException (pluginName );
178193 }
179194 }
195+ props = PySystemState .getBaseProperties ();
196+ props = setDefaultPythonPath (props , file .getAbsolutePath ());
197+
180198 PySystemState state = new PySystemState ();
199+ state .initialize (System .getProperties (), props , null );
181200 PyList pythonpath = state .path ;
182201 PyString filepath = new PyString (file .getAbsolutePath ());
183202 pythonpath .append (filepath );
@@ -352,11 +371,11 @@ public PluginDescriptionFile getPluginDescription(File file)
352371 InputStream stream = null ;
353372 PluginDataFile data = null ;
354373
355- if (file .getName ().endsWith ("dir" )) {
374+ if (file .getName ().endsWith (". dir" ) || file . getName (). endsWith ( "_dir " )) {
356375 if (!file .isDirectory ())
357376 throw new InvalidDescriptionException (new InvalidPluginException (new Exception ("python directories cannot be normal files! .pyp or .py.zip instead." )));
358377 data = new PluginPythonDirectory (file );
359- } else if (file .getName ().endsWith ("zip" ) || file .getName ().endsWith ("pyp" )) {
378+ } else if (file .getName ().endsWith (". zip" ) || file .getName ().endsWith (". pyp" )) {
360379 if (file .isDirectory ())
361380 throw new InvalidDescriptionException (new InvalidPluginException (new Exception ("python zips cannot be directories! try .py.dir instead." )));
362381 try {
0 commit comments