Merge pull request #133692 from angustrau/pygame-darwin
This commit is contained in:
commit
d9401a02e5
@ -1,6 +1,6 @@
|
||||
{ lib, fetchPypi, buildPythonPackage, python, pkg-config, libX11
|
||||
, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, libpng, libjpeg, portmidi, freetype
|
||||
, fontconfig
|
||||
{ stdenv, lib, substituteAll, fetchPypi, buildPythonPackage, python, pkg-config, libX11
|
||||
, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, libpng, libjpeg, portmidi, freetype, fontconfig
|
||||
, AppKit, CoreMIDI
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
@ -12,6 +12,27 @@ buildPythonPackage rec {
|
||||
sha256 = "8b1e7b63f47aafcdd8849933b206778747ef1802bd3d526aca45ed77141e4001";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# Patch pygame's dependency resolution to let it find build inputs
|
||||
(substituteAll {
|
||||
src = ./fix-dependency-finding.patch;
|
||||
buildinputs_include = builtins.toJSON (builtins.concatMap (dep: [
|
||||
"${lib.getDev dep}/"
|
||||
"${lib.getDev dep}/include"
|
||||
]) buildInputs);
|
||||
buildinputs_lib = builtins.toJSON (builtins.concatMap (dep: [
|
||||
"${lib.getLib dep}/"
|
||||
"${lib.getLib dep}/lib"
|
||||
]) buildInputs);
|
||||
})
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace src_py/sysfont.py \
|
||||
--replace 'path="fc-list"' 'path="${fontconfig}/bin/fc-list"' \
|
||||
--replace /usr/X11/bin/fc-list ${fontconfig}/bin/fc-list
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config SDL2
|
||||
];
|
||||
@ -19,37 +40,33 @@ buildPythonPackage rec {
|
||||
buildInputs = [
|
||||
SDL2 SDL2_image SDL2_mixer SDL2_ttf libpng libjpeg
|
||||
portmidi libX11 freetype
|
||||
] ++ lib.optionals stdenv.isDarwin [
|
||||
AppKit CoreMIDI
|
||||
];
|
||||
|
||||
preConfigure = ''
|
||||
sed \
|
||||
-e "s/origincdirs = .*/origincdirs = []/" \
|
||||
-e "s/origlibdirs = .*/origlibdirs = []/" \
|
||||
-e "/linux-gnu/d" \
|
||||
-i buildconfig/config_unix.py
|
||||
${lib.concatMapStrings (dep: ''
|
||||
sed \
|
||||
-e "/origincdirs =/a\ origincdirs += ['${lib.getDev dep}/include']" \
|
||||
-e "/origlibdirs =/a\ origlibdirs += ['${lib.getLib dep}/lib']" \
|
||||
-i buildconfig/config_unix.py
|
||||
'') buildInputs
|
||||
}
|
||||
LOCALBASE=/ ${python.interpreter} buildconfig/config.py
|
||||
'';
|
||||
|
||||
checkInputs = [ fontconfig ];
|
||||
checkPhase = ''
|
||||
runHook preCheck
|
||||
|
||||
preCheck = ''
|
||||
# No audio or video device in test environment
|
||||
export SDL_VIDEODRIVER=dummy
|
||||
export SDL_AUDIODRIVER=disk
|
||||
export SDL_DISKAUDIOFILE=/dev/null
|
||||
|
||||
${python.interpreter} -m pygame.tests -v --exclude opengl,timing --time_out 300
|
||||
|
||||
runHook postCheck
|
||||
'';
|
||||
pythonImportsCheck = [ "pygame" ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Python library for games";
|
||||
homepage = "https://www.pygame.org/";
|
||||
license = licenses.lgpl21Plus;
|
||||
platforms = platforms.linux;
|
||||
maintainers = with maintainers; [ angustrau ];
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,64 @@
|
||||
diff --git a/buildconfig/config_darwin.py b/buildconfig/config_darwin.py
|
||||
index 8d84683f..70df8f9c 100644
|
||||
--- a/buildconfig/config_darwin.py
|
||||
+++ b/buildconfig/config_darwin.py
|
||||
@@ -56,10 +56,10 @@ class Dependency:
|
||||
class FrameworkDependency(Dependency):
|
||||
def configure(self, incdirs, libdirs):
|
||||
BASE_DIRS = '/', os.path.expanduser('~/'), '/System/'
|
||||
- for n in BASE_DIRS:
|
||||
+ for n in incdirs + libdirs:
|
||||
n += 'Library/Frameworks/'
|
||||
fmwk = n + self.libs + '.framework/Versions/Current/'
|
||||
- if os.path.isfile(fmwk + self.libs):
|
||||
+ if os.path.isfile(fmwk + self.libs + '.tbd'):
|
||||
print ('Framework ' + self.libs + ' found')
|
||||
self.found = 1
|
||||
self.inc_dir = fmwk + 'Headers'
|
||||
@@ -158,19 +158,8 @@ def main(sdl2=False):
|
||||
])
|
||||
|
||||
print ('Hunting dependencies...')
|
||||
- incdirs = ['/usr/local/include']
|
||||
- if sdl2:
|
||||
- incdirs.append('/usr/local/include/SDL2')
|
||||
- else:
|
||||
- incdirs.append('/usr/local/include/SDL')
|
||||
-
|
||||
- incdirs.extend([
|
||||
- #'/usr/X11/include',
|
||||
- '/opt/local/include',
|
||||
- '/opt/local/include/freetype2/freetype']
|
||||
- )
|
||||
- #libdirs = ['/usr/local/lib', '/usr/X11/lib', '/opt/local/lib']
|
||||
- libdirs = ['/usr/local/lib', '/opt/local/lib']
|
||||
+ incdirs = @buildinputs_include@
|
||||
+ libdirs = @buildinputs_lib@
|
||||
|
||||
for d in DEPS:
|
||||
if isinstance(d, (list, tuple)):
|
||||
diff --git a/buildconfig/config_unix.py b/buildconfig/config_unix.py
|
||||
index f6a4ea4b..f7f5be76 100644
|
||||
--- a/buildconfig/config_unix.py
|
||||
+++ b/buildconfig/config_unix.py
|
||||
@@ -224,18 +224,8 @@ def main(sdl2=False):
|
||||
if not DEPS[0].found:
|
||||
raise RuntimeError('Unable to run "sdl-config". Please make sure a development version of SDL is installed.')
|
||||
|
||||
- incdirs = []
|
||||
- libdirs = []
|
||||
- for extrabase in extrabases:
|
||||
- incdirs += [extrabase + d for d in origincdirs]
|
||||
- libdirs += [extrabase + d for d in origlibdirs]
|
||||
- incdirs += ["/usr"+d for d in origincdirs]
|
||||
- libdirs += ["/usr"+d for d in origlibdirs]
|
||||
- incdirs += ["/usr/local"+d for d in origincdirs]
|
||||
- libdirs += ["/usr/local"+d for d in origlibdirs]
|
||||
- if localbase:
|
||||
- incdirs = [localbase+d for d in origincdirs]
|
||||
- libdirs = [localbase+d for d in origlibdirs]
|
||||
+ incdirs = @buildinputs_include@
|
||||
+ libdirs = @buildinputs_lib@
|
||||
|
||||
for arg in DEPS[0].cflags.split():
|
||||
if arg[:2] == '-I':
|
@ -6079,7 +6079,9 @@ in {
|
||||
|
||||
pygal = callPackage ../development/python-modules/pygal { };
|
||||
|
||||
pygame = callPackage ../development/python-modules/pygame { };
|
||||
pygame = callPackage ../development/python-modules/pygame {
|
||||
inherit (pkgs.darwin.apple_sdk.frameworks) AppKit CoreMIDI;
|
||||
};
|
||||
|
||||
pygame_sdl2 = callPackage ../development/python-modules/pygame_sdl2 { };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user