-
-
Couldn't load subscription status.
- Fork 324
"UseLastKnownVersion" suggests that if two versions are available in ... #60
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
...the same folder then the later one will be chosen. i.e. in case both Python27 and Python36 are available in the same folder (as in OSGeo4W, for instance).
"UseLastKnownVersion" (admittedly the name is confusing) works as follows:
- You use a conditional define such as {$DEFINE PYTHON26}
- TPythonEngine.DoOpenDll searches for a dll that is nearer to the defined version:
i.e.
if UseLastKnownVersion then
for i:= Integer(COMPILED_FOR_PYTHON_VERSION_INDEX) to High(PYTHON_KNOWN_VERSIONS) do
This property has been around since the very early days of P4D and it would break backward compatibility to change it.
If you want you program to work with Python 3.x compile with {$DEFINE PYTHON30}.
Having more than one python dlls in the same directory is uncommon and not recommended. Where would the python libraries be located then?
In any case. if you want the latest version in a particular directory then you have to manually (in your code) look for python dll's in a given directory and choose the one you want before loading the dll.
Pythonversion.pas contains a function PythonVersionFromPath that searches for dlls in a given path. However, this function stops a the first dll that it finds. You can create a similar function say LatestPythonVersionFromPath that works the way you want. If that function can be of general use (I am not convinced about this) I would consider merging it into PythonVersions.pas.
The QGIS way of separating out the python DLLs from the python library is untypical. It can be handled with a bit of extra work with the existing P4D as you are doing now, and I am inclined not to add extra properties or code to handle this automatically.
If you insist, I would suggest that you handle this from PythonVersions.pas side without changing Pythonengine.pas.
...the same folder then the later one will be chosen.
i.e. in case both Python27 and Python36 are available in the same folder (as in OSGeo4W, for instance).
The other option to load Python36 in that case would be to specify explicitly "DllName", which defetes the purpose of "last known version".
The "PythonVersions.GetLatestRegisteredPythonVersion(PythonVersion)" method won't help because the python version I require is not "registered" but loaded from a given path.