[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame]



Hello,

Pygame works well on Python 3.2 for Windows 32 and 64 bit. I have installers at <http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame>. The _movie module seems to work. The changes to _camera.c are attached.

Christoph


On 2/26/2011 9:35 AM, Lenard Lindstrom wrote:
Hi,

_movie plays movies on Windows when the sdl driver is windib. Otherwise
the window is blank. It will play a movie on Debian squeeze when the
driver is directfb, but generates this error for X11:

XIO: fatal IO error 11 (Resource temporarily unavailable) on X server
":0.0"
after 90 requests (88 known processed) with 1 events remaining.

I could be that _movie is not correctly releasing some resource. The
smpeg based movie module works just fine with X11.

Lenard

On 26/02/11 01:37 AM, René Dudfield wrote:
Ah, nice one.

the ffmpeg module needs a bit of work... but I can't remember what
exactly. I think it kind of works for playing movies... but probably
needs updating for more recent ffmpeg.


On Sat, Feb 26, 2011 at 8:11 AM, Lenard Lindstrom <len-l@xxxxxxxxx
<mailto:len-l@xxxxxxxxx>> wrote:

Hello,

I ported Pygame to Python 3.2 and it builds successful for linux
and Windows for my 32 bit machine. The only extension modules
still to be ported to Python 3 are scrape, _camera, and _movie.
What is the status of the ffmpeg _movie module anyway?

Lenard Lindstrom



On 25/02/11 11:21 PM, René Dudfield wrote:


Hi,

I do not think anyone has tried it with 3.2 yet? I will see
if i can get it working today. I guess we will need to do
another release after it is fixed. Or maybe you will be able
to apply a small patch... not sure yet.

Speak again soon.

On 26 Feb 2011 06:44, "Westley Martínez" <anikom15@xxxxxxxxx
<mailto:anikom15@xxxxxxxxx> <mailto:anikom15@xxxxxxxxx
<mailto:anikom15@xxxxxxxxx>>> wrote:
> Hello, I am a developer who frequently uses pygame. I'm
wondering if
> anyone has been able to successfully build pygame for Python
3.2.
> Specifically the i686 and x86_64 architectures.
>
> I know pygame hasn't been completely ported to Python 3,
nevertheless I
> maintain a package for Arch Linux for pygame on Python 3.
Arch Linux
> recently updated to Python 3.2 (it is a rolling release
distribution)
> and I was able to build pygame fine, but when I attempted to
import it I
> got an error:
>
> Python 3.2 (r32:88445, Feb 21 2011, 01:55:53)
> [GCC 4.5.2 20110127 (prerelease)] on linux2
> Type "help", "copyright", "credits" or "license" for more
information.
>>>> import pygame
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib/python3.2/site-packages/pygame/__init__.py",
line 95,
> in <module>
> from pygame.base import *
> ImportError:
/usr/lib/python3.2/site-packages/pygame/base.cpython-32mu.so
<http://base.cpython-32mu.so> <http://base.cpython-32mu.so>:
undefined symbol: PyCObject_FromVoidPtr

>
> I am unsure why, and I am neither a pygame nor a CPython
developer. This
> is the process I used to build the package:
>
> python config.py
> python setup.py install --prefix=/usr
> cp -R examples lib/* "/usr/lib/python3.2/site-packages/pygame"
> cp -R test/* "/usr/lib/python3.2/site-packages/pygame/tests"
> chmod 644 /usr/include/python3.2mu/pygame/*
>
> Any information is appreciated.
>





Index: src/_camera.c
===================================================================
--- src/_camera.c	(revision 2957)
+++ src/_camera.c	(working copy)
@@ -34,6 +34,7 @@
  */
  
 #include "camera.h"
+#include "pgcompat.h"
 
 /*
 #if defined(__unix__) || !defined(__APPLE__)
@@ -1392,20 +1393,19 @@
     free(((PyCameraObject*) self)->device_name);
     PyObject_DEL (self);
 }
-
+/*
 PyObject* camera_getattr(PyObject* self, char* attrname) {
     return Py_FindMethod(cameraobj_builtins, self, attrname);
 }
-
+*/
 PyTypeObject PyCamera_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0,
+    TYPE_HEAD (NULL, 0)
     "Camera",
     sizeof(PyCameraObject),
     0,
     camera_dealloc,
     0,
-    camera_getattr,
+    0,                      /*camera_getattr */
     NULL,			        /*setattr*/
     NULL,			        /*compare*/
     NULL,			        /*repr*/
@@ -1416,7 +1416,24 @@
     (ternaryfunc)NULL,		/*call*/
     (reprfunc)NULL, 		/*str*/
     0L,0L,0L,0L,
-    DOC_PYGAMECAMERACAMERA  /* Documentation string */
+    DOC_PYGAMECAMERACAMERA,  /* Documentation string */
+    0,                          /* tp_traverse */
+    0,                          /* tp_clear */
+    0,                          /* tp_richcompare */
+    0,                          /* tp_weaklistoffset */
+    0,                          /* tp_iter */
+    0,                          /* tp_iternext */
+    cameraobj_builtins,         /* tp_methods */
+    0,                          /* tp_members */
+    0,                          /* tp_getset */
+    0,                          /* tp_base */
+    0,                          /* tp_dict */
+    0,                          /* tp_descr_get */
+    0,                          /* tp_descr_set */
+    0,                          /* tp_dictoffset */
+    0,                          /* tp_init */
+    0,                          /* tp_alloc */
+    0,                          /* tp_new */
 };
 
 PyObject* Camera (PyCameraObject* self, PyObject* arg) {
@@ -1515,25 +1532,49 @@
     {NULL, NULL, 0, NULL }
 };
  
-void init_camera(void) {
-    PyObject *module, *dict;
+MODINIT_DEFINE (_camera) {
+    PyObject *module;
     /* imported needed apis; Do this first so if there is an error
      * the module is not loaded.
      */
+     
+#if PY3
+    static struct PyModuleDef _module = {
+        PyModuleDef_HEAD_INIT,
+        "_camera",
+        DOC_PYGAMECAMERA,
+        -1,
+        camera_builtins,
+        NULL, NULL, NULL, NULL
+    };
+#endif
+
     import_pygame_base();
     if (PyErr_Occurred()) {
-        return;
+        MODINIT_ERROR;
     }
     import_pygame_surface();
     if (PyErr_Occurred()) {
-        return;
+        MODINIT_ERROR;
     }
 
     /* type preparation */
-    PyType_Init(PyCamera_Type);
+    //PyType_Init(PyCamera_Type);
+    PyCamera_Type.tp_new = PyType_GenericNew;
+    if (PyType_Ready (&PyCamera_Type) < 0)
+    {
+        MODINIT_ERROR;
+    }
   
     /* create the module */
+#if PY3
+    module = PyModule_Create(&_module);
+#else
     module = Py_InitModule3("_camera", camera_builtins, DOC_PYGAMECAMERA);
-    dict = PyModule_GetDict(module);
-    PyDict_SetItemString(dict, "CameraType", (PyObject *)&PyCamera_Type);
+#endif
+
+    Py_INCREF(&PyCamera_Type);
+    PyModule_AddObject(module, "CameraType", (PyObject *)&PyCamera_Type);
+
+    MODINIT_RETURN(module);
 }