diff --git a/setuptools/command/build_ext.py b/setuptools/command/build_ext.py index 51c1771a338..68b8047aadc 100644 --- a/setuptools/command/build_ext.py +++ b/setuptools/command/build_ext.py @@ -1,6 +1,7 @@ from __future__ import annotations import itertools +import operator import os import sys from importlib.machinery import EXTENSION_SUFFIXES @@ -319,7 +320,7 @@ def get_outputs(self) -> list[str]: def get_output_mapping(self) -> dict[str, str]: """See :class:`setuptools.commands.build.SubCommand`""" mapping = self._get_output_mapping() - return dict(sorted(mapping, key=lambda x: x[0])) + return dict(sorted(mapping, key=operator.itemgetter(0))) def __get_stubs_outputs(self): # assemble the base name for each extension that needs a stub diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index e6d9656f101..6592a8c1886 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -2,6 +2,7 @@ import fnmatch import itertools +import operator import os import stat import textwrap @@ -153,7 +154,7 @@ def get_output_mapping(self) -> dict[str, str]: self._get_package_data_output_mapping(), self._get_module_mapping(), ) - return dict(sorted(mapping, key=lambda x: x[0])) + return dict(sorted(mapping, key=operator.itemgetter(0))) def _get_module_mapping(self) -> Iterator[tuple[str, str]]: """Iterate over all modules producing (dest, src) pairs.""" diff --git a/setuptools/command/editable_wheel.py b/setuptools/command/editable_wheel.py index 46852c1a948..3a7c5808856 100644 --- a/setuptools/command/editable_wheel.py +++ b/setuptools/command/editable_wheel.py @@ -14,6 +14,7 @@ import io import logging +import operator import os import shutil import traceback @@ -865,7 +866,7 @@ def _finder_template( """Create a string containing the code for the``MetaPathFinder`` and ``PathEntryFinder``. """ - mapping = dict(sorted(mapping.items(), key=lambda p: p[0])) + mapping = dict(sorted(mapping.items(), key=operator.itemgetter(0))) return _FINDER_TEMPLATE.format(name=name, mapping=mapping, namespaces=namespaces)