Skip to content

Commit c86514b

Browse files
authored
Merge pull request #2015 from pupil-labs/pyglfw-external-dependency
Replace internal GLFW bindings with pyGLFW
2 parents a948e38 + 1ca1388 commit c86514b

34 files changed

+653
-1263
lines changed

.travis/run_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ python -m pip install -U pip
33
pip install -U git+https://github.com/pupil-labs/pyndsi
44
pip install -U git+https://github.com/pupil-labs/PyAV
55
pip install scikit-learn
6+
pip install glfw
67

78
pip install pytest==5.2.2
89
pytest

deployment/deploy_capture/bundle.spec

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# -*- mode: python -*-
22

33

4-
import platform, sys, os, os.path, numpy, glob, pathlib
4+
import glob
5+
import os
6+
import os.path
7+
import pathlib
8+
import platform
9+
import sys
10+
11+
import numpy
12+
import pkg_resources
513
from PyInstaller.utils.hooks import collect_submodules
614

715
hidden_imports = []
@@ -14,8 +22,9 @@ hidden_imports += collect_submodules("pyglui")
1422
hidden_imports += collect_submodules("pupil_apriltags")
1523
hidden_imports += collect_submodules("sklearn")
1624

17-
from pyglui import ui
25+
import glfw
1826
import pupil_apriltags
27+
from pyglui import ui
1928

2029
apriltag_lib_path = pathlib.Path(pupil_apriltags.__file__).parent
2130

@@ -25,6 +34,12 @@ def apriltag_relative_path(absolute_path):
2534
return os.path.join(*absolute_path.parts[-3:])
2635

2736

37+
glfw_name = glfw._glfw._name
38+
glfw_path = pathlib.Path(glfw_name)
39+
if not glfw_path.exists():
40+
glfw_path = pathlib.Path(pkg_resources.resource_filename("glfw", glfw_name))
41+
glfw_binaries = [(glfw_path.name, str(glfw_path), "BINARY")]
42+
2843
if platform.system() == "Darwin":
2944
sys.path.append(".")
3045
from version import pupil_version
@@ -63,11 +78,11 @@ if platform.system() == "Darwin":
6378
a.binaries - libSystem,
6479
a.zipfiles,
6580
a.datas,
66-
[("libglfw.dylib", "/usr/local/lib/libglfw.dylib", "BINARY")],
6781
[("pyglui/OpenSans-Regular.ttf", ui.get_opensans_font_path(), "DATA")],
6882
[("pyglui/Roboto-Regular.ttf", ui.get_roboto_font_path(), "DATA")],
6983
[("pyglui/pupil_icons.ttf", ui.get_pupil_icons_font_path(), "DATA")],
7084
apriltag_libs,
85+
glfw_binaries,
7186
strip=None,
7287
upx=True,
7388
name="Pupil Capture",
@@ -125,19 +140,21 @@ elif platform.system() == "Linux":
125140
binaries,
126141
a.zipfiles,
127142
a.datas,
128-
[("libglfw.so", "/usr/local/lib/libglfw.so", "BINARY")],
129143
[("libGLEW.so", "/usr/lib/x86_64-linux-gnu/libGLEW.so", "BINARY")],
130144
[("pyglui/OpenSans-Regular.ttf", ui.get_opensans_font_path(), "DATA")],
131145
[("pyglui/Roboto-Regular.ttf", ui.get_roboto_font_path(), "DATA")],
132146
[("pyglui/pupil_icons.ttf", ui.get_pupil_icons_font_path(), "DATA")],
133147
apriltag_libs,
148+
glfw_binaries,
134149
strip=True,
135150
upx=True,
136151
name="pupil_capture",
137152
)
138153

139154
elif platform.system() == "Windows":
140-
import sys, os, os.path
155+
import os
156+
import os.path
157+
import sys
141158

142159
np_path = os.path.dirname(numpy.__file__)
143160
np_dlls = glob.glob(np_path + "/core/*.dll")
@@ -194,11 +211,11 @@ elif platform.system() == "Windows":
194211
a.zipfiles,
195212
a.datas,
196213
[("PupilDrvInst.exe", "../../pupil_external/PupilDrvInst.exe", "BINARY")],
197-
[("glfw3.dll", "../../pupil_external/glfw3.dll", "BINARY")],
198214
[("pyglui/OpenSans-Regular.ttf", ui.get_opensans_font_path(), "DATA")],
199215
[("pyglui/Roboto-Regular.ttf", ui.get_roboto_font_path(), "DATA")],
200216
[("pyglui/pupil_icons.ttf", ui.get_pupil_icons_font_path(), "DATA")],
201217
apriltag_libs,
218+
glfw_binaries,
202219
vc_redist_libs,
203220
np_dll_list,
204221
strip=False,

deployment/deploy_player/bundle.spec

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# -*- mode: python -*-
22

33

4-
import platform, sys, os, os.path, zmq, glob, numpy, pathlib
4+
import glob
5+
import os
6+
import os.path
7+
import pathlib
8+
import platform
9+
import sys
10+
11+
import numpy
12+
import pkg_resources
513
from PyInstaller.utils.hooks import collect_submodules
614

715
hidden_imports = []
@@ -14,8 +22,9 @@ hidden_imports += collect_submodules("pyglui")
1422
hidden_imports += collect_submodules("pupil_apriltags")
1523
hidden_imports += collect_submodules("sklearn")
1624

17-
from pyglui import ui
25+
import glfw
1826
import pupil_apriltags
27+
from pyglui import ui
1928

2029
apriltag_lib_path = pathlib.Path(pupil_apriltags.__file__).parent
2130

@@ -25,6 +34,12 @@ def apriltag_relative_path(absolute_path):
2534
return os.path.join(*absolute_path.parts[-3:])
2635

2736

37+
glfw_name = glfw._glfw._name
38+
glfw_path = pathlib.Path(glfw_name)
39+
if not glfw_path.exists():
40+
glfw_path = pathlib.Path(pkg_resources.resource_filename("glfw", glfw_name))
41+
glfw_binaries = [(glfw_path.name, str(glfw_path), "BINARY")]
42+
2843
if platform.system() == "Darwin":
2944
sys.path.append(".")
3045
from version import pupil_version
@@ -64,11 +79,11 @@ if platform.system() == "Darwin":
6479
a.binaries - libSystem,
6580
a.zipfiles,
6681
a.datas,
67-
[("libglfw.dylib", "/usr/local/lib/libglfw.dylib", "BINARY")],
6882
[("pyglui/OpenSans-Regular.ttf", ui.get_opensans_font_path(), "DATA")],
6983
[("pyglui/Roboto-Regular.ttf", ui.get_roboto_font_path(), "DATA")],
7084
[("pyglui/pupil_icons.ttf", ui.get_pupil_icons_font_path(), "DATA")],
7185
apriltag_libs,
86+
glfw_binaries,
7287
strip=None,
7388
upx=True,
7489
name="Pupil Player",
@@ -127,19 +142,21 @@ elif platform.system() == "Linux":
127142
binaries,
128143
a.zipfiles,
129144
a.datas,
130-
[("libglfw.so", "/usr/local/lib/libglfw.so", "BINARY")],
131145
[("libGLEW.so", "/usr/lib/x86_64-linux-gnu/libGLEW.so", "BINARY")],
132146
[("pyglui/OpenSans-Regular.ttf", ui.get_opensans_font_path(), "DATA")],
133147
[("pyglui/Roboto-Regular.ttf", ui.get_roboto_font_path(), "DATA")],
134148
[("pyglui/pupil_icons.ttf", ui.get_pupil_icons_font_path(), "DATA")],
135149
apriltag_libs,
150+
glfw_binaries,
136151
strip=True,
137152
upx=True,
138153
name="pupil_player",
139154
)
140155

141156
elif platform.system() == "Windows":
142-
import sys, os, os.path
157+
import os
158+
import os.path
159+
import sys
143160

144161
np_path = os.path.dirname(numpy.__file__)
145162
np_dlls = glob.glob(np_path + "/core/*.dll")
@@ -191,11 +208,11 @@ elif platform.system() == "Windows":
191208
a.binaries,
192209
a.zipfiles,
193210
a.datas,
194-
[("glfw3.dll", "../../pupil_external/glfw3.dll", "BINARY")],
195211
[("pyglui/OpenSans-Regular.ttf", ui.get_opensans_font_path(), "DATA")],
196212
[("pyglui/Roboto-Regular.ttf", ui.get_roboto_font_path(), "DATA")],
197213
[("pyglui/pupil_icons.ttf", ui.get_pupil_icons_font_path(), "DATA")],
198214
apriltag_libs,
215+
glfw_binaries,
199216
vc_redist_libs,
200217
np_dll_list,
201218
strip=None,

deployment/deploy_service/bundle.spec

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# -*- mode: python -*-
22

33

4-
import platform, sys, os, os.path, numpy, glob, pathlib
4+
import glob
5+
import os
6+
import os.path
7+
import pathlib
8+
import platform
9+
import sys
10+
11+
import numpy
12+
import pkg_resources
513
from PyInstaller.utils.hooks import collect_submodules
614

715
hidden_imports = []
@@ -13,8 +21,15 @@ if platform.system() != "Windows":
1321
hidden_imports += collect_submodules("pyglui")
1422
hidden_imports += collect_submodules("sklearn")
1523

24+
import glfw
1625
from pyglui import ui
1726

27+
glfw_name = glfw._glfw._name
28+
glfw_path = pathlib.Path(glfw_name)
29+
if not glfw_path.exists():
30+
glfw_path = pathlib.Path(pkg_resources.resource_filename("glfw", glfw_name))
31+
glfw_binaries = [(glfw_path.name, str(glfw_path), "BINARY")]
32+
1833
if platform.system() == "Darwin":
1934
sys.path.append(".")
2035
from version import pupil_version
@@ -48,10 +63,10 @@ if platform.system() == "Darwin":
4863
a.binaries - libSystem,
4964
a.zipfiles,
5065
a.datas,
51-
[("libglfw.dylib", "/usr/local/lib/libglfw.dylib", "BINARY")],
5266
[("pyglui/OpenSans-Regular.ttf", ui.get_opensans_font_path(), "DATA")],
5367
[("pyglui/Roboto-Regular.ttf", ui.get_roboto_font_path(), "DATA")],
5468
[("pyglui/pupil_icons.ttf", ui.get_pupil_icons_font_path(), "DATA")],
69+
glfw_binaries,
5570
strip=None,
5671
upx=True,
5772
name="Pupil Service",
@@ -105,18 +120,20 @@ elif platform.system() == "Linux":
105120
binaries,
106121
a.zipfiles,
107122
a.datas,
108-
[("libglfw.so", "/usr/local/lib/libglfw.so", "BINARY")],
109123
[("libGLEW.so", "/usr/lib/x86_64-linux-gnu/libGLEW.so", "BINARY")],
110124
[("pyglui/OpenSans-Regular.ttf", ui.get_opensans_font_path(), "DATA")],
111125
[("pyglui/Roboto-Regular.ttf", ui.get_roboto_font_path(), "DATA")],
112126
[("pyglui/pupil_icons.ttf", ui.get_pupil_icons_font_path(), "DATA")],
127+
glfw_binaries,
113128
strip=True,
114129
upx=True,
115130
name="pupil_service",
116131
)
117132

118133
elif platform.system() == "Windows":
119-
import sys, os, os.path
134+
import os
135+
import os.path
136+
import sys
120137

121138
np_path = os.path.dirname(numpy.__file__)
122139
np_dlls = glob.glob(np_path + "/core/*.dll")
@@ -168,10 +185,10 @@ elif platform.system() == "Windows":
168185
a.zipfiles,
169186
a.datas,
170187
[("PupilDrvInst.exe", "../../pupil_external/PupilDrvInst.exe", "BINARY")],
171-
[("glfw3.dll", "../../pupil_external/glfw3.dll", "BINARY")],
172188
[("pyglui/OpenSans-Regular.ttf", ui.get_opensans_font_path(), "DATA")],
173189
[("pyglui/Roboto-Regular.ttf", ui.get_roboto_font_path(), "DATA")],
174190
[("pyglui/pupil_icons.ttf", ui.get_pupil_icons_font_path(), "DATA")],
191+
glfw_binaries,
175192
np_dll_list,
176193
vc_redist_libs,
177194
strip=False,

