Skip to contentSkip to conversation

package/gstreamer1/gst1-python: fix libpython-dir path

PATCH New aduskett at gmail.com 2 participants 4 messages Mar 24, 2020 – Mar 27, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 package/gstreamer1/gst1-python: fix libpython-dir path

From: Adam Duskett <[email protected]>

Due to the CONF_ENV options set in the gst1-python.mk file, libpython-dir must be set manually or else the error:
"Python dynamic library path could not be determined" occurs.

Previously the libpython-dir option was set to $(HOST_DIR)/lib/python$(PYTHON3_VERSION_MAJOR), however, this breaks the resulting .so because the above full path is baked into the resulting .so. which results in the error:

Couldn't g_module_open libpython. Reason:
/full/path/to/host/lib/python3.8/libpython3.8.so: cannot open shared object
file: No such file or directory

To fix this error, set the libpython-dir to /usr/lib.
Because we provide PYTHONPATH=$(PYTHON3_PATH) in the GST1_PYTHON_CONF_ENV, the logic in the meson file uses the above python3 provided by the PYTHONPATH variable to determine /usr/lib/ has the proper python$(PYTHON3_VERSION_MAJOR).so file.

Because Buildroot provides the appropriate paths, the meson file finds the correct .so file and the resulting compiled library has the appropriate path of /usr/lib/python3.$(PYTHON3_VERSION_MAJOR).so

This change has been tested on the following distributions:
- Debian 9 and 10
- Debian 9 without python3 installed on the host.
- Centos7
- Fedora 31

---
 package/gstreamer1/gst1-python/gst1-python.mk | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
package/gstreamer1/gst1-python/gst1-python.mk +9 -3
index 23b4bbd900..122c3dd997 100644
@@ -23,10 +23,16 @@ GST1_PYTHON_CONF_ENV += \
 	_PYTHON_SYSCONFIGDATA_NAME=$(PKG_PYTHON_SYSCONFIGDATA_NAME) \
 	PYTHONPATH=$(PYTHON3_PATH)
 
-# Due to the CONF_ENV options, libpython-dir must be set to the host directory
+# Due to the CONF_ENV options, libpython-dir must be set manually
 # or else the error: "Python dynamic library path could not be determined"
-# will occure
+# occurs. We set the libpython-dir to /usr/lib as this path is hard-coded
+# into the resulting .so file as /usr/lib/python3.$(PYTHON3_VERSION_MAJOR).so.
+# Because we provide PYTHONPATH=$(PYTHON3_PATH) above, the logic in the meson
+# file uses the above python path to determine if /usr/lib/ has the proper .so
+# file. Because Buildroot provides the appropriate paths, the meson file finds
+# the correct .so file, and the resulting compiled library has the appropriate
+# path of /usr/lib/python3.$(PYTHON3_VERSION_MAJOR).so
 GST1_PYTHON_CONF_OPTS += \
-	-Dlibpython-dir=$(HOST_DIR)/lib/python$(PYTHON3_VERSION_MAJOR)
+	-Dlibpython-dir=/usr/lib/
 
 $(eval $(meson-package))
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 support/testing/tests/package/test_gst1_python.py: fix config and timeout

From: Adam Duskett <[email protected]>

The config is missing the following packages:
- BR2_PACKAGE_GST1_PLUGINS_BASE
- This is needed for the videotestsrc plugin which provides videotestsrc.

- BR2_PACKAGE_GST1_PLUGINS_BAD
- This is needed for the debugutils plugin which provides fakevideosink.

- BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_VIDEOTESTSRC
- videotestsrcplugin used by the example pipeline.

- BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_DEBUGUTILS
- fakevideosink plugin used by the example pipeline.

In addition, the default timeout is set to low and will result in a test failure, this has been changed to 200 seconds.

---
 support/testing/tests/package/test_gst1_python.py | 5 +++++
 1 file changed, 5 insertions(+)
support/testing/tests/package/test_gst1_python.py +5 -0
index 469e0f392d..c6b337dd04 100644
@@ -14,6 +14,10 @@ class TestGst1Python(TestPythonPackageBase):
         BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM=y
         BR2_PACKAGE_GOBJECT_INTROSPECTION=y
         BR2_PACKAGE_GSTREAMER1=y
+        BR2_PACKAGE_GST1_PLUGINS_BASE=y
+        BR2_PACKAGE_GST1_PLUGINS_BAD=y
+        BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_VIDEOTESTSRC=y
+        BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_DEBUGUTILS=y
         BR2_PACKAGE_GST1_PYTHON=y
         BR2_PACKAGE_PYTHON3=y
         BR2_PACKAGE_PYTHON_GOBJECT=y
@@ -26,3 +30,4 @@ class TestGst1Python(TestPythonPackageBase):
                            options=["-initrd", cpio_file])
         self.emulator.login()
     sample_scripts = ["tests/package/sample_gst1_python.py"]
+    timeout = 200
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/3 support/testing/tests/package/sample_gst1_python.py: fix test

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

This commit fixes the following issues:
- No call to main.

- using autovideosink instead of fakevideosink. Using Fakevideoskink is preferred because its primary purpose is for debugging and sample pipelines. Autovideosink does not work because there is no video output device.

- No function on_message. Without this function, the script fails because of the missing function.

