Dernière mise à jour : 02/01/2018 à 11h31
Table des matières
Installer Pygame pour Python 3 (Mageia 5, 6)
Pygame est une bibliothèque libre multiplate-forme qui facilite le développement de jeux vidéo temps réel avec le langage de programmation Python.
Introduction
Le jeu jeu ultime ! Une seule bouteille de whisky a suffit à faire éclore votre génie.
Vous allez le coder en Python 3 et Pygame.
C'est simple
urpmi python-pygame
et voilà !
Non.
À l'heure actuelle, 23/08/17, le rpm est python-pygame-1.9.1-16.mga6. Et cette version de pygame, 1.9.1, n'est pas compatible avec Python3.
Il vous faut la 1.9.2
La solution de facilité
Vous téléchargez la version 1.9.2 que j'ai construite (« buildée ») pour ma Mageia 6 64 bits.
Vous décompressez, et changez pour le bon répertoire.
Vous installez avec, en root,
Code BASH :
# python3 setup.py install
Il est peu probable que cette archive fonctionne en 32 bits.
Vous devrez installer au moins les rpm suivants :
lib64smpeg0.4_0-0.4.5-8.mga6.x86_64
lib64SDL_ttf2.0_0-2.0.11-8.mga6.x86_64
lib64SDL_mixer1.2_0-1.2.12-10.mga6.x86_64
lib64SDL_image1.2_0-1.2.12-9.mga6.x86_64
lib64mikmod3-3.3.11-1.mga6.x86_64
lib64SDL_ttf2.0_0-2.0.11-8.mga6.x86_64
lib64SDL_mixer1.2_0-1.2.12-10.mga6.x86_64
lib64SDL_image1.2_0-1.2.12-9.mga6.x86_64
lib64mikmod3-3.3.11-1.mga6.x86_64
Construire sa propre version
C'est moins simple. Mais ça vous évite de placer votre confiance en un individu qui rode sur le web.
Utiliser cette version pygame-1.9.2-pre-master.zip.
Il s'agit de la version officielle qu'il faudra adapter à votre système.
Décompresser, ensuite les commandes à exécuter seront :
$ cd /home/dom/tmp/pygame-1.9.2-pre-master
$ python3 ./config.py
$ 2to3 setup.py -w
$ python3 setup.py build
# python3 setup.py install
$ python3 ./config.py
$ 2to3 setup.py -w
$ python3 setup.py build
# python3 setup.py install
Cependant, les dépendances à compléter seront (probablement) considérables.
Dépendances
Code BASH :
urpmi lib64SDL-devel urpmi libSDL_ttf-devel libSDL_image-devel urpmi lib64SDL_mixer-devel urpmi lib64smpeg-devel urpmi lib64portmidi-devel-217-6.mga4.x86_64
Après la commande
Code BASH :
vous aurez probablement des protestations du système.python3 ./config.py
Pour
IMAGE : not found
JPEG : not found
JPEG : not found
Code BASH :
urpmi lib64SDL_image-devel
Pour
AVFORMAT: not found
SWSCALE : not found
SWSCALE : not found
Code BASH :
urpmi lib64ffmpeg-devel-2.4.9-1.mga5.tainted.x86_64
Pour
In file included from src/imageext.c:47:0:
src/pygame.h:80:20: erreur fatale : Python.h : Aucun fichier ou dossier de ce type
src/pygame.h:80:20: erreur fatale : Python.h : Aucun fichier ou dossier de ce type
Corrigé avec
Code BASH :
urpmi lib64python3-devel
Pour info, les dépendances que j'ai dû installer :
Caché :
Code TEXT :
lib64python3.5-testsuite-3.5.3-1.mga6.x86_64 lun. 21 août 2017 16:45:57 CEST python3-docs-3.5.3-1.mga6.noarch lib64python3-devel-3.5.3-1.mga6.x86_64 lib64SDL_mixer-devel-1.2.12-10.mga6.x86_64 lib64SDL_mixer1.2_0-1.2.12-10.mga6.x86_64 lib64mikmod-devel-3.3.11-1.mga6.x86_64 lib64mikmod3-3.3.11-1.mga6.x86_64 lib64flac-devel-1.3.2-1.mga6.x86_64 pango-doc-1.40.6-1.mga6.noarch opencv-devel-2.4.12.3-5.mga6.x86_64 lib64tasn1-devel-4.12-1.mga6.x86_64 lib64gnutls-devel-3.5.13-1.mga6.x86_64 lib64ffmpeg-devel-3.3.3-1.mga6.tainted.x86_64 gnutls-3.5.13-1.mga6.x86_64 lib64x264-devel-0.148-0.20170120.stable.5.mga6.tainted.x86_64 lib64opus-devel-1.1.5-1.mga6.x86_64 lib64opencv_ts2.4-2.4.12.3-5.mga6.x86_64 lib64mp3lame-devel-3.99.5-13.mga6.tainted.x86_64 lib64gtk-gir2.0-2.24.31-3.mga6.x86_64 lib64gtk+2.0-devel-2.24.31-3.mga6.x86_64 lib64gsm-devel-1.0.17-1.mga6.x86_64 lib64gdk_pixbuf2.0-devel-2.36.7-1.mga6.x86_64 lib64xvidcore-devel-1.3.4-3.mga6.tainted.x86_64 lib64x265-devel-2.2-1.mga6.tainted.x86_64 lib64vo-amrwbenc-devel-0.1.3-2.mga6.tainted.x86_64 lib64v4l-devel-1.12.5-1.mga6.x86_64 lib64rtmp-devel-2.4-0.git20160101.3.mga6.tainted.x86_64 lib64pulseaudio-devel-10.0-1.1.mga6.x86_64 lib64pango1.0-devel-1.40.6-1.mga6.x86_64 lib64openexr-devel-2.2.0-10.mga6.x86_64 lib64opencv_videostab2.4-2.4.12.3-5.mga6.x86_64 lib64opencv_superres2.4-2.4.12.3-5.mga6.x86_64 lib64opencv_stitching2.4-2.4.12.3-5.mga6.x86_64 lib64opencv_photo2.4-2.4.12.3-5.mga6.x86_64 lib64opencv_legacy2.4-2.4.12.3-5.mga6.x86_64 lib64opencore-amr-devel-0.1.3-1.mga6.tainted.x86_64 lib64gnutlsxx28-3.5.13-1.mga6.x86_64 lib64opencv_ocl2.4-2.4.12.3-5.mga6.x86_64 lib64opencv_nonfree2.4-2.4.12.3-5.mga6.x86_64 lib64opencv_gpu2.4-2.4.12.3-5.mga6.x86_64 lib64cairo-devel-1.14.10-1.mga6.x86_64 lib64twolame-devel-0.3.13-7.mga6.x86_64 lib64opts25-5.18.6-2.mga6.x86_64 lib64nettle-devel-3.3-1.mga6.x86_64 lib64celt0-devel-0.11.3-6.mga6.x86_64 lib64xrandr-devel-1.5.1-1.mga6.x86_64 lib64xinerama-devel-1.1.3-6.mga6.x86_64 lib64xcomposite-devel-0.4.4-8.mga6.x86_64 lib64xavs-devel-0.1.55-8.mga6.x86_64 lib64vpx-devel-1.5.0-3.mga6.x86_64 lib64vdpau-devel-1.1.1-2.mga6.x86_64 lib64va-devel-1.7.3-3.mga6.x86_64 lib64speex-devel-1.2-0.rc2.2.mga6.x86_64 lib64sdl2.0-devel-2.0.5-2.mga6.x86_64 lib64pixman-devel-0.34.0-1.mga6.x86_64 lib64p11-kit-devel-0.23.2-2.mga6.x86_64 lib64nut-devel-0.0.675-8.mga6.x86_64 lib64modplug-devel-0.8.9.0-1.mga6.x86_64 lib64jasper-devel-1.900.23-5.mga6.x86_64 lib64ilmbase-devel-2.2.0-5.mga6.x86_64 lib64atk1.0-devel-2.24.0-1.mga6.x86_64 lib64xft-devel-2.3.2-4.mga6.x86_64 lib64xcursor-devel-1.1.14-6.mga6.x86_64T lib64vorbis-devel-1.3.5-2.mga6.x86_64 lib64theora-devel-1.1.1-11.mga6.x86_64 lib64thai-devel-0.1.26-1.mga6.x86_64 lib64schroedinger-devel-1.0.11-8.mga6.x86_64 lib64openjpeg-devel-1.5.2-8.mga6.x86_64 lib64opencl-devel-2.2.11-1.mga6.x86_64 lib64jack-devel-1.9.10-6.mga6.x86_64 lib64gstreamer-plugins-base1.0-devel-1.10.4-1.mga6.x86_64 lib64ass-devel-0.13.6-1.mga6.x86_64 orc-0.4.26-1.mga6.x86_64 openjpeg-1.5.2-8.mga6.x86_64 opencl-headers-1.2-1.20150303.1.mga6.noarch lib64xrender-devel-0.9.10-1.mga6.x86_64 lib64usb1.0-devel-1.0.21-1.mga6.x86_64 lib64udf0-0.94-1.mga6.x86_64 lib64samplerate-devel-0.1.9-1.mga6.x86_64 lib64raw1394-devel-2.1.2-1.mga6.x86_64 lib64orc-devel-0.4.26-1.mga6.x86_64 lib64ogg-devel-1.3.2-4.mga6.x86_64 lib64gstreamer-plugins-base-gir1.0-1.10.4-1.mga6.x86_64 lib64gstreamer1.0-devel-1.10.4-1.mga6.x86_64 lib64gst-gir1.0-1.10.4-1.mga6.x86_64 lib64fribidi-devel-0.19.7-3.mga6.x86_64 lib64dc1394-devel-2.2.5-2.mga6.x86_64 lib64datrie-devel-0.2.10-1.mga6.x86_64 lib64cdio-paranoia-devel-10.2.0.93.1-8.mga6.x86_64 lib64cdio-devel-0.94-1.mga6.x86_64 lib64cdio++0-0.94-1.mga6.x86_64 lib64smpeg-devel-0.4.5-8.mga6.x86_64 lib64smpeg0.4_0-0.4.5-8.mga6.x86_64 lib64portmidi-devel-217-10.mga6.x86_64 lib64portmidi0-217-10.mga6.x86_64 lib64tiff-devel-4.0.8-3.mga6.x86_64 lib64SDL_ttf-devel-2.0.11-8.mga6.x86_64 lib64SDL_image-devel-1.2.12-9.mga6.x86_64 lib64jpeg-devel-1.5.1-1.mga6.x86_64 lib64jbig-devel-2.1-4.mga6.x86_64 lib64xxf86dga-devel-1.1.4-6.mga6.x86_64 lib64slang-devel-2.3.0-1.mga6.x86_64 lib64SDL-devel-1.2.15-19.mga6.x86_64 lib64mesaglu1-devel-9.0.0-6.mga6.x86_64 lib64gpm-devel-1.20.7-7.mga6.x86_64 lib64gii-devel-1.0.2-21.mga6.x86_64 lib64ggi-devel-2.2.2-24.mga6.x86_64 lib64alsa2-devel-1.1.4.1-1.mga6.x86_64 lib64aa-devel-1.4.0-0.rc5.31.mga6.x86_64
Bilan
Code BASH :
[meuz@localhost pygame-1.9.2-pre-master]$ python3 ./config.py Using UNIX configuration... Hunting dependencies... SDL : found 1.2.15 FONT : found IMAGE : found MIXER : found SMPEG : found 0.4.5 PNG : found JPEG : found SCRAP : found PORTMIDI: found PORTTIME: found AVFORMAT: found SWSCALE : found FREETYPE: found 2.5.4 If you get compiler errors during install, doublecheck the compiler flags in the "Setup" file.
Donc, c'est bon.
On peut « buider »
Code BASH :
python3 setup.py build
Correction du bug
Car il y a un bug. En fin au moins un.
# bug gcc : Compilation error - can't find -lporttime
Résolu par le lien symbolique.
Code BASH :
ln -s /usr/lib64/libportmidi.so /usr/lib64/libporttime.so
Une fois ce problème réglé, on peut installer (en root)
Code BASH :
# python3 setup.py install
Remarques générales
Les dépendances que j'ai mentionnées sont celles que j'ai relevées au cours de la construction et l'installation du paquet python pygame sur ma machine.
Il est possible, et même probable, que les dépendances soient plus ou moins importantes selon ce qui est déjà installé sur votre machine.
Cette démarche devrait fonctionner en 32 bits, Cependant je ne puis être affirmatif, je le répète, je n'ai fait qu'une installation sous Mageia 5 et 6 en 64 bits.
Webographie
Pygame
Wikipedia Pygame
Problème d’installation de Pygame sous Ubuntu
Meuz