Exemplo n.º 1
0
 def write_wheelfile(self, *args, **kwargs):
     old = self.root_is_pure
     self.root_is_pure = False
     try:
         return bdist_wheel.write_wheelfile(self, *args, **kwargs)
     finally:
         self.root_is_pure = old
Exemplo n.º 2
0
    def write_wheelfile(self, *args, **kwargs):
        bdist_wheel.write_wheelfile(self, *args, **kwargs)
        release_dir = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            "..",
            "..",
            "electron",
            "release",
        )
        bin_dir = os.path.join(
            self.bdist_dir, self.data_dir, "purelib", "fiftyone", "gui", "bin"
        )

        if self.plat_name.startswith("linux"):
            apps = glob.glob(os.path.join(release_dir, "FiftyOne*.AppImage"))
        elif self.plat_name.startswith("mac"):
            apps = glob.glob(os.path.join(release_dir, "mac", "FiftyOne*.app"))
        elif self.plat_name.startswith("win"):
            apps = glob.glob(os.path.join(release_dir, "FiftyOne*.exe"))
        else:
            raise ValueError(
                "Unsupported target platform: %r" % self.plat_name
            )
        if not apps:
            raise RuntimeError(
                "Could not find any built Electron apps in %r. "
                "Run 'yarn package-PLATFORM' in the 'electron' folder first."
                % release_dir
            )
        elif len(apps) > 1:
            raise RuntimeError(
                "Found too many Electron apps in %r: %r" % (release_dir, apps)
            )
        app_path = apps[0]

        if not os.path.isdir(bin_dir):
            os.mkdir(bin_dir)
        if os.path.isfile(app_path):
            # use copy2 to maintain executable permission
            ext = os.path.splitext(app_path)[-1]
            shutil.copy2(app_path, os.path.join(bin_dir, "FiftyOne" + ext))
        elif os.path.isdir(app_path):
            # Mac app bundle
            shutil.copytree(app_path, os.path.join(bin_dir, "FiftyOne.app"))
        else:
            raise RuntimeError("Unsupported file type: %r" % app_path)
Exemplo n.º 3
0
 def write_wheelfile(self, *args, **kwargs):
     bdist_wheel.write_wheelfile(self, *args, **kwargs)
     bin_dir = os.path.join(
         self.bdist_dir, self.data_dir, "purelib", "fiftyone", "db", "bin"
     )
     if not os.path.isdir(bin_dir):
         os.mkdir(bin_dir)
     mongo_zip_url = next(
         v
         for k, v in MONGODB_DOWNLOAD_URLS.items()
         if self.plat_name.startswith(k)
     )
     if LINUX_DISTRO is not None:
         if not self.plat_name.startswith("linux"):
             raise ValueError(
                 "Cannot build for distro %r on platform %r"
                 % (LINUX_DISTRO, self.plat_name)
             )
         if LINUX_DISTRO not in MONGODB_DOWNLOAD_URLS:
             raise ValueError("Unrecognized distro: %r" % LINUX_DISTRO)
         mongo_zip_url = MONGODB_DOWNLOAD_URLS[LINUX_DISTRO]
     mongo_zip_filename = os.path.basename(mongo_zip_url)
     mongo_zip_dest = os.path.join(
         os.path.dirname(os.path.abspath(__file__)),
         "cache",
         mongo_zip_filename,
     )
     if not os.path.exists(mongo_zip_dest):
         print("downloading MongoDB from %s" % mongo_zip_url)
         with urlopen(mongo_zip_url) as conn, open(
             mongo_zip_dest, "wb"
         ) as dest:
             shutil.copyfileobj(conn, dest)
     print("using MongoDB from %s" % mongo_zip_dest)
     if mongo_zip_dest.endswith(".zip"):
         # Windows
         mongo_zip = zipfile.ZipFile(mongo_zip_dest)
         for filename in MONGODB_BINARIES:
             filename = filename + ".exe"
             try:
                 zip_entry = next(
                     entry
                     for entry in mongo_zip.filelist
                     if entry.filename.endswith("bin/" + filename)
                 )
             except StopIteration:
                 raise IOError(
                     "Could not find %r in MongoDB archive" % filename
                 )
             print("copying %r" % zip_entry.filename)
             # strip the leading directories (zipfile doesn't have an
             # equivalent of tarfile.extractfile to support this)
             zip_entry.filename = os.path.basename(zip_entry.filename)
             mongo_zip.extract(zip_entry, bin_dir)
     else:
         # assume tar
         mongo_tar = tarfile.open(mongo_zip_dest)
         for filename in MONGODB_BINARIES:
             try:
                 tar_entry_name = next(
                     name
                     for name in mongo_tar.getnames()
                     if name.endswith("bin/" + filename)
                 )
             except StopIteration:
                 raise IOError(
                     "Could not find %r in MongoDB archive" % filename
                 )
             tar_entry = mongo_tar.getmember(tar_entry_name)
             print("copying %r" % tar_entry_name)
             dest_path = os.path.join(bin_dir, filename)
             with mongo_tar.extractfile(tar_entry) as src, open(
                 dest_path, "wb"
             ) as dest:
                 shutil.copyfileobj(src, dest)
             os.chmod(dest_path, tar_entry.mode)