File tree Expand file tree Collapse file tree
Source/UnrealEnginePython/Private Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "pipDirectoryPath" :" "
3+ }
Original file line number Diff line number Diff line change 1+ import sys
2+ import unreal_engine as ue
3+ import json
4+ import upycmd as cmd
5+ from os import listdir
6+
7+ from upypip import pip
8+
9+ def checkPipDirectory ():
10+ #get our python scripts path
11+ configPath = cmd .PythonPluginScriptPath () + '/upyconfig.json'
12+ correctPipPath = cmd .PythonHomeScriptsPath ()
13+
14+ #let's test our pip directory path
15+ try :
16+ with open (configPath ) as data_file :
17+ configs = json .load (data_file )
18+
19+ #grab currently stored path
20+ storedPipPath = configs ['pipDirectoryPath' ]
21+
22+ print (storedPipPath )
23+ print (tempPath )
24+
25+ #compare paths
26+ if (storedPipPath != correctPipPath ):
27+ #if they don't match, remove the pip module and reinstall pip for this module
28+
29+ libPath = cmd .PythonHomePath () + '/Lib/site-packages'
30+ dirs = listdir (libPath )
31+ print (libPath )
32+ print (dirs )
33+
34+ tempPath = None
35+ for directory in dirs :
36+ if ('pip' in directory and
37+ directory .endswith ('.dist-info' )):
38+ tempPath = libPath + directory
39+
40+ print (tempPath )
41+ #rmdir Li
42+ except :
43+ e = sys .exc_info ()[0 ]
44+ ue .log ('upyconfig.json error: ' + str (e ))
45+
46+ #add any startup action you wish to perform in python
47+ def startup ():
48+ #check that our pip directory matches for pip.exe commands
49+ checkPipDirectory ()
Original file line number Diff line number Diff line change @@ -142,6 +142,11 @@ void FUnrealEnginePythonModule::StartupModule()
142142 // import upymodule_importer
143143 PyImport_ImportModule (" upymodule_importer" );
144144
145+ char const * startupCode =
146+ " import upystartup\n "
147+ " upystartup.startup()\n " ;
148+ PyRun_SimpleString (startupCode);
149+
145150 if (PyImport_ImportModule (" ue_site" )) {
146151 UE_LOG (LogPython, Log, TEXT (" ue_site Python module successfully imported" ));
147152 }
You can’t perform that action at this time.
0 commit comments