- The script sets the pipeline to Gst.State.EOS instead of Gst.State.NULL which results in a failed pipeline state. When the state is set to NULL, gstreamer automatically calls EOS. Manually setting the pipeline state to EOS results in the following error:

Trying to dispose element sink, but it is in PLAYING instead of the NULL state. You need to explicitly set elements to the NULL state before dropping the final reference, to allow them to clean up. A refcounting bug may also cause this problem in the application or some element.

These issues are now properly fixed, and the sample script passes.

---
 .../tests/package/sample_gst1_python.py       | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
support/testing/tests/package/sample_gst1_python.py +15 -4
index 39107616ed..6ed57a168b 100644
@@ -1,20 +1,31 @@
 #!/usr/bin/env python
-"""A simple test that uses gst1-python to run a fake videotestsrc for 100 frames"""
+"""A simple test that uses gst1-python to run a fake videotestsrc for 100
+frames
+"""
 import sys
 import gi
 gi.require_version('Gst', '1.0')
 from gi.repository import Gst, GLib  # noqa: E402
 
 
+def on_message(bus: Gst.Bus, message: Gst.Message, loop: GLib.MainLoop):
+    if message.type == Gst.MessageType.EOS:
+        loop.quit()
+    return True
+
+
 def main():
     # Initializes Gstreamer
     Gst.init(sys.argv)
-    pipeline = Gst.parse_launch("videotestsrc num-buffers=100 ! autovideosink")
+    pipeline = Gst.parse_launch("videotestsrc num-buffers=100 ! fakevideosink")
     bus = pipeline.get_bus()
     bus.add_signal_watch()
     pipeline.set_state(Gst.State.PLAYING)
     loop = GLib.MainLoop()
     bus.connect("message", on_message, loop)
     loop.run()
-    pipeline.set_state(Gst.State.EOS)
-    exit(0)
+    pipeline.set_state(Gst.State.NULL)
+
+
+if __name__ == '__main__':
+    main()
Signature · 1 line
2.25.1
#3 lore raw

PATCH 1/3 package/gstreamer1/gst1-python: fix libpython-dir path

In reply to aduskett at gmail.com

Adam, All,

On 2020-03-24 10:38 -0700, aduskett at gmail.com spake thusly:

Quoted 25 lines

From: Adam Duskett <[email protected]>

Due to the CONF_ENV options set in the gst1-python.mk file, libpython-dir must be set manually or else the error:
"Python dynamic library path could not be determined" occurs.

Previously the libpython-dir option was set to $(HOST_DIR)/lib/python$(PYTHON3_VERSION_MAJOR), however, this breaks the resulting .so because the above full path is baked into the resulting .so. which results in the error:

Couldn't g_module_open libpython. Reason:
/full/path/to/host/lib/python3.8/libpython3.8.so: cannot open shared object
file: No such file or directory

To fix this error, set the libpython-dir to /usr/lib.
Because we provide PYTHONPATH=$(PYTHON3_PATH) in the GST1_PYTHON_CONF_ENV, the logic in the meson file uses the above python3 provided by the PYTHONPATH variable to determine /usr/lib/ has the proper python$(PYTHON3_VERSION_MAJOR).so file.

Because Buildroot provides the appropriate paths, the meson file finds the correct .so file and the resulting compiled library has the appropriate path of /usr/lib/python3.$(PYTHON3_VERSION_MAJOR).so

Quoted 7 lines

This change has been tested on the following distributions:
- Debian 9 and 10
- Debian 9 without python3 installed on the host.
- Centos7
- Fedora 31

Thanks for the fixes. I've all three to master, but I also did meld patches two and three together because they are doing a single thing:
fix the test case.

Thanks!
Regards,
Yann E. MORIN.

Quoted 35 lines
---
 package/gstreamer1/gst1-python/gst1-python.mk | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
package/gstreamer1/gst1-python/gst1-python.mk +9 -3
index 23b4bbd900..122c3dd997 100644
@@ -23,10 +23,16 @@ GST1_PYTHON_CONF_ENV += \
 	_PYTHON_SYSCONFIGDATA_NAME=$(PKG_PYTHON_SYSCONFIGDATA_NAME) \
 	PYTHONPATH=$(PYTHON3_PATH)
 
-# Due to the CONF_ENV options, libpython-dir must be set to the host directory
+# Due to the CONF_ENV options, libpython-dir must be set manually
 # or else the error: "Python dynamic library path could not be determined"
-# will occure
+# occurs. We set the libpython-dir to /usr/lib as this path is hard-coded
+# into the resulting .so file as /usr/lib/python3.$(PYTHON3_VERSION_MAJOR).so.
+# Because we provide PYTHONPATH=$(PYTHON3_PATH) above, the logic in the meson
+# file uses the above python path to determine if /usr/lib/ has the proper .so
+# file. Because Buildroot provides the appropriate paths, the meson file finds
+# the correct .so file, and the resulting compiled library has the appropriate
+# path of /usr/lib/python3.$(PYTHON3_VERSION_MAJOR).so
 GST1_PYTHON_CONF_OPTS += \
-	-Dlibpython-dir=$(HOST_DIR)/lib/python$(PYTHON3_VERSION_MAJOR)
+	-Dlibpython-dir=/usr/lib/
 
 $(eval $(meson-package))
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'