<commit_before># Standard library modules.
import ConfigParser
import logging
import os
import pipes
import re
import shutil
import StringIO
import subprocess
import sys
import tempfile

# External dependencies.
from deb_pkg_tools.control import merge_control_fields, unparse_control_fields
from deb_pkg_tools.package import build_package
from humanfriendly import format_path
from pip_accel.bdist import get_binary_dist, install_binary_dist

# Modules included in our package.
from py2deb.config import config
from py2deb.util import (find_python_version, get_tagged_description,
                         patch_control_file)

# Initialize a logger for this module.
logger = logging.getLogger(__name__)

def build(context):
    package = context['package']
    # Check whether the package is to be installed under a custom installation
    # prefix. If it is we are building an isolated package, this means the
    # Debian control file doesn't need fields like `Provides', `Replaces',
    # `Conflicts', etc.
    is_isolated_package = config.has_option('general', 'install-prefix')
    # Create a temporary directory to put the generated package in.
    build_directory = tempfile.mkdtemp()
    # Make sure we clean up the temporary directory afterwards...
    try:
        # Download the package, build the package, create a binary distribution
        # archive, sanitize the contents of the archive and install the
        # sanitized binary distribution inside the build directory (all using
        # pip-accel).
        if is_isolated_package:
            install_prefix = config.get('general', 'install-prefix')
        else:
            install_prefix = '/usr'
        install_binary_dist(rewrite_filenames(package, is_isolated_package),
                            prefix=os.path.join(build_directory, install_prefix.lstrip('/')),
                            python='/usr/bin/%s' % find_python_version())
        # Get the Python requirements converted to Debian dependencies.
        dependencies = [find_python_version()] + package.debian_dependencies
        # If the package installs shared object files, find their dependencies
        # on other system packages. Also determine the package's architecture
        # based on the architecture of the shared object files (if any).
        shared_objects = find_shared_object_files(build_directory)
        architecture = determine_package_architecture(shared_objects)
        if shared_objects:
            dependencies += find_library_dependencies(shared_objects)
        # Generate the control fields.
        control_fields = unparse_control_fields(dict(Package=package.debian_name,
                                                     Version=package.release,
                                                     Maintainer=find_package_maintainer(package),
                                                     Description=get_tagged_description(),<commit_msg>Use deb_pkg_tools.package.clean_package_tree() in pip-accel backend<commit_after># Standard library modules.
import ConfigParser
import logging
import os
import pipes
import re
import shutil
import StringIO
import subprocess
import sys
import tempfile

# External dependencies.
from deb_pkg_tools.control import merge_control_fields, unparse_control_fields
from deb_pkg_tools.package import build_package, clean_package_tree
from humanfriendly import format_path
from pip_accel.bdist import get_binary_dist, install_binary_dist

# Modules included in our package.
from py2deb.config import config
from py2deb.util import (find_python_version, get_tagged_description,
                         patch_control_file)

# Initialize a logger for this module.
logger = logging.getLogger(__name__)

def build(context):
    package = context['package']
    # Check whether the package is to be installed under a custom installation
    # prefix. If it is we are building an isolated package, this means the
    # Debian control file doesn't need fields like `Provides', `Replaces',
    # `Conflicts', etc.
    is_isolated_package = config.has_option('general', 'install-prefix')
    # Create a temporary directory to put the generated package in.
    build_directory = tempfile.mkdtemp()
    # Make sure we clean up the temporary directory afterwards...
    try:
        # Download the package, build the package, create a binary distribution
        # archive, sanitize the contents of the archive and install the
        # sanitized binary distribution inside the build directory (all using
        # pip-accel).
        if is_isolated_package:
            install_prefix = config.get('general', 'install-prefix')
        else:
            install_prefix = '/usr'
        directory = os.path.join(build_directory, install_prefix.lstrip('/'))
        clean_package_tree(directory)
        install_binary_dist(rewrite_filenames(package, is_isolated_package),
                            prefix=directory,
                            python='/usr/bin/%s' % find_python_version())
        # Get the Python requirements converted to Debian dependencies.
        dependencies = [find_python_version()] + package.debian_dependencies
        # If the package installs shared object files, find their dependencies
        # on other system packages. Also determine the package's architecture
        # based on the architecture of the shared object files (if any).
        shared_objects = find_shared_object_files(build_directory)
        architecture = determine_package_architecture(shared_objects)
        if shared_objects:
            dependencies += find_library_dependencies(shared_objects)
        # Generate the control fields.
        control_fields = unparse_control_fields(dict(Package=package.debian_name,
                                                     Version=package.release,
                                                     Maintainer=find_package_maintainer(package),
                                                     Description=get_tagged_description(),
{'fraction_non_alphanumeric': 0.06020680453635757, 'fraction_numerical': 0.00066711140760507, 'mean_word_length': 2.8815533980582524, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4211634', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1397, 'n_words': 475}