Closed JasonWorks closed 3 years ago
For reference with regards to a possible solution, at OpenTimelineIO we've been wanting to accommodate builds in environments such as conda. We're investigating a pattern of auto-detecting based on a snip like this to help with diverse build environments:
find_package(Python REQUIRED COMPONENTS Interpreter Development)
set(OTIO_RESOLVED_PYTHON_INSTALL_DIR "${Python_SITEARCH}")
and some CMake options governing whether the python environment should be automatically detected via this snippet, or externally supplied.
When building with build_usd.py we explicitly use the python that you invoked build_usd.py with as the one you're building against. The script always did that for building against Maya's python, and when we added python3 build support we stuck with that pattern. So, by the time we're running cmake code in that case, we already know what python we're using.
That's why this check doesn't add anything. We already know there's a python interpreter being used, and we know we're building for that one.
The code is here: https://github.com/PixarAnimationStudios/USD/blob/release/build_scripts/build_usd.py#L2007
I think we could just remove the if on line 2007, remove the else, keep the 64 bit/py38 checks, and this would be equivalent to what its doing now. Jason, do you have a PR in the works? If not I can try that out and submit a PR if it works as expected.
I do not have a PR - in our docker image, we simply sed: sed -i 's#find_executable("python")#sys.executable#' USD/build_scripts/build_usd.py
But removing the check altogether works for me.
Filed as internal issue #USD-6519
I believe this was fixed with commit dd436cb in the 21.05 release. Closing this out.
In build_usd.py, find_executable("python") is used to make sure "python" is in the path. But as a company moving from python2 to python3, we are starting to be very specific about which python version is being executed and getting rid of any use of the link to python.
Now we can add the link when building usd, but I'm not sure it is needed given that build_usd.py is a python file that is being executed at the time. Additionally, elsewhere in build_usd.py, sys.executable is used for actual building of python code.
Filing this issue based on usd-interest post.