diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/wheel/bdist_wheel.py | 41 | ||||
| -rwxr-xr-x | src/wheel/cli/convert.py | 11 |
2 files changed, 31 insertions, 21 deletions
diff --git a/src/wheel/bdist_wheel.py b/src/wheel/bdist_wheel.py index cdea46d..bf2500c 100644 --- a/src/wheel/bdist_wheel.py +++ b/src/wheel/bdist_wheel.py @@ -4,16 +4,14 @@ Create a wheel (.whl) distribution. A wheel is a built archive format. """ -import distutils import os import re import shutil import stat import sys +import sysconfig import warnings from collections import OrderedDict -from distutils import log as logger -from distutils.core import Command from email.generator import BytesGenerator from glob import iglob from io import BytesIO @@ -22,6 +20,7 @@ from sysconfig import get_config_var from zipfile import ZIP_DEFLATED, ZIP_STORED import pkg_resources +from setuptools import Command from . import __version__ as wheel_version from .macosx_libfile import calculate_macosx_platform_tag @@ -36,20 +35,31 @@ safe_version = pkg_resources.safe_version PY_LIMITED_API_PATTERN = r"cp3\d" +def log(msg, *, error=False): + stream = sys.stderr if error else sys.stdout + try: + print(msg, file=stream, flush=True) + except UnicodeEncodeError: + # emulate backslashreplace error handler + encoding = stream.encoding + msg = msg.encode(encoding, "backslashreplace").decode(encoding) + print(msg, file=stream, flush=True) + + def python_tag(): return f"py{sys.version_info[0]}" def get_platform(archive_root): """Return our platform name 'win32', 'linux_x86_64'""" - # XXX remove distutils dependency - result = distutils.util.get_platform() + result = sysconfig.get_platform() if result.startswith("macosx") and archive_root is not None: result = calculate_macosx_platform_tag(archive_root, result) if result == "linux_x86_64" and sys.maxsize == 2147483647: # pip pull request #3497 result = "linux_i686" - return result + + return result.replace("-", "_") def get_flag(var, fallback, expected=True, warn=True): @@ -237,7 +247,10 @@ class bdist_wheel(Command): wheel = self.distribution.get_option_dict("wheel") if "universal" in wheel: # please don't define this in your global configs - logger.warn("The [wheel] section is deprecated. Use [bdist_wheel] instead.") + log( + "The [wheel] section is deprecated. Use [bdist_wheel] instead.", + error=True, + ) val = wheel["universal"][1].strip() if val.lower() in ("1", "true", "yes"): self.universal = True @@ -352,7 +365,7 @@ class bdist_wheel(Command): basedir_observed, ) - logger.info("installing to %s", self.bdist_dir) + log(f"installing to {self.bdist_dir}") self.run_command("install") @@ -393,7 +406,7 @@ class bdist_wheel(Command): ) if not self.keep_temp: - logger.info("removing %s", self.bdist_dir) + log(f"removing {self.bdist_dir}") if not self.dry_run: rmtree(self.bdist_dir, onerror=remove_readonly) @@ -417,7 +430,7 @@ class bdist_wheel(Command): msg["Tag"] = "-".join((impl, abi, plat)) wheelfile_path = os.path.join(wheelfile_base, "WHEEL") - logger.info("creating %s", wheelfile_path) + log("creating {wheelfile_path}") buffer = BytesIO() BytesGenerator(buffer, maxheaderlen=0).flatten(msg) with open(wheelfile_path, "wb") as f: @@ -452,15 +465,11 @@ class bdist_wheel(Command): for pattern in patterns: for path in iglob(pattern): if path.endswith("~"): - logger.debug( - 'ignoring license file "%s" as it looks like a backup', path - ) + log(f'ignoring license file "{path}" as it looks like a backup') continue if path not in files and os.path.isfile(path): - logger.info( - 'adding license file "%s" (matched pattern "%s")', path, pattern - ) + log(f'adding license file "{path}" (matched pattern "{pattern}")') files.add(path) return files diff --git a/src/wheel/cli/convert.py b/src/wheel/cli/convert.py index b2f685f..a4bec18 100755 --- a/src/wheel/cli/convert.py +++ b/src/wheel/cli/convert.py @@ -3,9 +3,10 @@ import re import shutil import tempfile import zipfile -from distutils import dist from glob import iglob +from setuptools.dist import Distribution + from ..bdist_wheel import bdist_wheel from ..wheelfile import WheelFile from . import WheelError, require_pkgresources @@ -68,9 +69,9 @@ def egg2wheel(egg_path, dest_dir): root_is_purelib = egg_info["arch"] is None if root_is_purelib: - bw = bdist_wheel(dist.Distribution()) + bw = bdist_wheel(Distribution()) else: - bw = _bdist_wheel_tag(dist.Distribution()) + bw = _bdist_wheel_tag(Distribution()) bw.root_is_pure = root_is_purelib bw.python_tag = pyver @@ -227,9 +228,9 @@ def wininst2wheel(path, dest_dir): pyver = pyver.replace("py", "cp") wheel_name = "-".join((dist_info, pyver, abi, arch)) if root_is_purelib: - bw = bdist_wheel(dist.Distribution()) + bw = bdist_wheel(Distribution()) else: - bw = _bdist_wheel_tag(dist.Distribution()) + bw = _bdist_wheel_tag(Distribution()) bw.root_is_pure = root_is_purelib bw.python_tag = pyver |
