From 06aac69087d6fa6b17e4d3c2f1170d50ae3f69e8 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Mon, 6 Feb 2023 20:45:38 -0800 Subject: Remove code to fix obscure cx_Freeze bug --- desktop/setup-freeze.py | 79 ------------------------------------------------- 1 file changed, 79 deletions(-) diff --git a/desktop/setup-freeze.py b/desktop/setup-freeze.py index 9ce867dd..7e4af3aa 100644 --- a/desktop/setup-freeze.py +++ b/desktop/setup-freeze.py @@ -26,85 +26,6 @@ import cx_Freeze from cx_Freeze import setup, Executable from setuptools import find_packages -# There's an obscure cx_Freeze bug that I'm hitting that's preventing the macOS -# package from getting built. This is some monkeypatching to fix it. - -if platform.system() == "Darwin" or platform.system() == "Linux": - import importlib_metadata - import pathlib - from pathlib import Path - from tempfile import TemporaryDirectory - - class CustomPackagePath(pathlib.PurePosixPath): - def __init__(self, filename): - self.long_filename = str(filename) - self.short_filename = "/".join(filename.as_posix().split("/")[-2:]) - super(CustomPackagePath, self).__init__() - - def read_text(self, encoding="utf-8"): - with self.locate().open(encoding=encoding) as stream: - return stream.read() - - def read_binary(self): - with self.locate().open("rb") as stream: - return stream.read() - - def locate(self): - return Path(self.long_filename) - - def as_posix(self): - return self.short_filename - - class DistributionCache(importlib_metadata.PathDistribution): - _cachedir = TemporaryDirectory(prefix="cxfreeze-") - - @staticmethod - def at(path): - return DistributionCache(Path(path)) - - at.__doc__ = importlib_metadata.PathDistribution.at.__doc__ - - @classmethod - def from_name(cls, name): - distribution = super().from_name(name) - temp_dir = Path(cls._cachedir.name) - dist_dir = None - files = distribution.files or [] - prep = importlib_metadata.Prepared(distribution.name) - normalized = prep.normalized - legacy_normalized = prep.legacy_normalized - for file in files: - # patch: the onionshare and onionshare_cli files are using absolute paths, which break everything - if name in ["onionshare", "onionshare_cli"]: - if ".dist-info" not in file.as_posix(): - continue - - file = CustomPackagePath(file) - - if ( - not file.match(f"{name}-*.dist-info/*") - and not file.match(f"{distribution.name}-*.dist-info/*") - and not file.match(f"{normalized}-*.dist-info/*") - and not file.match(f"{legacy_normalized}-*.dist-info/*") - ): - continue - src_path = file.locate() - if not src_path.exists(): - continue - dst_path = temp_dir / file.as_posix() - if dist_dir is None: - dist_dir = dst_path.parent - dist_dir.mkdir(exist_ok=True) - shutil.copy2(src_path, dst_path) - if dist_dir is None: - raise importlib_metadata.PackageNotFoundError(name) - return cls.at(dist_dir) - - from_name.__doc__ = importlib_metadata.PathDistribution.from_name.__doc__ - - #cx_Freeze.module.DistributionCache = DistributionCache - - # Discover the version with open(os.path.join("..", "cli", "onionshare_cli", "resources", "version.txt")) as f: version = f.read().strip() -- cgit v1.2.3-54-g00ecf