Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

"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

Closed
idanmiara wants to merge 1 commit into pyscripter:master from talos-gis:master

Conversation

@idanmiara
Copy link
Contributor

@idanmiara idanmiara commented Oct 14, 2018

...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.

...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).
Copy link
Owner

"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.

Copy link
Contributor Author

idanmiara commented Oct 15, 2018 via email
edited
Loading

Hi, Thanks for your detailed reply. QGIS \ OSGeo4W use Python27+Python36 in the same folder as follows: OSGeo4W\bin\ - Python27.dll + Python36.dll + other binaries of different apps OSGeo4W\apps\Python27\ - python27 library OSGeo4W\apps\Python36\ - python36 library That's why I have to use SetPythonHome (for the library path) and also I need to specify the Python dll version. Do you prefer the solution of a modified PythonVersionFromPath over the solution of adding a Property PreferLatestSupportedVersion (default=false to keep backwards compatibility) that would iterate downwards instead of upwards the supported versions? Adding such property could effect the for loop in both functions PythonVersionFromPath and TPythonEngine.DoOpenDll. I could Define PYTHON30 to drop support of Python2 to workaround that problem, but I think solving the issue would be better. Also, please explain the use of PYTHON_KNOWN_VERSIONS[i].CanUseLatest. I see it's true for all versions, thus have no use. Is it just a remainder of an old feature?
...
On 2018年10月14日 at 23:52, pyscripter ***@***.***> wrote: "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. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#60 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AZIQrSNgmmijBZC3wGH97dwaNTlMyVNkks5uk6QOgaJpZM4XbOGp> .

Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /