Skip to content

Commit

Permalink
Merge pull request #2091 from pupil-labs/develop
Browse files Browse the repository at this point in the history
Pupil v3.1 Release Candidate 1
  • Loading branch information
papr authored Jan 21, 2021
2 parents d01e26b + 91d2173 commit 8f48609
Show file tree
Hide file tree
Showing 34 changed files with 400 additions and 72 deletions.
6 changes: 5 additions & 1 deletion deployment/bundle_macos.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash
#!/usr/local/bin/zsh

pl_codesign () {
sign="Developer ID Application: Pupil Labs UG (haftungsbeschrankt) (R55K9ESN6B)"
codesign \
--all-architectures \
--force \
--strict=all \
--options runtime \
--entitlements entitlements.plist \
--continue \
Expand Down Expand Up @@ -42,6 +45,7 @@ mv dist/*.$ext ../$release_dir
cd ..

printf "\n##########\nSigning applications\n##########\n"
pl_codesign $release_dir/*.$ext/Contents/Resources/**/.dylibs/*.dylib
pl_codesign $release_dir/*.$ext

printf "\n##########\nCreating dmg file\n##########\n"
Expand Down
2 changes: 1 addition & 1 deletion deployment/deploy_capture/bundle.spec
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if platform.system() == "Darwin":
pathex=["../../pupil_src/shared_modules/"],
hiddenimports=hidden_imports,
hookspath=None,
runtime_hooks=None,
runtime_hooks=["../find_opengl_bigsur.py"],
excludes=["matplotlib"],
datas=data_files_pye3d,
)
Expand Down
2 changes: 1 addition & 1 deletion deployment/deploy_player/bundle.spec
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ if platform.system() == "Darwin":
pathex=["../../pupil_src/shared_modules/"],
hiddenimports=hidden_imports,
hookspath=None,
runtime_hooks=None,
runtime_hooks=["../find_opengl_bigsur.py"],
excludes=["matplotlib"],
datas=data_files_pye3d,
)
Expand Down
2 changes: 1 addition & 1 deletion deployment/deploy_service/bundle.spec
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if platform.system() == "Darwin":
pathex=["../../pupil_src/shared_modules/"],
hiddenimports=hidden_imports,
hookspath=None,
runtime_hooks=None,
runtime_hooks=["../find_opengl_bigsur.py"],
excludes=["matplotlib"],
datas=data_files_pye3d,
)
Expand Down
23 changes: 23 additions & 0 deletions deployment/find_opengl_bigsur.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import ctypes.util
import functools


print("Attempting to import OpenGL using patched `ctypes.util.find_library`...")
_find_library_original = ctypes.util.find_library

@functools.wraps(_find_library_original)
def _find_library_patched(name):
if name == "OpenGL":
return "/System/Library/Frameworks/OpenGL.framework/OpenGL"
else:
return _find_library_original(name)

ctypes.util.find_library = _find_library_patched

import OpenGL.GL

print("OpenGL import successful!")
print("Restoring original `ctypes.util.find_library`...")
ctypes.util.find_library = _find_library_original
del _find_library_patched
print("Original `ctypes.util.find_library` restored.")
3 changes: 2 additions & 1 deletion pupil_src/launchables/eye.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ def eye(

# display
import glfw
from gl_utils import GLFWErrorReporting

glfw.ERROR_REPORTING = "raise"
GLFWErrorReporting.set_default()

from pyglui import ui, graph, cygl
from pyglui.cygl.utils import draw_points, RGBA, draw_polyline
Expand Down
9 changes: 5 additions & 4 deletions pupil_src/launchables/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ def player(

# display
import glfw
from gl_utils import GLFWErrorReporting

glfw.ERROR_REPORTING = "raise"
GLFWErrorReporting.set_default()

# check versions for our own depedencies as they are fast-changing
from pyglui import __version__ as pyglui_version
Expand Down Expand Up @@ -137,7 +138,7 @@ def player(
)

assert parse_version(pyglui_version) >= parse_version(
"1.28"
"1.29"
), "pyglui out of date, please upgrade to newest version"

process_was_interrupted = False
Expand Down Expand Up @@ -374,7 +375,6 @@ def get_dt():
glfw.init()
glfw.window_hint(glfw.SCALE_TO_MONITOR, glfw.TRUE)
main_window = glfw.create_window(width, height, window_name, None, None)

window_position_manager = gl_utils.WindowPositionManager()
window_pos = window_position_manager.new_window_position(
window=main_window,
Expand Down Expand Up @@ -808,8 +808,9 @@ def player_drop(

try:
import glfw
from gl_utils import GLFWErrorReporting

glfw.ERROR_REPORTING = "raise"
GLFWErrorReporting.set_default()

import gl_utils
from OpenGL.GL import glClearColor
Expand Down
3 changes: 2 additions & 1 deletion pupil_src/launchables/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ def detection_enabled_setter(is_on: bool):

# display
import glfw
from gl_utils import GLFWErrorReporting

glfw.ERROR_REPORTING = "raise"
GLFWErrorReporting.set_default()

from version_utils import parse_version
from pyglui import ui, cygl, __version__ as pyglui_version
Expand Down
6 changes: 5 additions & 1 deletion pupil_src/shared_modules/audio_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ def _load_audio_single(file_path, return_pts_based_timestamps=False):
),
dtype=float,
)
container.seek(0)
try:
container.seek(0)
except av.AVError as err:
logger.debug(f"{err}")
return None

return LoadedAudio(container, stream, timestamps)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import typing as T

import glfw
from gl_utils import GLFWErrorReporting

glfw.ERROR_REPORTING = "raise"
GLFWErrorReporting.set_default()

try:
from typing import OrderedDict as T_OrderedDict # Python 3.7.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import OpenGL.GL as gl
import glfw

glfw.ERROR_REPORTING = "raise"

import gl_utils
from gl_utils import GLFWErrorReporting

GLFWErrorReporting.set_default()

from pyglui.cygl.utils import draw_polyline

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
import numpy as np

import glfw
from gl_utils import GLFWErrorReporting

glfw.ERROR_REPORTING = "raise"
GLFWErrorReporting.set_default()

from methods import normalize
from pyglui import ui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import OpenGL.GL as gl

import glfw
from gl_utils import GLFWErrorReporting

glfw.ERROR_REPORTING = "raise"
GLFWErrorReporting.set_default()

from circle_detector import CircleTracker
from platform import system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
import OpenGL.GL as gl

import glfw
from gl_utils import GLFWErrorReporting

glfw.ERROR_REPORTING = "raise"
GLFWErrorReporting.set_default()

from .mixin import MonitorSelectionMixin
from .controller import (
Expand Down
6 changes: 3 additions & 3 deletions pupil_src/shared_modules/camera_intrinsics_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
from pyglui.ui import get_opensans_font_path

import glfw

glfw.ERROR_REPORTING = "raise"

import gl_utils
from gl_utils import GLFWErrorReporting

GLFWErrorReporting.set_default()

from plugin import Plugin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
import numpy as np

import glfw
from gl_utils import GLFWErrorReporting

glfw.ERROR_REPORTING = "raise"
GLFWErrorReporting.set_default()

import tasklib
from gaze_producer import model, worker
Expand Down
1 change: 1 addition & 0 deletions pupil_src/shared_modules/gl_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
make_coord_system_norm_based,
make_coord_system_pixel_based,
window_coordinate_to_framebuffer_coordinate,
GLFWErrorReporting,
)
from .window_position_manager import WindowPositionManager
58 changes: 56 additions & 2 deletions pupil_src/shared_modules/gl_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
See COPYING and COPYING.LESSER for license details.
---------------------------------------------------------------------------~(*)
"""
import contextlib
import logging
import math
import typing as T
Expand Down Expand Up @@ -41,8 +42,6 @@
)
from OpenGL.GLU import gluErrorString, gluPerspective

glfw.ERROR_REPORTING = "raise"

# OpenGL.FULL_LOGGING = True
OpenGL.ERROR_LOGGING = False

Expand Down Expand Up @@ -330,3 +329,58 @@ def get_window_title_bar_rect(window) -> _Rectangle:
return _Rectangle(
x=frame_rect.x, y=frame_rect.y, width=frame_rect.width, height=frame_edges.top
)


_GLFWErrorReportingDict = T.Dict[T.Union[None, int], str]


class GLFWErrorReporting:
@classmethod
@contextlib.contextmanager
def error_code_handling(
cls,
*_,
ignore: T.Optional[T.Tuple[int]] = None,
debug: T.Optional[T.Tuple[int]] = None,
warn: T.Optional[T.Tuple[int]] = None,
raise_: T.Optional[T.Tuple[int]] = None,
):
old_reporting = glfw.ERROR_REPORTING

if isinstance(old_reporting, dict):
new_reporting: _GLFWErrorReportingDict = dict(old_reporting)
else:
new_reporting = cls.__default_error_reporting()

new_reporting.update({err_code: "ignore" for err_code in ignore or ()})
new_reporting.update({err_code: "log" for err_code in debug or ()})
new_reporting.update({err_code: "warn" for err_code in warn or ()})
new_reporting.update({err_code: "raise" for err_code in raise_ or ()})

glfw.ERROR_REPORTING = new_reporting

try:
yield
finally:
glfw.ERROR_REPORTING = old_reporting

@classmethod
def set_default(cls):
glfw.ERROR_REPORTING = cls.__default_error_reporting()

### Private

@staticmethod
def __default_error_reporting() -> _GLFWErrorReportingDict:
ignore = [
# GLFWError: (65544) b'Cocoa: Failed to find service port for display'
# This happens on macOS Big Sur running on Apple Silicone hardware
65544,
]
return {
None: "raise",
**{code: "log" for code in ignore},
}


GLFWErrorReporting.set_default()
6 changes: 3 additions & 3 deletions pupil_src/shared_modules/gl_utils/window_position_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import typing as T

import glfw

glfw.ERROR_REPORTING = "raise"

import gl_utils
from .utils import GLFWErrorReporting

GLFWErrorReporting.set_default()


class WindowPositionManager:
Expand Down
3 changes: 2 additions & 1 deletion pupil_src/shared_modules/head_pose_tracker/ui/gl_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

import gl_utils
import glfw
from gl_utils import GLFWErrorReporting

glfw.ERROR_REPORTING = "raise"
GLFWErrorReporting.set_default()

from observable import Observable

Expand Down
6 changes: 3 additions & 3 deletions pupil_src/shared_modules/log_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
from pyglui.pyfontstash import fontstash
from pyglui.ui import get_opensans_font_path
import glfw

glfw.ERROR_REPORTING = "raise"

import gl_utils
from gl_utils import GLFWErrorReporting

GLFWErrorReporting.set_default()


def color_from_level(lvl):
Expand Down
3 changes: 2 additions & 1 deletion pupil_src/shared_modules/marker_auto_trim_marks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
)

import glfw
from gl_utils import GLFWErrorReporting

glfw.ERROR_REPORTING = "raise"
GLFWErrorReporting.set_default()

import numpy as np
from itertools import groupby
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@

import glfw

glfw.ERROR_REPORTING = "raise"

from gl_utils import (
adjust_gl_view,
basic_gl_setup,
clear_gl_screen,
make_coord_system_norm_based,
make_coord_system_pixel_based,
GLFWErrorReporting,
)

GLFWErrorReporting.set_default()

from methods import normalize
from plugin import Plugin

Expand Down
Loading

0 comments on commit 8f48609

Please sign in to comment.