<commit_before>import os
import shutil
import subprocess
from distutils.errors import LibError
from distutils.core import setup
from distutils.command.build import build as _build

QEMU_REPO_PATH_CGC = "tracer-qemu-cgc"
QEMU_PATH_CGC = os.path.join("bin", "tracer-qemu-cgc")

QEMU_REPO_PATH_LINUX = "tracer-qemu-linux"
QEMU_PATH_LINUX_I386 = os.path.join("bin", "tracer-qemu-linux-i386")
QEMU_PATH_LINUX_X86_64 = os.path.join("bin", "tracer-qemu-linux-x86_64")
QEMU_PATH_LINUX_MIPS = os.path.join("bin", "tracer-qemu-linux-mips")
QEMU_PATH_LINUX_MIPS64 = os.path.join("bin", "tracer-qemu-linux-mips64")
QEMU_PATH_LINUX_PPC = os.path.join("bin", "tracer-qemu-linux-ppc")
QEMU_PATH_LINUX_PPC64 = os.path.join("bin", "tracer-qemu-linux-ppc64")
QEMU_PATH_LINUX_ARM = os.path.join("bin", "tracer-qemu-linux-arm")
QEMU_PATH_LINUX_AARCH64 = os.path.join("bin", "tracer-qemu-linux-aarch64")
QEMU_LINUX_TRACER_PATCH = os.path.join("..", "patches", "tracer-qemu.patch")

BIN_PATH = "bin"

# grab the CGC repo
if not os.path.exists(QEMU_REPO_PATH_CGC):
    TRACER_QEMU_REPO_CGC = "<EMAIL>:cgc/qemu.git"
    if subprocess.call(['git', 'clone', TRACER_QEMU_REPO_CGC, QEMU_REPO_PATH_CGC]) != 0:
        raise LibError("Unable to retrieve tracer qemu")
    if subprocess.call(['git', 'checkout', 'base_tracer'], cwd=QEMU_REPO_PATH_CGC) != 0:
        raise LibError("Unable to checkout tracer branch")

# grab the linux tarball
if not os.path.exists(QEMU_REPO_PATH_LINUX):
    TRACER_QEMU_REPO_LINUX = "git://git.qemu.org/qemu.git"
    if subprocess.call(['git', 'clone', TRACER_QEMU_REPO_LINUX, QEMU_REPO_PATH_LINUX]) != 0:
        raise LibError("Unable to retrieve qemu repository \"%s\"" % TRACER_QEMU_REPO_LINUX)
    if subprocess.call(['git', '-C', QEMU_REPO_PATH_LINUX, 'checkout', 'tags/v2.3.0']) != 0:
        raise LibError("Unable to checkout version 2.3.0 of qemu")
    if subprocess.call(['git', '-C', QEMU_REPO_PATH_LINUX, 'apply', QEMU_LINUX_TRACER_PATCH]) != 0:
        raise LibError("Unable to apply tracer patch to qemu")

# update tracer qemu for cgc
if subprocess.call(['git', 'pull'], cwd=QEMU_REPO_PATH_CGC) != 0:
    raise LibError("Unable to retrieve tracer qemu")

if not os.path.exists(BIN_PATH):
    try:
        os.makedirs(BIN_PATH)
    except OSError:
        raise LibError("Unable to create bin directory")

