<commit_before>from setuptools import setup, find_packages

mesos_requirements = []
# only set requirements that are not already satisfied. For some reason, setting requirements that are already satisfied
# causes setup.py to reinstall them. This is bad, especially in cases like in cgcloud mesos right now, when mesos.native and
# mesos.interface are installed via an egg. This then uninstalls mesos.interface, pip installs it, and now there are two
# mesos modules instead of the one we want.
try:
    import mesos.native
    try:
        import mesos.interface
    except:
        mesos_requirements.append('mesos.interface>=0.22.1')
    try:
        import psutil
    except:
        mesos_requirements.append('psutil>=3.0.1')
except:
    pass

setup(
    name='toil',
    version='3.0.3.dev1',
    description='Pipeline management software for clusters.',
    author='<NAME>',
    author_email='<EMAIL>',
    url="https://github.com/BD2KGenomics/toil",
    install_requires = mesos_requirements,
    package_dir={ '': 'src' },
    packages=find_packages( 'src', exclude=[ '*.test' ] ),
    entry_points={
        'console_scripts': [
            'toilKill = toil.utils.toilKill:main',
            'toilStatus = toil.utils.toilStatus:main',
            'toilStats = toil.utils.toilStats:main',
            'toilRestarts = toil.utils.toilRestarts:main',
            'multijob = toil.batchSystems.multijob:main'
        ],
    })
<commit_msg>setup.py: Tweaked Mesos trial import logic in setup.py<commit_after>import importlib

from setuptools import setup, find_packages

install_requires = [ ]


def __try_import( name ):
    try:
        importlib.import_module( name )
    except ImportError:
        print "Failed to import '%s'" % name
        return 0
    else:
        print "Successfully imported '%s'" % name
        return 1


# The mesos.native package can't be installed solely via pip, it must be installed by installing
# Mesos as a whole. And while mesos.interface *can* be installed via pip, it is not sufficient
# for our purposes. We therefore don't explicitly depend on neither mesos.native nor
# mesos.interface. Instead, we require them both to be absent or present. In the latter case,
# we dynamically add the dependencies we need to use Mesos.

mesos_imports = __try_import( 'mesos.native' ) + __try_import( 'mesos.interface' )

if mesos_imports == 0:
    pass
elif mesos_imports == 1:
    raise RuntimeError( "Please install matching versions of mesos.native and mesos.interface. "
                        "One of them is missing at the moment." )
elif mesos_imports == 2:
    install_requires.append( 'psutil>=3.0.1' )
else:
    raise RuntimeError( "Internal error." )

setup(
    name='toil',
    version='3.0.3.dev1',
    description='Pipeline management software for clusters.',
    author='<NAME>',
    author_email='<EMAIL>',
    url="https://github.com/BD2KGenomics/toil",
    install_requires=install_requires,
    package_dir={ '': 'src' },
    packages=find_packages( 'src', exclude=[ '*.test' ] ),
    entry_points={
        'console_scripts': [
            'toilKill = toil.utils.toilKill:main',
            'toilStatus = toil.utils.toilStatus:main',
            'toilStats = toil.utils.toilStats:main',
            'toilRestarts = toil.utils.toilRestarts:main',
            'multijob = toil.batchSystems.multijob:main'
        ],
    } )

{'fraction_non_alphanumeric': 0.10831606984314886, 'fraction_numerical': 0.00739863865048831, 'mean_word_length': 3.0920096852300243, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 2, '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': '2286738', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1016, 'n_words': 292}