Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a trick to get around a dependency on distutils. #1475

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions cx_Freeze/dist.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
"""The classes and functions with which cx_Freeze extends setuptools."""

from distutils.dist import DistributionMetadata # pylint: disable=W0402

from setuptools import Distribution as _Distribution

__all__ = ["Distribution", "DistributionMetadata"]


class DistributionMetadata:
"""Dummy class to hold the distribution meta-data: name, version,
author, and so forth."""


class Distribution(_Distribution):
"""Distribution with support for executables."""

def __init__(self, attrs):
self.executables = []
super().__init__(attrs)
self.metadata = self._patch_metadata()

def _patch_metadata(self) -> DistributionMetadata:
old_metadata = self.metadata
new_metadata = DistributionMetadata()
for var in dir(old_metadata):
if not hasattr(new_metadata, var):
setattr(new_metadata, var, getattr(old_metadata, var))
self.distutils_metadata = old_metadata
return new_metadata

def has_executables(self):
"""Predicate for build_exe command."""
Expand Down