def _build_qemus():
    if subprocess.call(['./tracer-config'], cwd=QEMU_REPO_PATH_CGC) != 0:
        raise LibError("Unable to configure tracer-qemu-cgc")

    if subprocess.call(['./tracer-config'], cwd=QEMU_REPO_PATH_LINUX) != 0:
        raise LibError("Unable to configure tracer-qemu-linux")

    if subprocess.call(['make'], cwd=QEMU_REPO_PATH_CGC) != 0:
        raise LibError("Unable to build tracer-qemu-cgc")

    if subprocess.call(['make'], cwd=QEMU_REPO_PATH_LINUX) != 0:
        raise LibError("Unable to build tracer-qemu-linux")

    shutil.copyfile(os.path.join(QEMU_REPO_PATH_CGC, "i386-linux-user", "qemu-i386"), QEMU_PATH_CGC)
    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "i386-linux-user", "qemu-i386"), QEMU_PATH_LINUX_I386)
    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "x86_64-linux-user", "qemu-x86_64"), QEMU_PATH_LINUX_X86_64)

    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "mips-linux-user", "qemu-mips"), QEMU_PATH_LINUX_MIPS)
    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "mips64-linux-user", "qemu-mips64"), QEMU_PATH_LINUX_MIPS64)

    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "ppc-linux-user", "qemu-ppc"), QEMU_PATH_LINUX_PPC)
    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "ppc64-linux-user", "qemu-ppc64"), QEMU_PATH_LINUX_PPC64)

    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "arm-linux-user", "qemu-arm"), QEMU_PATH_LINUX_ARM)
    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "aarch64-linux-user", "qemu-aarch64"), QEMU_PATH_LINUX_AARCH64)

    os.chmod(QEMU_PATH_CGC, 0755)
    os.chmod(QEMU_PATH_LINUX_I386, 0755)
    os.chmod(QEMU_PATH_LINUX_X86_64, 0755)
    os.chmod(QEMU_PATH_LINUX_MIPS, 0755)
    os.chmod(QEMU_PATH_LINUX_MIPS64, 0755)
    os.chmod(QEMU_PATH_LINUX_PPC, 0755)
    os.chmod(QEMU_PATH_LINUX_PPC64, 0755)
    os.chmod(QEMU_PATH_LINUX_ARM, 0755)
    os.chmod(QEMU_PATH_LINUX_AARCH64, 0755)

class build(_build):
    def run(self):
            self.execute(_build_qemus, (), msg="Building Tracer QEMU")
            _build.run(self)
cmdclass = {'build': build}


setup(
    name='tracer', version='0.1', description="Symbolically trace concrete inputs.",
    packages=['tracer'],
    data_files=[
        ('bin', ('bin/tracer-qemu-cgc',),),
        ('bin', ('bin/tracer-qemu-linux-i386',),),
        ('bin', ('bin/tracer-qemu-linux-x86_64',),),
    ],
    cmdclass=cmdclass,
)<commit_msg>Add install requirements to setup.py<commit_after>import os
import shutil
import subprocess
from distutils.errors import LibError
from distutils.core import setup
from distutils.command.build import build as _build

QEMU_REPO_PATH_CGC = "tracer-qemu-cgc"
QEMU_PATH_CGC = os.path.join("bin", "tracer-qemu-cgc")

QEMU_REPO_PATH_LINUX = "tracer-qemu-linux"
QEMU_PATH_LINUX_I386 = os.path.join("bin", "tracer-qemu-linux-i386")
QEMU_PATH_LINUX_X86_64 = os.path.join("bin", "tracer-qemu-linux-x86_64")
QEMU_PATH_LINUX_MIPS = os.path.join("bin", "tracer-qemu-linux-mips")
QEMU_PATH_LINUX_MIPS64 = os.path.join("bin", "tracer-qemu-linux-mips64")
QEMU_PATH_LINUX_PPC = os.path.join("bin", "tracer-qemu-linux-ppc")
QEMU_PATH_LINUX_PPC64 = os.path.join("bin", "tracer-qemu-linux-ppc64")
QEMU_PATH_LINUX_ARM = os.path.join("bin", "tracer-qemu-linux-arm")
QEMU_PATH_LINUX_AARCH64 = os.path.join("bin", "tracer-qemu-linux-aarch64")
QEMU_LINUX_TRACER_PATCH = os.path.join("..", "patches", "tracer-qemu.patch")

BIN_PATH = "bin"

# grab the CGC repo
if not os.path.exists(QEMU_REPO_PATH_CGC):
    TRACER_QEMU_REPO_CGC = "<EMAIL>:cgc/qemu.git"
    if subprocess.call(['git', 'clone', TRACER_QEMU_REPO_CGC, QEMU_REPO_PATH_CGC]) != 0:
        raise LibError("Unable to retrieve tracer qemu")
    if subprocess.call(['git', 'checkout', 'base_tracer'], cwd=QEMU_REPO_PATH_CGC) != 0:
        raise LibError("Unable to checkout tracer branch")

