Hi everyone, I'm trying to get PySide to run with PyPy using the Python C-API. I'm able to build and install PySide under PyPy on Windows, without any errors, but the installed libraries do not work. I'm working on it. Anyone wants to give it a try on Linux? Maybe the problem is Windows specific. Here is my recipe for building PySide with PyPy: 1. Install the prerequisites: * CMake * Qt (4.6, 4.7, 4.8 are said to work; I used Qt 4.8.5, the latest Qt 4 version) * iconv, libxml2, libxslt (Not sure if they really are needed.) 2. The sphinx package can cause problems. If you don't have sphinx installed or if you have sphinx 1.1.3 installed, then you are fine. But if you have sphinx 1.2.1 (the latest version) installed, then the build will fail. (This is a known PySide issue.) 3. Replace <pypy-prefix>/include/Python.h with the following patched version: https://dl.dropboxusercontent.com/u/525329/PySide/Python.h I have added definitions of two C-API functions, PyUnicode_Concat and PyCFunction_Call, that are missing in PyPy. 4. To make the build work, I had to create a directory <pypy-prefix>/libs and copy <pypy-prefix>/include/python27.lib there. This might be different on Linux. 5. Download the following patched version of the PySide installation package: https://dl.dropboxusercontent.com/u/525329/PySide/PySide-1.2.1-patched.zip I have fixed some bugs in the PySide code. 6. Unzip PySide-1.2.1-patched.zip and run setup.py. I used the command pypy setup.py bdist_egg --qmake=c:\qt-4.8.5-vs2008\bin\qmake.exe If you have only one Qt version installed, then you can probably skip the --qmake option. If you have more than one Qt version installed, use the --qmake option to specify which Qt version to use. On my laptop, the build takes about 20 minutes. --Johan
Hi Johan, On 23 February 2014 08:44, Johan Råde <johan.rade@gmail.com> wrote:
the installed libraries do not work.
Thanks for the instructions! As far as I'm concerned I cannot do anything from "do not work"-kind of descriptions. Please also include a small example of code using the library and tell us exactly what you expect it to do, and what it does instead. (It's maybe obvious and for all I know any example program crashes immediately, but please write down an explicit example.) A bientôt, Armin.
Hi Armin, Observed behavior on Windows:
import PySide import PySide.QtCore Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named PySide.QtCore from PySide import * Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'QtCore'
Expected behavior: The module PySide.QtCore should be imported successfully. ----------------------------------------- If you are able to import PySide.QtCore and PySide.QtGui, then the next step would be to try a simple hello world program: import sys from PySide.QtGui import * app = QApplication(sys.argv) label = QLabel("Hello World!") label.show() app.exec_() This should display a small window with the text "Hello World!" --Johan
On 2014-02-23 08:44, Johan Råde wrote:
Hi everyone,
I'm trying to get PySide to run with PyPy using the Python C-API. I'm able to build and install PySide under PyPy on Windows, without any errors, but the installed libraries do not work. I'm working on it.
Maybe I'm making some progress. Here is what happens now when I try to import PySide.QtCore:
import PySide.QtCore Fatal error in cpyext, CPython compatibility layer, calling PyDict_SetItemString Either report a bug or consider not using this particular extension <OpErrFmt object at 0x2467e24> RPython traceback: File "pypy_module_cpyext_api_2.c", line 17110, in PyDict_SetItemString File "pypy_module_cpyext_pyobject.c", line 1136, in BaseCpyTypedescr_realize File "pypy_objspace_std_objspace.c", line 4657, in allocate_instance__W_ObjectObject File "pypy_objspace_std_typeobject.c", line 3911, in W_TypeObject_check_user_subclass
Does this trace contain any useful information? I'm using the official 2.2.1 release of PyPy. ------------------------------------------------------------------------------------------- Updated instructions for building and installing PySide 1.2.1 with PyPy 2.2.1 on Windows: 1. Install the prerequisites: * CMake * Qt 4.x.y, with x >= 6, compiled with Visual Studio 2008 (I used Qt 4.8.5, the latest Qt 4 version.) Binaries can be downloaded from http://qt-project.org/downloads * iconv, libxml2, libxslt. (Not sure if they are needed.) 2. The sphinx package can cause problems. If you don't have sphinx installed or if you have sphinx 1.1.3 installed, then you are fine. But if you have sphinx 1.2.1 (the latest version) installed, then the build will fail. 3. Download the file c-api-extra.h here: https://dl.dropboxusercontent.com/u/525329/PySide/c-api-extra (It contains definitions of some required C-API functions that are missing from PyPy.) Copy the file c-api-extra.h to <pypy-prefix>/include and add the statement #include "c-api-extra.h" somewhere towards the end of <pypy-prefix>/include/Python.h 4. The definiton of PyMODINIT_FUNC in <pypy-prefix>/include/modsupport.h will not work on Windows. Change it to #define PyMODINIT_FUNC __declspec(dllexport) void 5. Create a directory <pypy-prefix>/libs and copy <pypy-prefix>/include/python27.lib there. 6. Download the following patched version of the PySide installation package: https://dl.dropboxusercontent.com/u/525329/PySide/PySide-1.2.1-patched.zip (I have fixed some bugs in the PySide code.) Unzip and copy the directory PySide-1.2.1-patched to a suitable location; the path to PySide-1.2.1-patched must not contain any spaces. 7. Build PySide: Open a Visual Studio 2008 command prompt. Change the current directory to PySide-1.2.1-patched. Run the command: pypy setup.py bdist_egg --qmake=c:/Qt/4.8.5/bin/qmake.exe (Modify the path to qmake.exe if needed.) On my laptop, the build takes about 20 minutes. 8. If you get errors such as "mt.exe : general error c101008d: Failed to write the updated manifest to the resource of file "shiboken.exe". The process cannot access the file because it is being used by another process." during the build, then you should turn off your anti-virus software and try again. 9. Install PySide: Change the current directory to PySide-1.2.1-patched/dist Run the command easy_install PySide-1.2.1-py2.7.egg 10. Go to directory <pypy-prefix>/site-packages/PySide-1.2.1-py2.7.egg/PySide. There you find 18 files with the file extension .pyd. Change these file extensions to .pypy-22.pyd. 11. Add the directory <pypy-prefix>/site-packages/PySide-1.2.1-py2.7.egg/PySide to the system path. Reboot. --Johan
participants (2)
-
Armin Rigo
-
Johan Råde