PySide Shiboken Tutorial: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=Simple Shiboken Binding Tutorial=
[[Category:LanguageBindings::PySide]]


This is sample demonstration how to generate simple bindings with shiboken python binding generator. This tutorial was written by Roman Lacko in a recent [http://lists.qt.io/pipermail/pyside/2013-January/001009.html mailing list] ''[lists.qt.io]''.
= Simple Shiboken Binding Tutorial =
 
This is sample demonstration how to generate simple bindings with shiboken python binding generator. This tutorial was written by Roman Lacko in a recent "mailing list":http://lists.qt.io/pipermail/pyside/2013-January/001009.html.


* ''FooLib'' project contains the library for which we want to generate the bindings
* ''FooLib'' project contains the library for which we want to generate the bindings
* ''FooLibBinding'' project contains the generated binding sources
* ''FooLibBinding'' project contains the generated binding sources


==Software used:==
== Software used: ==


* [http://releases.qt.io/qt4/source/qt-win-opensource-4.8.4-vs2010.exe Qt 4.8.4 <span class="caps">MSVC</span> 2010 64bit] ''[releases.qt.io]''
* &quot;Qt 4.8.4 MSVC 2010 64bit&amp;quot;:http://releases.qt.io/qt4/source/qt-win-opensource-4.8.4-vs2010.exe
** Please note that by default Python 2.7 is built with msvc2008 and Python 3.3 with msvc2010. So in general you should use MSVC2008 to compile, however others have successfully completed this tutorial using MSVC2010.
** Please note that by default Python 2.7 is built with msvc2008 and Python 3.3 with msvc2010. So in general you should use MSVC2008 to compile, however others have successfully completed this tutorial using MSVC2010.
* [http://python.org/ftp/python/2.7.3/python-2.7.3.amd64.msi Python 2.7 64bit] ''[python.org]''
* &quot;Python 2.7 64bit&amp;quot;:http://python.org/ftp/python/2.7.3/python-2.7.3.amd64.msi
* [http://releases.qt.io/pyside/PySide-1.1.2.win-amd64-py2.7.exe PySide 1.1.2 for Python 2.7 64bit] ''[releases.qt.io]''
* &quot;PySide 1.1.2 for Python 2.7 64bit&amp;quot;:http://releases.qt.io/pyside/PySide-1.1.2.win-amd64-py2.7.exe
* [https://docs.google.com/file/d/0B0aOk3P0ndoLbkhwbWZncTlUM00/edit BindingTest.zip] ''[docs.google.com]''
* &quot;BindingTest.zip&amp;quot;:https://docs.google.com/file/d/0B0aOk3P0ndoLbkhwbWZncTlUM00/edit


==Notes:==
== Notes: ==


* Update the paths to python libs and includes in ''FooLibBinding\FooLibBinding.pro''. In this tutorial, it’s assumed that python is installed in C:\Python27_64.
* Update the paths to python libs and includes in ''FooLibBinding\FooLibBinding.pro''. In this tutorial, it's assumed that python is installed in C:27_64.
 
<code><br />INCLUDEPATH ''= ../pyside/include/PySide  ../pyside/include/PySide/QtCore  ../pyside/include/shiboken  c:/Python27_64/include  ../FooLib
<br />LIBS''= c:/Python27_64/libs/python27.lib  ../pyside/shiboken-python2.7.lib  ../FooLib-build-Desktop-Release/release/FooLib.lib<br /></code>


* Also update the path where you have installed Qt on your system in the files below
* Also update the path where you have installed Qt on your system in the files below
** Replace this “c:\Qt\qt-4.8.4-msvc2010-x64” with your path
** Replace this &quot;c:–4.8.4-msvc2010-x64&amp;quot; with your path
 
<code><br />pyside\include\PySide\pyside_global.h<br />FooLib\generate_binding.bat<br /></code>


* Note that if you decide to experiment with using mingw, you will need to change the .lib extension to .a
* Note that if you decide to experiment with using mingw, you will need to change the .lib extension to .a


==To generate and test the bindings do the following:==
== To generate and test the bindings do the following: ==


# Install PySide
# Install PySide
# Copy content of ''C:\Python27\Lib\site-packages\PySide'' to ''BindingTest\PySide'' folder
# Copy content of ''C:27\Lib\site-packages\PySide'' to ''BindingTest\PySide'' folder
# Compile ''FooLib'' project
# Compile ''FooLib'' project
# Run ''FooLib\generate_binding.bat''
# Run ''FooLib\generate_binding.bat''
# Compile ''FooLibBinding'' project
# Compile ''FooLibBinding'' project
# Run ''FooLibBinding\make_package.bat''
# Run ''FooLibBinding\make_package.bat''
# Go to generated folder “''package''” and run ''foolib_test.py''
===Categories:===
* [[:Category:LanguageBindings|LanguageBindings]]
** [[:Category:LanguageBindings::PySide|PySide]]

Revision as of 10:43, 24 February 2015


Simple Shiboken Binding Tutorial

This is sample demonstration how to generate simple bindings with shiboken python binding generator. This tutorial was written by Roman Lacko in a recent "mailing list&quot;:http://lists.qt.io/pipermail/pyside/2013-January/001009.html.

  • FooLib project contains the library for which we want to generate the bindings
  • FooLibBinding project contains the generated binding sources

Software used:

Notes:

  • Update the paths to python libs and includes in FooLibBinding\FooLibBinding.pro. In this tutorial, it's assumed that python is installed in C:27_64.
<br />INCLUDEPATH ''= ../pyside/include/PySide  ../pyside/include/PySide/QtCore  ../pyside/include/shiboken  c:/Python27_64/include  ../FooLib
<br />LIBS''= c:/Python27_64/libs/python27.lib  ../pyside/shiboken-python2.7.lib  ../FooLib-build-Desktop-Release/release/FooLib.lib<br />
  • Also update the path where you have installed Qt on your system in the files below
    • Replace this "c:–4.8.4-msvc2010-x64&quot; with your path
<br />pyside\include\PySide\pyside_global.h<br />FooLib\generate_binding.bat<br />
  • Note that if you decide to experiment with using mingw, you will need to change the .lib extension to .a

To generate and test the bindings do the following:

  1. Install PySide
  2. Copy content of C:27\Lib\site-packages\PySide to BindingTest\PySide folder
  3. Compile FooLib project
  4. Run FooLib\generate_binding.bat
  5. Compile FooLibBinding project
  6. Run FooLibBinding\make_package.bat