OpenTimelineIO
OpenTimelineIO copied to clipboard
Python binding is broken: it ignores PYTHON_EXECUTABLE and installs into a wrong prefix
- When multiple puthon versions are installed
PYTHON_EXECUTABLEis used to set which python to use.
I set PYTHON_EXECUTABLE=/usr/local/bin/python3.8 but 3.10 is still used
- It installs python binding into the root directory / instead of the python site libs folder.
Hello, @yurivict . I imagine that you are trying to distribute OTIO in FreeBSD? I found https://github.com/freebsd/freebsd-ports/tree/main/multimedia/opentimelineio, but my FreeBSD knowledge is... non existent. But I'll try to answer your questions or help you as best as I can.
- When multiple puthon versions are installed PYTHON_EXECUTABLE is used to set which python to use. I set PYTHON_EXECUTABLE=/usr/local/bin/python3.8 but 3.10 is still used
You will need to set Python_EXECUTABLE, not PYTHON_EXECUTABLE. See https://github.com/PixarAnimationStudios/OpenTimelineIO/blob/main/setup.py#L88 as a reference.
But that makes me wonder how are you building OTIO right now? Aren't are you going through the setup.py?
- It installs python binding into the root directory / instead of the python site libs folder.
I'm lacking a little bit of details, here (regarding how you build), but I would guess that OTIO_PYTHON_INSTALL_DIR isn't set.
If you have some builds logs that you can share, I'll be more than happy to look at them to confirm what I just said applies to you. Any additional information you have will help us help you.
You will need to set Python_EXECUTABLE [...]
This works, thanks.
But that makes me wonder how are you building OTIO right now? Aren't are you going through the setup.py?
I use cmake with PYTHON=ON.
So this appears to be a bug that it doesn't install the python files when PYTHON=ON.
On the other hand, using setup.py is a more suitable way for FreeBSD ports because it installs the binding separately.
So this appears to be a bug that it doesn't install the python files when
PYTHON=ON.
OTIO doesn't know what is PYTHON. It knows about OTIO_PYTHON_INSTALL.
But yes I agree that if you can install OTIO using the setup.py, that is our preferred (and only officially supported) option to install the python bindings.
Though, just as a side note, it won't build the C++ libraries and install the C++ headers. It will simply build everything statically and create the python bindings. You can see that here: https://github.com/PixarAnimationStudios/OpenTimelineIO/blob/main/setup.py#L90-L91.
If you want to have the C++ libraries build as shared libraries and have the Python extension link against these, then you will have to invoke cmake manually. The variables Python_EXECUTABLE="path o interpreter", OTIO_PYTHON_INSTALL=ON, OTIO_SHARED_LIBS=ON, OTIO_CXX_INSTALL=ON and OTIO_PYTHON_INSTALL_DIR="path to site-packages" will need to be passed to CMake.
You could also probably patch the setup.py to set these variables with the values you want to use.
Sorry, I meant OTIO_PYTHON_INSTALL.
Some projects install python files with a cmake option, some others don't. This can be confusing for users. IMO both ways to install python files should work to avoid confusion in the future,
If you want to have the C++ libraries build as shared libraries and have the Python extension link against these, then you will have to invoke cmake manually.
Ideally setup.py should be able to link against shared libraries built and installed by the C++ project, but I guess you don't currently support it.
Is that the resolution, allowing setup.py to use an externally supplied set of OTIO libs, in addition to the present mechanism? That sounds fine to me.