Changeset 265049 in webkit


Ignore:
Timestamp:
Jul 29, 2020 11:43:43 AM (4 years ago)
Author:
Jonathan Bedard
Message:

[webkitcorepy] Add an auto-installer
https://bugs.webkit.org/show_bug.cgi?id=214606

Reviewed by Darin Adler.

Add an autoinstaller to webkitcorepy. This is eventually intended to replace the
autoinstaller in webkitpy.

  • Scripts/libraries: Added property svn:ignore.
  • Scripts/libraries/webkitcorepy/README.md:
  • Scripts/libraries/webkitcorepy/webkitcorepy/init.py:
  • Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py: Added.

(Package): Class representing a single Python module.
(Package.Archive): Class representing a zip file containing a package.
(Package.Archive.init): Construct representation with a name, version and
downloadable link.
(Package.Archive.repr): Archives are named based on their package name
and version.
(Package.Archive.path): The location of a downloaded archive on disk.
(Package.Archive.download): Download archive and write contents to disk.
(Package.Archive.unpack): Unpack archive on disk into package.
(Package.init): Packages are constructed with a name, version and name on
PyPi, which is assumed to be the package name unless specified.
(Package.location): Location of the package on disk.
(Package.do_post_install): Some packages have post-install actions, execute
those.
(Package.archives): Return a list of archives which match the specified
package parameters.
(Package.is_cached): Check the AutoInstall manifest to see if a package has
already been installed.
(Package.install): If needed, find a compatible archive for the specified
package, download and install it.
(AutoInstall): Namespace for auto-install functionality.
(AutoInstall._request): Make a request to the package index specified.
(AutoInstall.enable): Enable the auto-installer.
(AutoInstall.disable): Disable the auto-installer.
(AutoInstall.set_directory): Set the directory to save auto-installed libraries to.
(AutoInstall.set_index): Use a different package index.
(AutoInstall.set_timeout): Set the default timeout.
(AutoInstall.register): Add a package to the list of packages to be installed
when encountered.
(AutoInstall.install): Given a package, register and install that package.
(AutoInstall.install_everything): Install all registered packages if they are not
already.
(AutoInstall.find_module): Check and see if a requested module has been registered,
if it has, install that module if needed.

  • Scripts/libraries/webkitcorepy/webkitcorepy/cacert.pem: Added.
  • Scripts/libraries/webkitcorepy/webkitcorepy/rootcerts.p7b: Added.
  • Scripts/webkitpy/init.py: Add logger, autoinstalled requests and certifi.
  • Scripts/webkitpy/test/main.py:

(Tester._run_tests): Include webkitcorepy.AutoInstall when installing everything.

