OpenTimelineIO icon indicating copy to clipboard operation
OpenTimelineIO copied to clipboard

Python binding is broken: it ignores PYTHON_EXECUTABLE and installs into a wrong prefix

Open yurivict opened this issue 3 years ago • 8 comments
trafficstars

  1. 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

  1. It installs python binding into the root directory / instead of the python site libs folder.

yurivict avatar Jan 29 '22 19:01 yurivict

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.

  1. 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?

  1. 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.

yurivict avatar Jan 29 '22 20:01 yurivict

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.

yurivict avatar Jan 29 '22 20:01 yurivict

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.

yurivict avatar Jan 29 '22 20:01 yurivict

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,

yurivict avatar Jan 29 '22 20:01 yurivict

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.

yurivict avatar Jan 29 '22 20:01 yurivict

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.

meshula avatar Jan 30 '22 01:01 meshula