Apostolos\’ Daily Plate

Using pygame with Python 3.2.3

Posted in Πληροφορική, OpenIndiana by asyropoulos on Αύγουστος 1, 2012

Yesterday I tried to compile Python 3.2.3 on OpenIndiana. There was absolutely no problem. Then I tried to compile pygame but it failed. The reason is that certain symbols are no longer defined in Python 3.2.0 and later versions. To solve this problem one has to apply the following patch:

diff -crB pygame-1.9.1release.orig/src/pygame.h pygame-1.9.1release.new/src/pygame.h
*** pygame-1.9.1release.orig/src/pygame.h	2009-07-06 19:09:50.000000000 +0300
--- pygame-1.9.1release.new/src/pygame.h	2012-08-01 19:26:45.902639760 +0300
***************
*** 130,135 ****
--- 130,141 ----
  typedef getcharbufferproc charbufferproc;
  #endif

+ #if PY_VERSION_HEX >= 0x3020000
+ #define PyCObject_AsVoidPtr(P) (PyCapsule_GetPointer(P, 0))
+ #define PyCObject_FromVoidPtr(X, P) (PyCapsule_New(X, 0, P))
+ #define PyCObject_Check(P) (PyCapsule_CheckExact(P))
+ #endif
+ 
  #define PyType_Init(x) (((x).ob_type) = &PyType_Type)
  #define PYGAMEAPI_LOCAL_ENTRY "_PYGAME_C_API"

This solves all problems and pygame compiles and works just fine.

Advertisements