Skip to content

Commit

Permalink
pygame: start adding python3 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
vext01 committed May 20, 2017
1 parent e7a6262 commit 6273712
Show file tree
Hide file tree
Showing 13 changed files with 883 additions and 0 deletions.
78 changes: 78 additions & 0 deletions devel/pygame/Makefile
@@ -0,0 +1,78 @@
# $OpenBSD: Makefile,v 1.32 2016/03/20 16:12:23 naddy Exp $

COMMENT= set of Python modules designed for writing games

DISTNAME= pygame-1.9.1release
PKGNAME= ${DISTNAME:S/release//}
CATEGORIES= devel games

HOMEPAGE= http://www.pygame.org/

# LGPLv2.1
PERMIT_PACKAGE_CDROM= Yes

WANTLIB += SDL SDL_image SDL_mixer SDL_ttf jpeg png pthread
WANTLIB += smpeg ${MODPY_WANTLIB}

MASTER_SITES= ${HOMEPAGE}ftp/

MODULES= lang/python

FLAVORS = python3
FLAVOR ?=

.if !${FLAVOR:Mpython3}
BUILD_DEPENDS += math/py-Numeric${MODPY_FLAVOR}
PKG_ARGS += -Dpython2
.endif

INCL_DIR = ${MODPY_INCDIR:S/${LOCALBASE}\///}
SUBST_VARS += INCL_DIR

LIB_DEPENDS= devel/sdl-ttf \
devel/sdl-image \
devel/sdl-mixer


MAKE_ENV+= LOCALBASE="${LOCALBASE}" \
SDL_CONFIG="${LOCALBASE}/bin/sdl-config"

EXAMPLESDIR= ${PREFIX}/share/examples/pygame${MODPY_BIN_SUFFIX}
DOCDIR= ${PREFIX}/share/doc/pygame${MODPY_BIN_SUFFIX}
DOCSUBDIRS= ref tut tut/chimp tut/surfarray \
tut/tom

TEST_IS_INTERACTIVE= x11

# fix perms
post-extract:
find ${WRKSRC} -type d | xargs chmod 755
find ${WRKSRC} -type f | xargs chmod 644

do-configure:
${SUBST_CMD} ${WRKSRC}/Setup.in
@cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MODPY_BIN} config.py

post-install:
${INSTALL_DATA_DIR} ${EXAMPLESDIR}
${INSTALL_SCRIPT} ${WRKSRC}/examples/*.py ${EXAMPLESDIR}
${INSTALL_DATA} ${WRKSRC}/examples/readme.txt ${EXAMPLESDIR}
${INSTALL_DATA_DIR} ${EXAMPLESDIR}/data
${INSTALL_SCRIPT} ${WRKSRC}/examples/data/* ${EXAMPLESDIR}/data
${INSTALL_DATA_DIR} ${DOCDIR}
${INSTALL_DATA} ${WRKSRC}/README.txt ${DOCDIR}
${INSTALL_DATA} ${WRKSRC}/docs/*.{gif,html} ${DOCDIR}
.for i in ${DOCSUBDIRS}
${INSTALL_DATA_DIR} ${DOCDIR}/$i
${INSTALL_DATA} `find ${WRKSRC}/docs/$i -maxdepth 1 -type f` \
${DOCDIR}/$i
.endfor
@perl -pi -e 's,/usr/bin/env python,/usr/bin/env python${MODPY_VERSION},g' \
${EXAMPLESDIR}/*.py

do-test: fake
@cd ${WRKSRC} && ${MAKE_ENV} \
PYTHONPATH=${WRKINST}${MODPY_SITEPKG} \
${MODPY_BIN} ./run_tests.py

.include <bsd.port.mk>
2 changes: 2 additions & 0 deletions devel/pygame/distinfo
@@ -0,0 +1,2 @@
SHA256 (pygame-1.9.1release.tar.gz) = omCVRyrkvpYx4NW/uaUqxXo6CR5FdXkTEo5KRzgH1DM=
SIZE (pygame-1.9.1release.tar.gz) = 2134254
11 changes: 11 additions & 0 deletions devel/pygame/patches/patch-Setup_in
@@ -0,0 +1,11 @@
$OpenBSD: patch-Setup_in,v 1.3 2015/07/07 22:29:14 bcallah Exp $
--- Setup.in.orig Thu Jul 2 00:41:56 2009
+++ Setup.in Mon Jul 6 22:27:18 2015
@@ -51,6 +51,7 @@ cdrom src/cdrom.c $(SDL) $(DEBUG)
color src/color.c $(SDL) $(DEBUG)
constants src/constants.c $(SDL) $(DEBUG)
display src/display.c $(SDL) $(DEBUG)
+display src/display.c $(SDL) $(DEBUG) -I${X11BASE}/include
event src/event.c $(SDL) $(DEBUG)
fastevent src/fastevent.c src/fastevents.c $(SDL) $(DEBUG)
key src/key.c $(SDL) $(DEBUG)
19 changes: 19 additions & 0 deletions devel/pygame/patches/patch-config_unix_py
@@ -0,0 +1,19 @@
$OpenBSD: patch-config_unix_py,v 1.5 2015/07/07 22:29:14 bcallah Exp $
--- config_unix.py.orig Tue May 26 17:15:24 2009
+++ config_unix.py Mon Jul 6 22:33:12 2015
@@ -172,15 +172,6 @@ def main():
for d in DEPS:
d.configure(incdirs, libdirs)

- for d in DEPS[1:]:
- if not d.found:
- if not confirm("""
-Warning, some of the pygame dependencies were not found. Pygame can still
-compile and install, but games that depend on those missing dependencies
-will not run. Would you like to continue the configuration?"""):
- raise SystemExit
- break
-
return DEPS

if __name__ == '__main__':
10 changes: 10 additions & 0 deletions devel/pygame/patches/patch-examples_eventlist_py
@@ -0,0 +1,10 @@
$OpenBSD: patch-examples_eventlist_py,v 1.2 2009/04/09 22:49:39 ajacoutot Exp $
--- examples/eventlist.py.orig Mon Jul 7 07:58:40 2008
+++ examples/eventlist.py Mon Apr 6 20:08:49 2009
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-
+#!/usr/bin/env python
"""Eventlist is a sloppy style of pygame, but is a handy
tool for learning about pygame events and input. At the
top of the screen are the state of several device values,
9 changes: 9 additions & 0 deletions devel/pygame/patches/patch-examples_fastevents_py
@@ -0,0 +1,9 @@
$OpenBSD: patch-examples_fastevents_py,v 1.2 2009/04/09 22:49:39 ajacoutot Exp $
--- examples/fastevents.py.orig Mon Jul 7 07:58:40 2008
+++ examples/fastevents.py Mon Apr 6 20:08:49 2009
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+#!/usr/bin/env python
""" This is a stress test for the fastevents module.

*Fast events does not appear faster!*
31 changes: 31 additions & 0 deletions devel/pygame/patches/patch-src_camera_h
@@ -0,0 +1,31 @@
$OpenBSD: patch-src_camera_h,v 1.1 2015/07/07 22:29:14 bcallah Exp $
--- src/camera.h.orig Fri Oct 10 03:37:10 2008
+++ src/camera.h Tue Jul 7 13:09:28 2015
@@ -37,11 +37,15 @@
#include <sys/mman.h>
#include <sys/ioctl.h>

+#if defined(__linux__)
#include <asm/types.h> /* for videodev2.h */

#include <linux/videodev.h>
#include <linux/videodev2.h>
+#elif defined(__OpenBSD__)
+ #include <sys/videoio.h>
#endif
+#endif

#define CLEAR(x) memset (&(x), 0, sizeof (x))
#define SAT(c) if (c & (~255)) { if (c < 0) c = 0; else c = 255; }
@@ -98,7 +102,11 @@ char** v4l2_list_cameras (int* num_devices);
int v4l2_get_control (int fd, int id, int *value);
int v4l2_set_control (int fd, int id, int value);
PyObject* v4l2_read_raw (PyCameraObject* self);
+#ifdef __OpenBSD__
+int v4l2_xioctl (int fd, unsigned long request, void *arg);
+#else
int v4l2_xioctl (int fd, int request, void *arg);
+#endif
int v4l2_process_image (PyCameraObject* self, const void *image,
unsigned int buffer_size, SDL_Surface* surf);
int v4l2_query_buffer (PyCameraObject* self);
15 changes: 15 additions & 0 deletions devel/pygame/patches/patch-src_camera_v4l2_c
@@ -0,0 +1,15 @@
$OpenBSD: patch-src_camera_v4l2_c,v 1.1 2015/07/07 22:29:14 bcallah Exp $
--- src/camera_v4l2.c.orig Sun Sep 28 05:31:42 2008
+++ src/camera_v4l2.c Tue Jul 7 13:10:17 2015
@@ -153,7 +153,11 @@ PyObject* v4l2_read_raw (PyCameraObject* self)
* and the HighGUI library in OpenCV.
*/

+#ifdef __OpenBSD__
+int v4l2_xioctl (int fd, unsigned long request, void *arg)
+#else
int v4l2_xioctl (int fd, int request, void *arg)
+#endif
{
int r;

22 changes: 22 additions & 0 deletions devel/pygame/patches/patch-src_camera_v4l_c
@@ -0,0 +1,22 @@
$OpenBSD: patch-src_camera_v4l_c,v 1.1 2015/07/07 22:29:14 bcallah Exp $
--- src/camera_v4l.c.orig Tue Jul 7 13:14:06 2015
+++ src/camera_v4l.c Tue Jul 7 13:13:28 2015
@@ -25,6 +25,10 @@

int v4l_open_device (PyCameraObject* self)
{
+#ifdef __OpenBSD__
+ /* OpenBSD supports V4L2 only */
+ return 0;
+#else
struct stat st;
struct video_capability cap;
struct video_mbuf buf;
@@ -67,6 +71,7 @@ int v4l_open_device (PyCameraObject* self)
}

return 1;
+#endif
}

int v4l_init_device(PyCameraObject* self)
21 changes: 21 additions & 0 deletions devel/pygame/patches/patch-src_scale_mmx64_c
@@ -0,0 +1,21 @@
$OpenBSD: patch-src_scale_mmx64_c,v 1.1 2017/04/22 03:11:36 jsg Exp $
--- src/scale_mmx64.c.orig Sat Apr 22 12:58:10 2017
+++ src/scale_mmx64.c Sat Apr 22 12:58:14 2017
@@ -425,7 +425,7 @@ filter_expand_X_MMX(Uint8 *srcpix, Uint8 *dstpix, int
" movl %5, %%ecx; "
" pxor %%mm0, %%mm0; "
"1: "
- " movsxl (%3), %%rax; " /* get xidx0[x] */
+ " movslq (%3), %%rax; " /* get xidx0[x] */
" add $4, %3; "
" movq (%0), %%mm1; " /* load mult0 */
" add $8, %0; "
@@ -500,7 +500,7 @@ filter_expand_X_SSE(Uint8 *srcpix, Uint8 *dstpix, int
" movl %5, %%ecx; "
" pxor %%mm0, %%mm0; "
"1: "
- " movsxl (%3), %%rax; " /* get xidx0[x] */
+ " movslq (%3), %%rax; " /* get xidx0[x] */
" add $4, %3; "
" movq (%0), %%mm1; " /* load mult0 */
" add $8, %0; "
4 changes: 4 additions & 0 deletions devel/pygame/pkg/DESCR
@@ -0,0 +1,4 @@
Pygame is a cross-platform library designed to make it easy to write
multimedia software, such as games, in Python. Pygame requires the
Python language and SDL multimedia library. It can also make use of
several other popular libraries.
4 changes: 4 additions & 0 deletions devel/pygame/pkg/PFRAG-python2
@@ -0,0 +1,4 @@
lib/python${MODPY_VERSION}/site-packages/pygame/_camera.so
lib/python${MODPY_VERSION}/site-packages/pygame/_numericsndarray.so
lib/python${MODPY_VERSION}/site-packages/pygame/_numericsurfarray.so
lib/python${MODPY_VERSION}/site-packages/pygame/scrap.so

0 comments on commit 6273712

Please sign in to comment.