Hello,
Thank you for your answer, Dan! We found a way to use mlt with Python3. When python imports a package, it searches in directories and sub-directories which are currently in the PYTHON PATHS : - (in a python2.7 Environment) : /usr/lib/python2.7/ - (in a python3.X Environment) : /usr/lib/python/3.4/ The required packages to "import mlt" in python2.7 are : - /usr/lib/python2.7/dist-packages/mlt.py - /usr/lib/python2.7/dist-packages/mlt.pyc - /usr/lib/python2.7/dist-packages/_mlt.x86_64-linux.so -cf:var/lib/dpkg/info/python-mlt.list They are generated by the mlt-0.9.X/src/swig/python/build script from the official source code. In order to switch to a Python3 environment, we have to make the following changes to the mlt 0.9.X/src/swig/python/build script (cf: enclosed script "build"): - which python3 2> - `python3 -c "import sys;print(\"%s/include/python%d.%d\"%(sys.prefix,sys.version_info[0],sys.version_info[1]))"` - -lmlt $(python3-config --ldflags) - -python -modern -py3 (swig -python -help) In addition to that, some problems come from the mlt-0.9.X/src/swig/mlt.i file. In python3 the following command is deprecated: "$result = PyString_FromStringAndSize( $1.data, $1.size );" We have to create a test that checks if we are in a Python3 or Python2 environment. If we are in a Python3 environment we will replace "PyString_FromStringAndSize" by "PyUnicode_DecodeUTF8". The attached text files explain the tasks required: build-3 : ======== The bash script which creates the mlt.py and the _mlt.x86_64-linux.so files that compose the python-mlt package for a Python3 environment. mlt-001_python3-strings.patch : =============================== a patch file which corrects the mlt-0.9.X/src/swig/mlt.i file : %typemap(out) binary_data { +%#if PY_VERSION_HEX >= 0x03000000 +%#if PY_VERSION_HEX >= 0x03010000 + $result = PyUnicode_DecodeUTF8( $1.data, $1.size , "surrogateescape" ); +%#else + $result = PyUnicode_FromStringAndSize( $1.data, $1.size ); +%#endif +%#else $result = PyString_FromStringAndSize( $1.data, $1.size ); +%#endif } The patch and the build script in a Python3 environment should be good enough to create the right package but we chose to apply and unapply the patch directly in the build script in order to prevent the potential edge effects." Kind regards Ludovic MICHAUD (06 60 67 50 78) ludovic.micha...@gmail.com Étudiant en Master 2 ISIS (Ingénierie des Systèmes Images et Sons) *Student : Master's degree in Broadcast Engineering * Université de Valenciennes et du Hainaut-Cambrésis (UVHC) 2015-09-01 18:53 GMT+02:00 Dan Dennedy <d...@dennedy.org>: > On Tue, Sep 1, 2015 at 7:39 AM Ludovic Michaud <ludovic.micha...@gmail.com> > wrote: > >> Hello, >> >> Do you know if it is possible to use MLT with Python 3 ? >> > > Probably yes, but I have never done it. > http://www.swig.org/Doc2.0/SWIGDocumentation.html#Python_python3support > > >> I've seen that softwares like Flowblade are developed with Python 2.7 >> thanks to Swig. >> >> When I try to “import mlt” in Python 2, there is no problem, but with >> Python 3, it returns “ImportError: No module named mlt”. >> >> Do you think that the problem comes from Swig or MLT ? >> > > I think it comes from how it is being built - which python-dev is > installed... > > >> Maybe it's because of the Bash script called *build **in MLT package* ( >> https://github.com/mltframework/mlt/blob/master/src/swig/python/build). >> >> > ...and perhaps something in PYTHON_INCLUDES and pkg-config usage in this > script. > > >> Thank you for your consideration. >> >> >> Best regards. >> >> Ludovic. >> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Mlt-devel mailing list >> Mlt-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/mlt-devel >> >
build-py3
Description: Binary data
mlt-001_python3-strings.patch
Description: Binary data
------------------------------------------------------------------------------ Go from Idea to Many App Stores Faster with Intel(R) XDK Give your users amazing mobile app experiences with Intel(R) XDK. Use one codebase in this all-in-one HTML5 development environment. Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs. http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________ Mlt-devel mailing list Mlt-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mlt-devel