-
-
Couldn't load subscription status.
- Fork 324
TDynamicDLL improvements and other fixes #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I am not sure what it the problem you are trying to solve. From what I see you set the RegVersion from aDLLName in TPythonEngine.DoOpenDll(const aDllName : String) if UseLastKnownerion is False.
What is the use of that?
PyhthonEngine can be used to work with (a) a registered Python version and (b) a non registered Python version.
In (a) you need to set
- RegVersion, DLLName and optionally UseLastKnownVersion if a version newer than RegVersion will do.
In (b) you need to :
- Set DDLPath, RegVersion, DLLName and set UseLastKnownVersion to false.
- Call SetPythonHome to the appropriate path or set the %PYTHONHOME% environment variable.
Also the implementation GetPythonVersionFromDLLName is platform specific (Windows). In addition there is no need for it to be a member of PythonEngine. It could be a stand-alone function (possibly inside PythonVersions), or a class function.
...nVersionFromPath with an extra optional flag
cf8c49b to
2ccd4e4
Compare
I am considering including GetPythonVersionFromDLLName and possibly LatestPythonVersionFromPath but I still do not see the purpose of your other changes:
What is the use of changing DoOpenDLL? You say that
The problem I'm trying to solve is as follows:
UserInputDllName := '';
// allow user to input UserInputDllName if he wishes.
PyEngine.DllName := UserInputDllName;
PyEngine.UseLastKnownVersion := PyEngine.DllName='';
now I want to read PyEngine.RegVersion and I will get a wrong answer in
case the user specified the DLL name.
Why don't you call GetPythonVersionFromDLLName in your code i.e
if UserInputDLLName <> '' then
PythonEngine.RegVersion := GetPythonVersionFromDLLName(UserInputDLLName);
Also regarding LatestPythonVersionFromPath. This actually deals with a corner case and anyway enen after using this method you still have to call SetPythonHome with a different path than the DLLPath.
The simple solution for QGIS would be to copy the dll and python exe files to the python directory,
By the way a QGIS user of PyScripter suggested the following script for running QGIS with PyScripter (which uses P4D) after copying the dll and python.exe files.
call "%OSGEO4W_ROOT%\bin\o4w_env.bat"
call qt5_env.bat
call py3_env.bat
path %OSGEO4W_ROOT%\apps\qgis\bin;%PATH%
set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:\=/%/apps/qgis
set GDAL_FILENAME_IS_UTF8=YES
rem Set VSI cache to be used as buffer, see #6448
set VSI_CACHE=TRUE
set VSI_CACHE_SIZE=1000000
set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\qgis\qtplugins;%OSGEO4W_ROOT%\apps\qt5\plugins
set PYTHONPATH=%OSGEO4W_ROOT%\apps\qgis\python;%PYTHONPATH%
start "PyScripter" %~pd0\PyScripter.exe --PYTHON36 --pythondllpath=%OSGEO4W_ROOT%\apps\python36
...pas (without other modifications)
+ GetDllFileName = DllPath + DllName + CreateInstance, CreateInstanceAndLoad - creates an instance of the dll + MapDll (abstract virtual), CallMapDll - CallMapDll will be called in AfterLoad + LoadDll - now a function instead of procedure, returns validity. + DoOpenDll - use default dllname if empty string is passed; fix for loading dlls in subdirs (previous method would fail depending on its depended DLLs) + Import now accepts UnicodeStrings + Import2 for handling STDCall on 32bit + DllPath now writes via a function SetDllPath + DllFullFileName added a property that returns the full path of the dll PythonEngine.pas - TPythonInterface + AfterLoad - split functionality between TPythonInterface.MapDll and TDynamicDll.CallMapDll + GetDllPath - add the special behavior for the PythonDLL (IsPythonVersionRegistered) which has nothing to do in TDynamicDll + MapDll - added functionality from TPythonInterface.GetDllPath; Import now accepts UnicodeString and not AnsiString
Hi,
I've rebased my changes on your master.
I'm using your TDynamicDll as a base for other dlls that I use.
I pushed some additions and fixes.
Should I keep posting improvements to this library? If you are willing to accept contributions I will keep post them.
The scope of the PR is becoming too wide, including different changes for different purposes. I am closing this. You are welcome to submit different PRs with narrow scope and specific purpose.
No description provided.