# Buggy code
def dosetup(name, version, packages, datafiles, scripts, ext_modules=[]):
    from setuptools import setup

    description, long_description = __doc__.split("\n", 1)
    kwargs = {}
    if py2exe:
        kwargs["distclass"] = TranslateDistribution

    setup(
        name=name,
        version=version,
        license="GNU General Public License (GPL)",
        description=description,
        long_description=long_description,
        author="Translate",
        author_email="translate-devel@lists.sourceforge.net",
        url="http://toolkit.translatehouse.org/",
        download_url="https://github.com/translate/translate/releases/tag/" + version,
        project_urls={
            "Issue Tracker": "https://github.com/translate/translate/issues",
            "Documentation": "http://docs.translatehouse.org/projects/translate-toolkit/",
        },
        platforms=["any"],
        classifiers=classifiers,
        packages=packages,
        data_files=datafiles,
        entry_points={
            "console_scripts": translatescripts,
        },
        scripts=scripts,
        ext_modules=ext_modules,
        cmdclass=cmdclass,
        install_requires=parse_requirements("requirements/required.txt"),
        **kwargs,
    )


# Traceback (AssertionError)
Traceback (most recent call last):
File "setup.py", line 526, in <module>
standardsetup("translate-toolkit", translateversion)
File "setup.py", line 486, in standardsetup
translatebashscripts)
File "setup.py", line 490, in dosetup
from setuptools import setup
File "C:\Python27\lib\site-packages\setuptools\__init__.py", line 20, in <module>
from setuptools.dist import Distribution, Feature
File "C:\Python27\lib\site-packages\setuptools\dist.py", line 336, in <module>
_Distribution = get_unpatched(distutils.core.Distribution)
File "C:\Python27\lib\site-packages\setuptools\monkey.py", line 44, in get_unpatched
return lookup(item)
File "C:\Python27\lib\site-packages\setuptools\monkey.py", line 61, in get_unpatched_class
raise AssertionError(msg)
AssertionError: distutils has already been patched by <class py2exe.Distribution at 0x047BBF48>

# Fixed code
def dosetup(name, version, packages, datafiles, scripts, ext_modules=[]):
    description, long_description = __doc__.split("\n", 1)
    kwargs = {}
    if py2exe:
        kwargs["distclass"] = TranslateDistribution

    setup(
        name=name,
        version=version,
        license="GNU General Public License (GPL)",
        description=description,
        long_description=long_description,
        author="Translate",
        author_email="translate-devel@lists.sourceforge.net",
        url="http://toolkit.translatehouse.org/",
        download_url="https://github.com/translate/translate/releases/tag/" + version,
        project_urls={
            "Issue Tracker": "https://github.com/translate/translate/issues",
            "Documentation": "http://docs.translatehouse.org/projects/translate-toolkit/",
        },
        platforms=["any"],
        classifiers=classifiers,
        packages=packages,
        data_files=datafiles,
        entry_points={
            "console_scripts": translatescripts,
        },
        scripts=scripts,
        ext_modules=ext_modules,
        cmdclass=cmdclass,
        install_requires=parse_requirements("requirements/required.txt"),
        **kwargs,
    )