dev_environment.py: detect Blender's bundled Python from disk - #9228
Open
theoryshaw wants to merge 1 commit into
Open
theoryshaw wants to merge 1 commit into
theoryshaw wants to merge 1 commit into
Conversation
The site-packages path was derived from a hardcoded Blender -> Python mapping, which has needed a manual edit on each Blender release that bumps the bundled interpreter (5.1 -> 3.13, then 5.2 falling through to 3.11) and would break again on 3.14. Glob extensions/.local/lib/python*/site-packages instead and take the highest version, sorting on the parsed version parts so python3.9 does not outrank python3.13. The old mapping stays as a fallback so the existing assert can still report a sensible path when nothing matches. Also print PACKAGE_PATH in the settings block - it was the one path the script asserts on but never showed, so the failure had no context. Closes IfcOpenShell#9227 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Closes #9227.
dev_environment.pyderived the site-packages path from a hardcoded Blender→Python mapping:That boundary has needed a manual edit on each Blender release that bumps the interpreter — 7e1843b for 5.1, then d30c250 after 5.2 fell through to 3.11 and the script aborted — and it will break again the moment Blender ships 3.14. Each time, the symptom is a new contributor unable to set up a dev environment, with an assertion that doesn't point at the cause.
The information is already on disk, so this reads it instead of predicting it: glob
extensions/.local/lib/python*/site-packagesand take the highest version. The old mapping stays as a fallback so the existing assert still reports a sensible path when nothing matches.Sorting is on the parsed version parts rather than the raw string — plain
sorted()putspython3.9abovepython3.13. Folder names that don't parse sort below the ones that do instead of raising, so an unexpected variant (e.g. a free-threadedpython3.13tbuild) can't take the script down.Also prints
PACKAGE_PATHin the "Script settings" block. It was the one path the script asserts on but never showed.Testing
Loaded the module with
inputstubbed and checked the resolved path against a real install:...\5.2\extensions\.local\lib\python3.13\site-packages...\4.5\extensions\.local\lib\python3.11\site-packagesSort key checked against a tree containing
python3.9,python3.13andpython3.13t: string sort pickspython3.9, the version-part key pickspython3.13.black --line-length 120reports no changes.Windows 10, Blender 5.2 and 4.5, Bonsai installed via offline installation (
extensions/user_default/bonsai). Not exercised on macOS or Linux, though the changed code is platform-independent — onlyBLENDER_PATH, set above it, differs per platform.🤖 Generated with Claude Code