You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The psutil package uses a C extension and therefore cannot be loaded from inside a zip[1]. pylink uses only a single function from psutil which can be easily replaced. If the dependency on psutil is dropped, pylink can be imported from inside a zip.
I have tested on windows and checked that all tests pass with this patch applied.
Sorry for getting back to this so late. Is this code pulled form psutil? Do you know if a later psutil has addressed this issue? It looks like zipapp is a Python3-specific thing? I'd personally prefer not pulling out the code from another open-source package.
The code is not pulled from psutil. For posix compliant platforms it's straightforward to check if the pid is alive. For windows it is a bit more complicated, the implementation is similar to what is outlined here.
It is not a bug in psutil. It is a limitation of python which is unable to load native extensions (dynamic libraries) from a zip file.
zipapp uses Python3. It simplifies the process of packaging an application. The created .pyz package can run on Python2 and Python3. You can find some more details here
The key difference between this implementation and the one provided by psutil is that in this PR ctypes is used on Windows to make the library calls whereas psutil uses a C extension for performance reasons. This is not a concern for pylink as this is not a critical path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The psutil package uses a C extension and therefore cannot be loaded from inside a zip[1]. pylink uses only a single function from psutil which can be easily replaced. If the dependency on psutil is dropped, pylink can be imported from inside a zip.
I have tested on windows and checked that all tests pass with this patch applied.
[1] https://docs.python.org/3/library/zipapp.html#caveats