@@ -63,7 +63,7 @@ private static string PythonDirectory
6363 {
6464 get
6565 {
66- if ( _appdir == null )
66+ if ( _appdir == null && Script != null )
6767 {
6868 using ( MD5 md5 = MD5 . Create ( ) )
6969 {
@@ -100,11 +100,7 @@ private static string PipUrl
100100 }
101101 }
102102
103- private static string ScriptDirectory = Path . Combine ( PythonDirectory , "module" ) ;
104- private static string PythonBinary = Path . Combine ( PythonDirectory , "python.exe" ) ;
105- private static string PythonWBinary = Path . Combine ( PythonDirectory , "pythonw.exe" ) ;
106- private static string PipBinary = Path . Combine ( PythonDirectory , "Scripts" , "pip.exe" ) ;
107- private static string PipTempScript = Path . Combine ( PythonDirectory , "get-pip.py" ) ;
103+
108104
109105 #endregion
110106
@@ -243,12 +239,24 @@ private static void UnzipFromBytes(byte[] zipData, string destination)
243239 private static void Main ( string [ ] args )
244240 {
245241 // Create temp directory if not exists
242+ if ( string . IsNullOrEmpty ( PythonDirectory ) )
243+ {
244+ Print . Error ( "Could not determine temporary directory." ) ;
245+ Environment . Exit ( 1 ) ;
246+ }
247+
248+ // Create directory
246249 if ( ! Directory . Exists ( PythonDirectory ) )
247250 {
248251 Print . Info ( "Creating directory: " + PythonDirectory ) ;
249252 Directory . CreateDirectory ( PythonDirectory ) ;
250253 }
251254
255+ string PythonBinary = Path . Combine ( PythonDirectory , "python.exe" ) ;
256+ string PythonWBinary = Path . Combine ( PythonDirectory , "pythonw.exe" ) ;
257+ string PipBinary = Path . Combine ( PythonDirectory , "Scripts" , "pip.exe" ) ;
258+ string PipTempScript = Path . Combine ( PythonDirectory , "get-pip.py" ) ;
259+
252260 // Python installer
253261 if ( ! File . Exists ( PythonBinary ) || ! File . Exists ( PythonWBinary ) )
254262 {
@@ -297,6 +305,7 @@ private static void Main(string[] args)
297305 }
298306
299307 // Extract script
308+ string ScriptDirectory = Path . Combine ( PythonDirectory , "module" ) ;
300309 if ( ! File . Exists ( Path . Combine ( ScriptDirectory , "__main__.py" ) ) )
301310 {
302311 UnzipFromBytes ( Script , ScriptDirectory ) ;
0 commit comments