示例#1
0
 def install_rust(self):
     """Download and run the rustup installer."""
     import errno
     import stat
     import tempfile
     platform = rust.platform()
     url = rust.rustup_url(platform)
     checksum = rust.rustup_hash(platform)
     if not url or not checksum:
         print('ERROR: Could not download installer.')
         sys.exit(1)
     print('Downloading rustup-init... ', end='')
     fd, rustup_init = tempfile.mkstemp(prefix=os.path.basename(url))
     os.close(fd)
     try:
         self.http_download_and_save(url, rustup_init, checksum)
         mode = os.stat(rustup_init).st_mode
         os.chmod(rustup_init, mode | stat.S_IRWXU)
         print('Ok')
         print('Running rustup-init...')
         subprocess.check_call([rustup_init, '-y',
             '--default-toolchain', 'stable',
             '--default-host', platform,
         ])
         cargo_home, cargo_bin = self.cargo_home()
         self.print_rust_path_advice(RUST_INSTALL_COMPLETE,
                 cargo_home, cargo_bin)
     finally:
         try:
             os.remove(rustup_init)
         except OSError as e:
             if e.errno != errno.ENOENT:
                 raise
示例#2
0
    def install_rust(self):
        """Download and run the rustup installer."""
        import errno
        import stat
        import tempfile

        platform = rust.platform()
        url = rust.rustup_url(platform)
        checksum = rust.rustup_hash(platform)
        if not url or not checksum:
            print("ERROR: Could not download installer.")
            sys.exit(1)
        print("Downloading rustup-init... ", end="")
        fd, rustup_init = tempfile.mkstemp(prefix=os.path.basename(url))
        os.close(fd)
        try:
            self.http_download_and_save(url, rustup_init, checksum)
            mode = os.stat(rustup_init).st_mode
            os.chmod(rustup_init, mode | stat.S_IRWXU)
            print("Ok")
            print("Running rustup-init...")
            subprocess.check_call([rustup_init, "-y", "--default-toolchain", "stable", "--default-host", platform])
            cargo_home, cargo_bin = self.cargo_home()
            print("Rust installation complete.")
            print("You should now have rustc and cargo in %s" % cargo_bin)
            print(RUST_PATH_ADVICE % {"cargo_home": cargo_home})
        finally:
            try:
                os.remove(rustup_init)
            except OSError as e:
                if e.errno != errno.ENOENT:
                    raise