git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #62150 from timokau/pyglet-library-hardcode

python.pkgs.pyglet: hardcode library paths

commit444f22ca892a873f76acd88d5d55bdc24ed08757 authorTimo Kaufmann <timokau@zoho.com> dateTue 28 May 2019, 14:58 (7 years ago) parent02781ac97ec74e
2 files changed+54−6
pkgs/development/python-modules/pyglet/default.nix+50−6 pkgs/development/python-modules/roboschool/default.nix+4
pkgs/development/python-modules/pyglet/default.nix+50−6
@@ -1,5 +1,14 @@
1−{ stdenv, buildPythonPackage, fetchPypi
2−, libGLU_combined, xorg, freetype, fontconfig, future}:
1+{ stdenv
2+, buildPythonPackage
3+, fetchPypi
4+, libGLU_combined
5+, xorg
6+, future
7+, pytest
8+, glibc
9+, gtk2-x11
10+, gdk_pixbuf
11+}:
312
413buildPythonPackage rec {
514 version = "1.3.2";
@@ -10,14 +19,49 @@ buildPythonPackage rec {
1019 sha256 = "b00570e7cdf6971af8953b6ece50d83d13272afa5d1f1197c58c0f478dd17743";
1120 };
1221
22+ # find_library doesn't reliably work with nix (https://github.com/NixOS/nixpkgs/issues/7307).
23+ # Even naively searching `LD_LIBRARY_PATH` won't work since `libc.so` is a linker script and
24+ # ctypes.cdll.LoadLibrary cannot deal with those. Therefore, just hardcode the paths to the
25+ # necessary libraries.
1326 postPatch = let
14− libs = [ libGLU_combined xorg.libX11 freetype fontconfig ];
15− paths = builtins.concatStringsSep "," (map (l: "\"${l}/lib\"") libs);
16− in "sed -i -e 's|directories\.extend.*lib[^]]*|&,${paths}|' pyglet/lib.py";
27+ ext = stdenv.hostPlatform.extensions.sharedLibrary;
28+ in ''
29+ cat > pyglet/lib.py <<EOF
30+ import ctypes
31+ def load_library(*names, **kwargs):
32+ for name in names:
33+ path = None
34+ if name == 'GL':
35+ path = '${libGLU_combined}/lib/libGL${ext}'
36+ elif name == 'GLU':
37+ path = '${libGLU_combined}/lib/libGLU${ext}'
38+ elif name == 'c':
39+ path = '${glibc}/lib/libc${ext}.6'
40+ elif name == 'X11':
41+ path = '${xorg.libX11}/lib/libX11${ext}'
42+ elif name == 'gdk-x11-2.0':
43+ path = '${gtk2-x11}/lib/libgdk-x11-2.0${ext}'
44+ elif name == 'gdk_pixbuf-2.0':
45+ path = '${gdk_pixbuf}/lib/libgdk_pixbuf-2.0${ext}'
46+ if path is not None:
47+ return ctypes.cdll.LoadLibrary(path)
48+ raise Exception("Could not load library {}".format(names))
49+ EOF
50+ '';
1751
52+ propagatedBuildInputs = [ future ];
53+
54+ # needs an X server. Keep an eye on
55+ # https://bitbucket.org/pyglet/pyglet/issues/219/egl-support-headless-rendering
1856 doCheck = false;
1957
20− propagatedBuildInputs = [ future ];
58+ checkInputs = [
59+ pytest
60+ ];
61+
62+ checkPhase = ''
63+ py.test tests/unit tests/integration
64+ '';
2165
2266 meta = with stdenv.lib; {
2367 homepage = "http://www.pyglet.org/";
pkgs/development/python-modules/roboschool/default.nix+4
@@ -1,5 +1,6 @@
11{ lib
22, buildPythonPackage
3+, isPy3k
34, python
45, fetchFromGitHub
56, fetchpatch
@@ -23,6 +24,9 @@ buildPythonPackage rec {
2324 sha256 = "1s7rp5bbiglnrfm33wf7x7kqj0ks3b21bqyz18c5g6vx39rxbrmh";
2425 };
2526
27+ # fails to find boost_python for some reason
28+ disabled = !isPy3k;
29+
2630 propagatedBuildInputs = [
2731 gym
2832 ];