# grab the linux tarball
if not os.path.exists(QEMU_REPO_PATH_LINUX):
    TRACER_QEMU_REPO_LINUX = "git://git.qemu.org/qemu.git"
    if subprocess.call(['git', 'clone', TRACER_QEMU_REPO_LINUX, QEMU_REPO_PATH_LINUX]) != 0:
        raise LibError("Unable to retrieve qemu repository \"%s\"" % TRACER_QEMU_REPO_LINUX)
    if subprocess.call(['git', '-C', QEMU_REPO_PATH_LINUX, 'checkout', 'tags/v2.3.0']) != 0:
        raise LibError("Unable to checkout version 2.3.0 of qemu")
    if subprocess.call(['git', '-C', QEMU_REPO_PATH_LINUX, 'apply', QEMU_LINUX_TRACER_PATCH]) != 0:
        raise LibError("Unable to apply tracer patch to qemu")

# update tracer qemu for cgc
if subprocess.call(['git', 'pull'], cwd=QEMU_REPO_PATH_CGC) != 0:
    raise LibError("Unable to retrieve tracer qemu")

if not os.path.exists(BIN_PATH):
    try:
        os.makedirs(BIN_PATH)
    except OSError:
        raise LibError("Unable to create bin directory")

def _build_qemus():
    if subprocess.call(['./tracer-config'], cwd=QEMU_REPO_PATH_CGC) != 0:
        raise LibError("Unable to configure tracer-qemu-cgc")

    if subprocess.call(['./tracer-config'], cwd=QEMU_REPO_PATH_LINUX) != 0:
        raise LibError("Unable to configure tracer-qemu-linux")

    if subprocess.call(['make'], cwd=QEMU_REPO_PATH_CGC) != 0:
        raise LibError("Unable to build tracer-qemu-cgc")

    if subprocess.call(['make'], cwd=QEMU_REPO_PATH_LINUX) != 0:
        raise LibError("Unable to build tracer-qemu-linux")

    shutil.copyfile(os.path.join(QEMU_REPO_PATH_CGC, "i386-linux-user", "qemu-i386"), QEMU_PATH_CGC)
    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "i386-linux-user", "qemu-i386"), QEMU_PATH_LINUX_I386)
    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "x86_64-linux-user", "qemu-x86_64"), QEMU_PATH_LINUX_X86_64)

    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "mips-linux-user", "qemu-mips"), QEMU_PATH_LINUX_MIPS)
    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "mips64-linux-user", "qemu-mips64"), QEMU_PATH_LINUX_MIPS64)

    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "ppc-linux-user", "qemu-ppc"), QEMU_PATH_LINUX_PPC)
    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "ppc64-linux-user", "qemu-ppc64"), QEMU_PATH_LINUX_PPC64)

    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "arm-linux-user", "qemu-arm"), QEMU_PATH_LINUX_ARM)
    shutil.copyfile(os.path.join(QEMU_REPO_PATH_LINUX, "aarch64-linux-user", "qemu-aarch64"), QEMU_PATH_LINUX_AARCH64)

    os.chmod(QEMU_PATH_CGC, 0755)
    os.chmod(QEMU_PATH_LINUX_I386, 0755)
    os.chmod(QEMU_PATH_LINUX_X86_64, 0755)
    os.chmod(QEMU_PATH_LINUX_MIPS, 0755)
    os.chmod(QEMU_PATH_LINUX_MIPS64, 0755)
    os.chmod(QEMU_PATH_LINUX_PPC, 0755)
    os.chmod(QEMU_PATH_LINUX_PPC64, 0755)
    os.chmod(QEMU_PATH_LINUX_ARM, 0755)
    os.chmod(QEMU_PATH_LINUX_AARCH64, 0755)

class build(_build):
    def run(self):
            self.execute(_build_qemus, (), msg="Building Tracer QEMU")
            _build.run(self)
cmdclass = {'build': build}


setup(
    name='tracer', version='0.1', description="Symbolically trace concrete inputs.",
    packages=['tracer'],
    data_files=[
        ('bin', ('bin/tracer-qemu-cgc',),),
        ('bin', ('bin/tracer-qemu-linux-i386',),),
        ('bin', ('bin/tracer-qemu-linux-x86_64',),),
    ],
    cmdclass=cmdclass,
    install_requires=[
        'cle',
        'angr',
        'simuvex',
    ],
)
{'fraction_non_alphanumeric': 0.1488673139158576, 'fraction_numerical': 0.030274558930994885, 'mean_word_length': 4.726240286909743, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5839698', 'n_tokens_mistral': 4277, 'n_tokens_neox': 4048, 'n_words': 592}