diff options
author | Micah Lee <micah@micahflee.com> | 2023-02-06 20:45:38 -0800 |
---|---|---|
committer | Micah Lee <micah@micahflee.com> | 2023-02-06 20:45:38 -0800 |
commit | 06aac69087d6fa6b17e4d3c2f1170d50ae3f69e8 (patch) | |
tree | 929d403ac92e8afdd5d2ea87d636d4c183d6d5b1 | |
parent | b26e7cb0df127e1f98880a90cdb722db0f6b6b25 (diff) | |
download | onionshare-06aac69087d6fa6b17e4d3c2f1170d50ae3f69e8.tar.gz onionshare-06aac69087d6fa6b17e4d3c2f1170d50ae3f69e8.zip |
Remove code to fix obscure cx_Freeze bug
-rw-r--r-- | desktop/setup-freeze.py | 79 |
1 files changed, 0 insertions, 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() |