Location:
trunk/Tools
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r265040 r265049  
     12020-07-29  Jonathan Bedard  <jbedard@apple.com>
     2
     3        [webkitcorepy] Add an auto-installer
     4        https://bugs.webkit.org/show_bug.cgi?id=214606
     5
     6        Reviewed by Darin Adler.
     7
     8        Add an autoinstaller to webkitcorepy. This is eventually intended to replace the
     9        autoinstaller in webkitpy.
     10
     11        * Scripts/libraries: Added property svn:ignore.
     12        * Scripts/libraries/webkitcorepy/README.md:
     13        * Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py:
     14        * Scripts/libraries/webkitcorepy/webkitcorepy/autoinstall.py: Added.
     15        (Package): Class representing a single Python module.
     16        (Package.Archive): Class representing a zip file containing a package.
     17        (Package.Archive.__init__): Construct representation with a name, version and
     18        downloadable link.
     19        (Package.Archive.__repr__): Archives are named based on their package name
     20        and version.
     21        (Package.Archive.path): The location of  a downloaded archive on disk.
     22        (Package.Archive.download): Download archive and write contents to disk.
     23        (Package.Archive.unpack): Unpack archive on disk into package.
     24        (Package.__init__): Packages are constructed with a name, version and name on
     25        PyPi, which is assumed to be the package name unless specified.
     26        (Package.location): Location of the package on disk.
     27        (Package.do_post_install): Some packages have post-install actions, execute
     28        those.
     29        (Package.archives): Return a list of archives which match the specified
     30        package parameters.
     31        (Package.is_cached): Check the AutoInstall manifest to see if a package has
     32        already been installed.
     33        (Package.install): If needed, find a compatible archive for the specified
     34        package, download and install it.
     35        (AutoInstall): Namespace for auto-install functionality.
     36        (AutoInstall._request): Make a request to the package index specified.
     37        (AutoInstall.enable): Enable the auto-installer.
     38        (AutoInstall.disable): Disable the auto-installer.
     39        (AutoInstall.set_directory): Set the directory to save auto-installed libraries to.
     40        (AutoInstall.set_index): Use a different package index.
     41        (AutoInstall.set_timeout): Set the default timeout.
     42        (AutoInstall.register): Add a package to the list of packages to be installed
     43        when encountered.
     44        (AutoInstall.install): Given a package, register and install that package.
     45        (AutoInstall.install_everything): Install all registered packages if they are not
     46        already.
     47        (AutoInstall.find_module): Check and see if a requested module has been registered,
     48        if it has, install that module if needed.
     49        * Scripts/libraries/webkitcorepy/webkitcorepy/cacert.pem: Added.
     50        * Scripts/libraries/webkitcorepy/webkitcorepy/rootcerts.p7b: Added.
     51        * Scripts/webkitpy/__init__.py: Add logger, autoinstalled requests and certifi.
     52        * Scripts/webkitpy/test/main.py:
     53        (Tester._run_tests): Include webkitcorepy.AutoInstall when installing everything.
     54
    1552020-07-29  Jonathan Bedard  <jbedard@apple.com>
    256
  • trunk/Tools/Scripts/libraries/webkitcorepy/README.md

    r264715 r265049  
    33Provides a number of utilities intended to support intermediate to advanced Python programming.
    44
     5## Requirements
    56
     7The mock and requests libraries.
     8 
    69## Usage
    710
     
    2427string_utils.decode(...)
    2528```
     29
     30Automatically install libraries on import.
     31```
     32from webkitcorepy import AutoInstall
     33AutoInstall.register(Package('requests', Version(2, 24)))
     34import requests
     35```
  • trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py

    r264715 r265049  
    2121# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2222
     23import logging
     24import sys
     25
     26log = logging.getLogger('webkitcorepy')
     27
    2328from webkitcorepy.version import Version
    2429from webkitcorepy.string_utils import BytesIO, StringIO, UnicodeIO, unicode
    2530
    26 version = Version(0, 0, 2)
     31version = Version(0, 0, 3)
     32
     33from webkitcorepy.autoinstall import Package, AutoInstall
     34if sys.version_info > (3, 0):
     35    AutoInstall.register(Package('mock', Version(4)))
     36else:
     37    AutoInstall.register(Package('mock', Version(3, 0, 5)))
     38
     39AutoInstall.register(Package('certifi', Version(2020, 6, 20)))
     40AutoInstall.register(Package('requests', Version(2, 24)))
  • trunk/Tools/Scripts/webkitpy/__init__.py

    r264425 r265049  
    1818libraries = os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__))), 'libraries')
    1919sys.path.insert(0, os.path.join(libraries, 'webkitcorepy'))
     20
     21from webkitcorepy import AutoInstall
     22AutoInstall.set_directory(os.path.join(libraries, 'autoinstalled', 'python-{}'.format(sys.version_info[0])))
  • trunk/Tools/Scripts/webkitpy/test/main.py

    r264949 r265049  
    156156        from webkitpy.thirdparty import autoinstall_everything
    157157        autoinstall_everything()
     158
     159        from webkitcorepy import AutoInstall
     160        AutoInstall.install_everything()
    158161
    159162        start_time = time.time()
Note: See TracChangeset for help on using the changeset viewer.