After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 675604 - gst-python: fix compilation on windows
gst-python: fix compilation on windows
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-python
0.10.x
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-05-07 11:06 UTC by Andoni Morales
Modified: 2013-11-24 22:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix compilation in windows (2.39 KB, patch)
2012-05-07 11:06 UTC, Andoni Morales
needs-work Details | Review
fix python's configure checks (2.44 KB, patch)
2012-05-07 11:07 UTC, Andoni Morales
reviewed Details | Review
fix compilation in windows (2.08 KB, patch)
2012-05-08 08:41 UTC, Andoni Morales
accepted-commit_now Details | Review

Description Andoni Morales 2012-05-07 11:06:40 UTC
Created attachment 213574 [details] [review]
fix compilation in windows

Fix compilation on windows adding -no-undefined and link to the python libraries properly.
Also fix python checks. When cross-compiling, we can't invoke python to guess the include's directory or the link libraries, instead those should be passed     through PYTHON_INCLUDES and PYTHON_LIBS. When compiling natively we can't use the python macro either because python-config is missing and the default path is wrong and because python returns paths with backlashes which are not escaped properly
Comment 1 Andoni Morales 2012-05-07 11:07:08 UTC
Created attachment 213575 [details] [review]
fix python's configure checks
Comment 2 Sebastian Dröge (slomo) 2012-05-07 11:12:17 UTC
Review of attachment 213574 [details] [review]:

This is not correct as the python interpreter is statically linked to libpython and linking the gstreamer module to the library will caused the library to be in memory twice when python is used from the interpreter (in contrast to be used from inside an application).

If anything this should be optional for windows only.
Comment 3 Andoni Morales 2012-05-08 08:41:51 UTC
Created attachment 213648 [details] [review]
fix compilation in windows

Updated patch to link conditionally with PYTHON_LIBS only on windows
Comment 4 Sebastian Dröge (slomo) 2012-05-09 07:43:50 UTC
Review of attachment 213575 [details] [review]:

::: configure.ac
@@ +99,3 @@
+if test "x$platform_win32" = "xyes" ; then
+  # skip python cheks if compiling to windows
+  # $PYTHON_INCLUDES and PYTHON_LIBS should be set properly

Why can't you use AM_CHECK_PYTHON_HEADERS() or an equivalent on Windows? Requiring the user to properly set this seems rather unintuitive

@@ +454,1 @@
 

Why do you remove the valgrind check?
Comment 5 Sebastian Dröge (slomo) 2012-05-09 07:46:00 UTC
Comment on attachment 213648 [details] [review]
fix compilation in windows

Looks good to me but depends on the other patch (Could you split the other into two chunks maybe, one for setting PLATFORM_WIN32?)
Comment 6 Andoni Morales 2012-05-09 09:00:11 UTC
This macro has several issues that makes it impossible to use for windows.

The first problem comes when this macro is being used in a cross-compilation environment. This macro calls the native python to guess -I -L and -l which is wrong as you will get the details for the system's python and not the target one. Also this macro don't check whether PYTHON_INCLUDES or PYTHON_LIBS is set to skip the check.
On a native environment, this macro makes use of python-config, which is not available on Windows

if $PYTHON-config --help 2>/dev/null; then
   PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null`
else
   PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"

The fallback path is wrong as the windows installer installs the python headers in ${py_prefix}/Include


For PYTHON_LIBS -L is also wrong because libpython27.dll, which is the dll used for linking, is not in ${py_prefix}/lib but in c:/Windows/System32

if $PYTHON-config --help 2>/dev/null; then
 PYTHON_LIBS=`$PYTHON-config --ldflags 2>/dev/null`
 PYTHON_LIB=`$PYTHON -c "import distutils.sysconfig as s; print s.get_python_lib(standard_lib=1)"`
[...]
else
 PYTHON_LIBS="-L${py_prefix}/lib -lpython${PYTHON_VERSION}"
 PYTHON_LIB_LOC="${py_prefix}/lib"
fi


Also py_prefix must be overridden with the am_cv_python_pyexecdir and am_cv_python_pythondir because paths from the python command are windows paths with backslashes which are escaped.
Comment 7 Andoni Morales 2012-05-09 09:14:11 UTC
The check is defined in acinclude.m4 so it could be fixed there instead.
Comment 8 Sebastian Dröge (slomo) 2012-05-09 09:23:12 UTC
Yes, should be fixed in acinclude.m4 and where the macro comes from (Python maybe?)

(In reply to comment #6)
> This macro has several issues that makes it impossible to use for windows.
> 
> The first problem comes when this macro is being used in a cross-compilation
> environment. This macro calls the native python to guess -I -L and -l which is
> wrong as you will get the details for the system's python and not the target
> one.

Ack, for cross compilation it shouldn't call any native binaries.

> Also this macro don't check whether PYTHON_INCLUDES or PYTHON_LIBS is set
> to skip the check.

Yes, skipping the test if the variables are set would be the correct behaviour

> On a native environment, this macro makes use of python-config, which is not
> available on Windows
> 
> if $PYTHON-config --help 2>/dev/null; then
>    PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null`
> else
>    PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
> 
> The fallback path is wrong as the windows installer installs the python headers
> in ${py_prefix}/Include

So platform specific fallbacks here

> For PYTHON_LIBS -L is also wrong because libpython27.dll, which is the dll used
> for linking, is not in ${py_prefix}/lib but in c:/Windows/System32
> 
> if $PYTHON-config --help 2>/dev/null; then
>  PYTHON_LIBS=`$PYTHON-config --ldflags 2>/dev/null`
>  PYTHON_LIB=`$PYTHON -c "import distutils.sysconfig as s; print
> s.get_python_lib(standard_lib=1)"`
> [...]
> else
>  PYTHON_LIBS="-L${py_prefix}/lib -lpython${PYTHON_VERSION}"
>  PYTHON_LIB_LOC="${py_prefix}/lib"
> fi

... and here

> Also py_prefix must be overridden with the am_cv_python_pyexecdir and
> am_cv_python_pythondir because paths from the python command are windows paths
> with backslashes which are escaped.

Ok
Comment 9 Sebastian Dröge (slomo) 2012-12-17 10:51:53 UTC
What should we do with this? gst-python is completely different in master, is this still relevant or necessary?
Comment 10 Tobias Mueller 2013-04-18 19:30:28 UTC
ping. There are patches lying around.
Comment 11 Tim-Philipp Müller 2013-11-24 18:57:28 UTC
Andoni: is this still relevant with 1.x gst-python, or can this be closed?
Comment 12 Andoni Morales 2013-11-24 22:03:49 UTC
I think it's not needed anymore