From ea7c7bc8407ec6d5f65f9bf6b39dd8236185e558 Mon Sep 17 00:00:00 2001 From: Angelos Evripiotis Date: Tue, 16 Jul 2019 14:17:54 +0100 Subject: win32: _platform/win32: add support for win32 Copy the approach of 'Darwin' and provide a SandboxDummy. This enables us to run 'bst workspace list' on Windows. --- src/buildstream/_platform/platform.py | 4 +++ src/buildstream/_platform/win32.py | 59 +++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/buildstream/_platform/win32.py diff --git a/src/buildstream/_platform/platform.py b/src/buildstream/_platform/platform.py index 11c9217be..af49b9e82 100644 --- a/src/buildstream/_platform/platform.py +++ b/src/buildstream/_platform/platform.py @@ -98,6 +98,8 @@ class Platform(): backend = 'darwin' elif sys.platform.startswith('linux'): backend = 'linux' + elif sys.platform == 'win32': + backend = 'win32' else: backend = 'fallback' @@ -105,6 +107,8 @@ class Platform(): from .linux import Linux as PlatformImpl # pylint: disable=cyclic-import elif backend == 'darwin': from .darwin import Darwin as PlatformImpl # pylint: disable=cyclic-import + elif backend == 'win32': + from .win32 import Win32 as PlatformImpl # pylint: disable=cyclic-import elif backend == 'fallback': from .fallback import Fallback as PlatformImpl # pylint: disable=cyclic-import else: diff --git a/src/buildstream/_platform/win32.py b/src/buildstream/_platform/win32.py new file mode 100644 index 000000000..36680019d --- /dev/null +++ b/src/buildstream/_platform/win32.py @@ -0,0 +1,59 @@ +# +# Copyright (C) 2019 Bloomberg Finance LP +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library. If not, see . + +from ..sandbox import SandboxDummy + +from .platform import Platform + + +class Win32(Platform): + + def maximize_open_file_limit(self): + # Note that on Windows, we don't have the 'resource' module to help us + # configure open file limits. + # + # 'psutil' provides an rlimit implementation that is only available on + # Linux, as of version 5.3. + # + # Given that this limit is only important for SafeHardLinks FUSE, and + # we don't have FUSE on Windows, this won't be an obstacle for now. + # + # If it does turn out to be an obstacle, beware that the Windows API + # `_setmaxstdio` for increasing the open file limit only applies to the + # 'stream I/O level', i.e. `fopen()` and friends. CPython opens files + # using `_wopen()`, which is at the 'low I/O level'. + # + # You can see this in the function `os_open_impl` in `posixmodule.c` in + # CPython version 3.9. + # + # For more information: + # https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setmaxstdio + # + pass + + @staticmethod + def _check_dummy_sandbox_config(config): + return True + + @staticmethod + def _create_dummy_sandbox(*args, **kwargs): + kwargs['dummy_reason'] = "There are no supported sandbox technologies for Win32 at this time." + return SandboxDummy(*args, **kwargs) + + def _setup_dummy_sandbox(self): + self.check_sandbox_config = Win32._check_dummy_sandbox_config + self.create_sandbox = Win32._create_dummy_sandbox + return True -- cgit v1.2.1