Title: [267019] trunk/Tools
Revision
267019
Author
[email protected]
Date
2020-09-14 10:10:39 -0700 (Mon, 14 Sep 2020)

Log Message

[webkitcorepy] Disable AutoInstaller with environment variable
https://bugs.webkit.org/show_bug.cgi?id=216396
<rdar://problem/68680933>

Reviewed by Dewei Zhu.

* Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py:
* Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py:
(AutoInstall):
(AutoInstall.enabled): Check DISABLE_WEBKITCOREPY_AUTOINSTALLER to see if the autoinstaller
has been explicitly disabled.
(AutoInstall.set_directory): Early exit if the autoinstaller is explicitly disabled.
(AutoInstall.find_module):
(AutoInstall.enable): Deleted.
(AutoInstall.disable): Deleted.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (267018 => 267019)


--- trunk/Tools/ChangeLog	2020-09-14 17:00:56 UTC (rev 267018)
+++ trunk/Tools/ChangeLog	2020-09-14 17:10:39 UTC (rev 267019)
@@ -1,3 +1,21 @@
+2020-09-14  Jonathan Bedard  <[email protected]>
+
+        [webkitcorepy] Disable AutoInstaller with environment variable
+        https://bugs.webkit.org/show_bug.cgi?id=216396
+        <rdar://problem/68680933>
+
+        Reviewed by Dewei Zhu.
+
+        * Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py:
+        * Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py:
+        (AutoInstall):
+        (AutoInstall.enabled): Check DISABLE_WEBKITCOREPY_AUTOINSTALLER to see if the autoinstaller
+        has been explicitly disabled.
+        (AutoInstall.set_directory): Early exit if the autoinstaller is explicitly disabled.
+        (AutoInstall.find_module):
+        (AutoInstall.enable): Deleted.
+        (AutoInstall.disable): Deleted.
+
 2020-09-14  Philippe Normand  <[email protected]>
 
         [Flatpak SDK] Migration to SDK 0.3 branch

Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py (267018 => 267019)


--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py	2020-09-14 17:00:56 UTC (rev 267018)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py	2020-09-14 17:10:39 UTC (rev 267019)
@@ -35,7 +35,7 @@
 from webkitcorepy.subprocess_utils import TimeoutExpired, CompletedProcess, run
 from webkitcorepy.output_capture import LoggerCapture, OutputCapture, OutputDuplicate
 
-version = Version(0, 4, 7)
+version = Version(0, 4, 8)
 
 from webkitcorepy.autoinstall import Package, AutoInstall
 if sys.version_info > (3, 0):

Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py (267018 => 267019)


--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py	2020-09-14 17:00:56 UTC (rev 267018)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py	2020-09-14 17:10:39 UTC (rev 267019)
@@ -297,8 +297,8 @@
 
 
 class AutoInstall(object):
-    _enabled = None
-    enabled = False
+    DISABLE_ENV_VAR = 'DISABLE_WEBKITCOREPY_AUTOINSTALLER'
+
     directory = None
     index = 'pypi.org'
     timeout = 30
@@ -322,16 +322,12 @@
         return urlopen(url, timeout=cls.timeout)
 
     @classmethod
-    def enable(cls):
-        cls._enabled = True
-        cls.enabled = True
+    def enabled(cls):
+        if os.environ.get(cls.DISABLE_ENV_VAR) not in ['0', 'FALSE', 'false', 'NO', 'no', None]:
+            return False
+        return True if cls.directory else None
 
     @classmethod
-    def disable(cls):
-        cls._enabled = False
-        cls.enabled = False
-
-    @classmethod
     def userspace_should_own(cls, path):
         # Windows doesn't have sudo
         if not hasattr(os, "geteuid"):
@@ -360,6 +356,14 @@
         if not directory or not isinstance(directory, str):
             raise ValueError('{} is an invalid autoinstall directory'.format(directory))
 
+        if cls.enabled() is False:
+            print('Request to set autoinstall directory to {}'.format(directory))
+            print('Environment variable {}={} overriding request'.format(
+                cls.DISABLE_ENV_VAR,
+                os.environ.get(cls.DISABLE_ENV_VAR),
+            ))
+            return
+
         directory = os.path.abspath(directory)
         if not os.path.isdir(directory):
             creation_root = directory
@@ -380,9 +384,6 @@
 
         sys.path.insert(0, directory)
         cls.directory = directory
-        if cls._enabled is None:
-            cls._enabled = True
-            cls.enabled = True
 
     @classmethod
     def set_index(cls, index, check=True, fatal=False):
@@ -468,7 +469,7 @@
 
     @classmethod
     def find_module(cls, fullname, path=None):
-        if not cls.enabled or path is not None:
+        if not cls.enabled() or path is not None:
             return
 
         name = fullname.split('.')[0]
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to