summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <bschubert15@bloomberg.net>2019-12-16 16:02:49 +0000
committerBenjamin Schubert <bschubert15@bloomberg.net>2019-12-16 16:02:49 +0000
commita1adce322cbe9306907a4fac0d0c6b58971ca6cc (patch)
tree6554a06e21ed2f9c4b411b956f0ba941469e822c
parent0118773753c571aec6c153d30f85c87e0d501d2c (diff)
downloadbuildstream-bschubert/fix-resource-deletion.tar.gz
_compat.py: Add module to handle version compatibility in pythonbschubert/fix-resource-deletion
This adds a module that allows us to patch some utilities when they are version conflicts. Let's keep them all in a specific place, which will make things easier when removing support for previous versions whenever possible.
-rw-r--r--src/buildstream/__init__.py1
-rw-r--r--src/buildstream/_compat.py32
2 files changed, 33 insertions, 0 deletions
diff --git a/src/buildstream/__init__.py b/src/buildstream/__init__.py
index c78fcbbf6..40746d735 100644
--- a/src/buildstream/__init__.py
+++ b/src/buildstream/__init__.py
@@ -28,6 +28,7 @@ if "_BST_COMPLETION" not in os.environ:
__version__ = get_versions()["version"]
del get_versions
+ from . import _compat
from .utils import UtilError, ProgramNotFoundError
from .sandbox import Sandbox, SandboxFlags, SandboxCommandError
from .types import Scope, Consistency, CoreWarnings
diff --git a/src/buildstream/_compat.py b/src/buildstream/_compat.py
new file mode 100644
index 000000000..1c8c99d73
--- /dev/null
+++ b/src/buildstream/_compat.py
@@ -0,0 +1,32 @@
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+
+# This module contains some patches to make it easier to handle different
+# python versions. Patches can be removed once we decide a specific version
+# does not need to be supported anymore.
+
+import sys
+
+# Python < 3.7
+if sys.version_info[:2] < (3, 7):
+ # multiprocessing.Process got a 'close' method on python3.7
+ # A no-op is fine for previous versions
+ import multiprocessing
+ def _close(self):
+ pass
+
+ multiprocessing.Process.close = _close