From e8beece45b7de0ee0de4db2254a4e40b44bc8b58 Mon Sep 17 00:00:00 2001 From: Tristan Maat Date: Wed, 27 Sep 2017 14:32:07 +0100 Subject: setup.py: Make setup.py work on non-linux --- setup.py | 54 +++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 953485dc9..2022e6cbb 100755 --- a/setup.py +++ b/setup.py @@ -26,12 +26,14 @@ if sys.version_info[0] != 3 or sys.version_info[1] < 4: print("BuildStream requires Python >= 3.4") sys.exit(1) -bwrap_path = shutil.which('bwrap') -if not bwrap_path: - print("Bubblewrap not found: BuildStream requires Bubblewrap (bwrap) for" - " sandboxing the build environment. Install it using your package manager" - " (usually bwrap or bubblewrap)") - sys.exit(1) +platform = os.environ.get('BST_FORCE_BACKEND', '') or sys.platform +if platform.startswith('linux'): + bwrap_path = shutil.which('bwrap') + if not bwrap_path: + print("Bubblewrap not found: BuildStream requires Bubblewrap (bwrap) for" + " sandboxing the build environment. Install it using your package manager" + " (usually bwrap or bubblewrap)") + sys.exit(1) try: from setuptools import setup, find_packages @@ -56,27 +58,29 @@ def exit_ostree(reason): "Install it using your package manager (usually ostree or gir1.2-ostree-1.0).") sys.exit(1) -try: - import gi -except ImportError: - print("BuildStream requires PyGObject (aka PyGI). Install it using" - " your package manager (usually pygobject3 or python-gi).") - sys.exit(1) +if platform.startswith('linux'): + try: + import gi + except ImportError: + print("BuildStream requires PyGObject (aka PyGI). Install it using" + " your package manager (usually pygobject3 or python-gi).") + sys.exit(1) -try: - gi.require_version('OSTree', '1.0') - from gi.repository import OSTree -except: - exit_ostree("OSTree not found") +if platform.startswith('linux'): + try: + gi.require_version('OSTree', '1.0') + from gi.repository import OSTree + except: + exit_ostree("OSTree not found") -try: - if OSTree.YEAR_VERSION < REQUIRED_OSTREE_YEAR or \ - (OSTree.YEAR_VERSION == REQUIRED_OSTREE_YEAR and - OSTree.RELEASE_VERSION < REQUIRED_OSTREE_RELEASE): - exit_ostree("OSTree v{}.{} is too old." - .format(OSTree.YEAR_VERSION, OSTree.RELEASE_VERSION)) -except AttributeError: - exit_ostree("OSTree is too old.") + try: + if OSTree.YEAR_VERSION < REQUIRED_OSTREE_YEAR or \ + (OSTree.YEAR_VERSION == REQUIRED_OSTREE_YEAR and + OSTree.RELEASE_VERSION < REQUIRED_OSTREE_RELEASE): + exit_ostree("OSTree v{}.{} is too old." + .format(OSTree.YEAR_VERSION, OSTree.RELEASE_VERSION)) + except AttributeError: + exit_ostree("OSTree is too old.") ########################################### -- cgit v1.2.1