Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/macos #9

Merged
merged 4 commits into from
Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a sanity check for the python2 installation.
  • Loading branch information
mathiasburger committed Feb 8, 2019
commit 33bc576cd886607dc2eba821af84ddf1ddec008b
2 changes: 2 additions & 0 deletions requirements-python2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numpy>=1.10
typing
32 changes: 32 additions & 0 deletions sanity-check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
import re
import shutil
import subprocess


class GimpInstallationException(Exception):
pass


if __name__ == '__main__':
python = shutil.which('python2')
if python is None:
raise GimpInstallationException('Could not find a python2 installation.')
proc = subprocess.Popen(
[python],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)

requirements = open(os.path.join(os.path.dirname(__file__), 'requirements-python2.txt'), 'r').readlines()
imports = list(map(lambda r: re.split('[<=>\\s]', r)[0], filter(lambda x: x != '\n', requirements)))
import_statements = list(map(lambda r: 'import ' + r, imports))
stdout, stderr = proc.communicate(
'\n'.join(import_statements).encode(),
timeout=5
)
if stderr.decode() != '':
raise GimpInstallationException(
'At least one of the following packages is missing in the python2 installation: ' + ', '.join(imports)
)