Skip to content

Commit

Permalink
Merge pull request #6497 from peircej/dev
Browse files Browse the repository at this point in the history
PKG: better help for missing standalone packages
  • Loading branch information
peircej committed May 23, 2024
2 parents 650d29f + d9e7a7f commit e187820
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions setupApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,26 @@ def dyld_find(name, loader=None, **kwargs):
packages.remove('PyQt6') # PyQt6 is not compatible with earlier PsychoPy versions

# check the includes and packages are all available
missing_pkgs = []
pip_install_lines = ''
missingPkgs = []
pipInstallLines = ''
packagePipNames = { # packages that are imported as one thing but installed as another
'OpenGL': 'pyopengl',
'opencv': 'opencv-python',
'googleapiclient': 'google-api-python-client',
'macropy': 'macropy3',

}
for pkg in includes+packages:

try:
importlib.import_module(pkg)
except ModuleNotFoundError:
if pkg == 'opencv':
missing_pkgs.append('opencv-python')
elif pkg == 'googleapiclient':
missing_pkgs.append('google-api-python-client')
if pkg in packagePipNames:
missingPkgs.append(packagePipNames[pkg])
elif pkg == 'pylink':
pip_install_lines += 'pip install --index-url=https://pypi.sr-support.com sr-research-pylink\n'
pipInstallLines += 'pip install --index-url=https://pypi.sr-support.com sr-research-pylink\n'
else:
missing_pkgs.append(pkg)
missingPkgs.append(pkg)
except OSError as err:
if 'libftd2xx.dylib' in str(err):
raise ImportError(f"Missing package: ftd2xx. Please install the FTDI D2XX drivers from "
Expand All @@ -161,10 +166,12 @@ def dyld_find(name, loader=None, **kwargs):
raise ImportError(f"It looks like the Eyelink dev kit is not installed "
"https://www.sr-research.com/support/thread-13.html")

if missing_pkgs:

helpStr =
raise ImportError(f"Missing packages: {' '.join(missing_pkgs)}")
if missingPkgs or pipInstallLines:
helpStr = f"You're missing some packages to include in standalone. Fix with:\n"
if missingPkgs:
helpStr += f"pip install {' '.join(missingPkgs)}\n"
helpStr += pipInstallLines
raise ImportError(helpStr)
else:
print("All packages appear to be present. Proceeding to build...")

Expand Down

0 comments on commit e187820

Please sign in to comment.