Generalise pyinstaller spec paths #2281
Merged
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 pyinstaller spec file sometimes needs to contain workarounds for packages to help pyinstaller find all the relevant imports or data files. If such introspection is still needed, we should avoid baking in platform-dependent and python-version-dependent paths.
This PR makes use of the
sysconfig
module from the Python stdlib that has information about where packages are located, so the details oflib
vsLib
,site-packages
vsdist-packages
,python3.8
vspython3.10
,… all go away. This last one is very important as it means we can create installer artifacts with multiple different Python versions for testing purposes, without needing to change the spec file.I tested an earlier version of this patch with Windows and Linux when it was still touching paths for those installers. With other changes, this code path is currently only used on macos which I can't test.
There's every chance that the actual code for
jedi
andzmq
for Darwin can also be removed; that's a problem for a different PR and for a mac user to test. In any case, the stub of loading and usingsysconfig
may as well stay for the time being since it will be needed some time in the future, no doubt.