Skip to content

Commit

Permalink
Utils/Hooks: Move opengl_arrays_module to the hook file. Nothing else…
Browse files Browse the repository at this point in the history
… calls it.
  • Loading branch information
Legorooj authored and htgoebel committed May 14, 2020
1 parent 1a3d99e commit c9cbb48
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
27 changes: 25 additions & 2 deletions PyInstaller/hooks/hook-OpenGL.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,31 @@


from PyInstaller.compat import is_win, is_darwin
from PyInstaller.utils.hooks import collect_data_files
from PyInstaller.utils.hooks import opengl_arrays_modules
from PyInstaller.utils.hooks import collect_data_files, exec_statement
import os
import glob


def opengl_arrays_modules():
"""
Return list of array modules for OpenGL module.
e.g. 'OpenGL.arrays.vbo'
"""
statement = 'import OpenGL; print(OpenGL.__path__[0])'
opengl_mod_path = exec_statement(statement)
arrays_mod_path = os.path.join(opengl_mod_path, 'arrays')
files = glob.glob(arrays_mod_path + '/*.py')
modules = []

for f in files:
mod = os.path.splitext(os.path.basename(f))[0]
# Skip __init__ module.
if mod == '__init__':
continue
modules.append('OpenGL.arrays.' + mod)

return modules


# PlatformPlugin performs a conditional import based on os.name and
Expand Down
23 changes: 0 additions & 23 deletions PyInstaller/utils/hooks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,29 +180,6 @@ def get_homebrew_path(formula=''):
return None


# TODO Move to "hooks/hook-OpenGL.py", the only place where this is called.
def opengl_arrays_modules():
"""
Return list of array modules for OpenGL module.
e.g. 'OpenGL.arrays.vbo'
"""
statement = 'import OpenGL; print(OpenGL.__path__[0])'
opengl_mod_path = exec_statement(statement)
arrays_mod_path = os.path.join(opengl_mod_path, 'arrays')
files = glob.glob(arrays_mod_path + '/*.py')
modules = []

for f in files:
mod = os.path.splitext(os.path.basename(f))[0]
# Skip __init__ module.
if mod == '__init__':
continue
modules.append('OpenGL.arrays.' + mod)

return modules


def remove_prefix(string, prefix):
"""
This function removes the given prefix from a string, if the string does
Expand Down

0 comments on commit c9cbb48

Please sign in to comment.