BF: detected installed packages in standalone app for py3.10#6771
Merged
peircej merged 1 commit intopsychopy:releasefrom Sep 6, 2024
Merged
BF: detected installed packages in standalone app for py3.10#6771peircej merged 1 commit intopsychopy:releasefrom
peircej merged 1 commit intopsychopy:releasefrom
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
@peircej I finally tracked down why does
pip installduring plugins manager ignore the existing package distributions under/Applications/PsychoPy.app/Contents/Resources/lib/python<major>.<minor>. This issue affects both py3.8 and py3.10 on macOS, but the Windows installations are fine because they organize the python distributions in a slightly different file structure.The root cause is due to the way distributions are packaged for the macOS builds. For python versions <3.11,
pipuses its internalpkg_resourcesbackend to find distributions onsys.path. Butpkg_resourcesdoesn't correctly resolve the distribution info inside zip files, yielding no detected distributions even though the correctsys.pathis present.This issue is pretty difficult to overcome for py3.8 because
pkg_resourcesexpects.disc-infofolders for distributions during resolution. And the alternativeimportlibbackend insidepiprequires anameattribute ofPathDistributionobjects that is only available after python 3.10.On py3.10, I dug up an undocumented environment variable
_PIP_USE_IMPORTLIB_METADATAto forceimportlibas the backend in order to find distributions onsys.path. Fortunately this works fine and prevents the PsychoPy plugins manager from installing potentially conflicting versions of other dependent packages (e.g.,numpy,pyserial, etc.) when installing plugin packages.In the long run though, the macOS builds might need to use a more
pip-compatible file structure for packages shipped with the PsychoPy app. Reading distribution info from the.zipfile will be dropped afterpip 24.3. Maybe both the package and.dist-infofolders can be put into~/Contents/Resources/lib/python<major>.<minor>(or using the~/Contents/Resources/lib/python<major>.<minor>/site-packagesconvention)? This way all versions ofpipon both py3.8 and py3.10 can resolve these existing distributions on macOS. The CPython files can still live inside the.zipfile.Here's an example output from Plugins & Packages GUI inside PsychoPy on py3.10 after this fix: