Fix getProgramPath() to find Python module in virtual environment on Windows and Linux - #368
Open
lukashof wants to merge 3 commits into
Open
Fix getProgramPath() to find Python module in virtual environment on Windows and Linux#368lukashof wants to merge 3 commits into
getProgramPath() to find Python module in virtual environment on Windows and Linux#368lukashof wants to merge 3 commits into
Conversation
lukashof
force-pushed
the
fix_py_module_path
branch
from
December 2, 2025 16:46
7dd9050 to
577521a
Compare
lukashof
force-pushed
the
fix_py_module_path
branch
from
December 16, 2025 09:38
577521a to
17924a6
Compare
lukashof
force-pushed
the
fix_py_module_path
branch
from
August 24, 2026 18:46
17924a6 to
8e8a060
Compare
Contributor
Author
|
I was never happy with the solution I proposed. I just rebased it to the latest version. In doing so, I found that I couldn't compile via the setup.py anymore because pybind wouldn't find my Python installation in a non-standard directory on Windows. I've added a commit to address this. I've also reworked the original solution to the program not finding the module correctly. It now identifies whether it runs in Python from a mismatch between the executable and module. The correct directory is also found by looking for the data and resources folders. So far, I only tested the Windows version with venv. I'll test on Linux too. Unfortunately, I don't have access to a Mac. I can only trust my LLM of choice for that bit. |
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.
There are various instances where data like scene or geometry files is loaded and
getProgramPath()is used to find the right folder. However, when using the Python bindings from a virtual environment using the built-in venv-Module this won't work, since the method returns the path to the global Python interpreter. The only (very crude) workaround I have previously found was to place the relevant data in the global interpreter, which is not ideal and requires admin-privileges.This PR contains a modification to find the correct Path of the venv, if the python bindings are used. I realize the implementation is a bit simplistic and depends on the found executable's name, and might therefore not cover all available Python distributions.
I made no changes to the Apple implementation, since I don't have a machine available to test this on.
I have previously discussed this with @digitalillusions in #283, where he mentioned that the issue does not occur with Anaconda. I tested my solution with Anaconda on Windows as well and had no issues.
This might solve the problems from discussion #151 and #254, although the latter one was already closed.
Looking forward to any feedback!