docs/dependencies-macos.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ brew install portaudio
4646
# tbb is included by default with https://github.com/Homebrew/homebrew-core/pull/20101
4747
brew install opencv
4848
brew install glew
49-
brew install glfw3
5049
# dependencies for 2d_3d c++ detector
5150
brew install ceres-solver
5251
```
@@ -80,6 +79,7 @@ pip install pyopengl
8079
pip install pyzmq
8180
pip install scikit-learn
8281
pip install scipy
82+
pip install glfw
8383
pip install git+https://github.com/zeromq/pyre
8484

8585
pip install pupil-apriltags

docs/dependencies-ubuntu17.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Pupil requires Python 3.6 or higher. Please check this [resource](https://askubu
99

1010
```sh
1111
sudo apt-get update
12-
sudo apt install -y pkg-config git cmake build-essential nasm wget python3-setuptools libusb-1.0-0-dev python3-dev python3-pip python3-numpy python3-scipy libglew-dev libglfw3-dev libtbb-dev
12+
sudo apt install -y pkg-config git cmake build-essential nasm wget python3-setuptools libusb-1.0-0-dev python3-dev python3-pip python3-numpy python3-scipy libglew-dev libtbb-dev
1313
```
1414

1515
## ffmpeg3
@@ -169,6 +169,7 @@ pip install pyopengl
169169
pip install pyzmq
170170
pip install scikit-learn
171171
pip install scipy
172+
pip install glfw
172173
pip install git+https://github.com/zeromq/pyre
173174
174175
pip install pupil-apriltags

docs/dependencies-ubuntu18.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Most of this works via **apt**! Just copy paste into the terminal and listen to
77
## General Dependencies
88

99
```sh
10-
sudo apt install -y pkg-config git cmake build-essential nasm wget python3-setuptools libusb-1.0-0-dev python3-dev python3-pip python3-numpy python3-scipy libglew-dev libglfw3-dev libtbb-dev
10+
sudo apt install -y pkg-config git cmake build-essential nasm wget python3-setuptools libusb-1.0-0-dev python3-dev python3-pip python3-numpy python3-scipy libglew-dev libtbb-dev
1111

1212
# ffmpeg >= 3.2
1313
sudo apt install -y libavformat-dev libavcodec-dev libavdevice-dev libavutil-dev libswscale-dev libavresample-dev ffmpeg x264 x265 libportaudio2 portaudio19-dev
@@ -80,6 +80,7 @@ pip install pyopengl
8080
pip install pyzmq
8181
pip install scikit-learn
8282
pip install scipy
83+
pip install glfw
8384
pip install git+https://github.com/zeromq/pyre
8485
8586
pip install pupil-apriltags

docs/dependencies-windows.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ pip install pyopengl
6868
pip install pyzmq
6969
pip install scikit-learn
7070
pip install scipy
71+
pip install glfw
7172
pip install win_inet_pton
7273
pip install git+https://github.com/zeromq/pyre
7374

@@ -121,12 +122,6 @@ The following steps require you to store dynamic libraries in the `pupil_externa
121122
- Unzip GLEW in your work dir
122123
- Copy `glew32.dll` to `pupil_external`
123124

124-
#### GLFW
125-
126-
- Download GLFW Windows binaries from [glfw.org](http://www.glfw.org/download.html)
127-
- Unzip GLFW to your work dir
128-
- Copy `glfw3.dll` from `lib-vc2015` to `pupil_external`
129-
130125
#### FFMPEG
131126

132127
- Download FFMPEG v4.0 Windows shared binaries from [ffmpeg](http://ffmpeg.zeranoe.com/builds/)

0 commit comments

Comments
 (0)