import os
from distutils.core import setup, Extension


here = os.path.abspath(os.path.dirname(__file__))
src = os.path.join(here, "src")


module1 = Extension(
    'decquad',
    sources=[os.path.join(src, 'decquadmodule.c')],
    include_dirs=[])

setup(name='decquad',
      url='https://github.com/cazino/decquad',
      author='emmanuel cazenave',
      author_email='emmanuel.cazenave@gmail.com',
      version='0.1',
      description='',
      ext_modules=[module1])

@@ -135,116 +135,2258 @@
 c%22)%0A
-%0A%0Amodule1 = Extension(%0A    'decquad',%0A    sources=%5Bos.path.join(src, 'decquadmodule.c')%5D,%0A    include_dirs=%5B
+libmpdec_src = os.path.join(here, 'libmpdec')%0A%0A%0Adef _decimal_ext():%0A    # Ripped from http://hg.python.org/cpython/file/c4a2d0538441/setup.py%0A    extra_compile_args = %5B%5D%0A    undef_macros = %5B%5D%0A%0A    include_dirs = %5Blibmpdec_src%5D%0A    libraries = %5B%5D%0A    sources = %5B%0A        'src/decquadmodule.c',%0A        'libmpdec/basearith.c',%0A        'libmpdec/constants.c',%0A        'libmpdec/context.c',%0A        'libmpdec/convolute.c',%0A        'libmpdec/crt.c',%0A        'libmpdec/difradix2.c',%0A        'libmpdec/fnt.c',%0A        'libmpdec/fourstep.c',%0A        'libmpdec/io.c',%0A        'libmpdec/memory.c',%0A        'libmpdec/mpdecimal.c',%0A        'libmpdec/numbertheory.c',%0A        'libmpdec/sixstep.c',%0A        'libmpdec/transpose.c',%0A    %5D%0A    depends = %5B%0A        'docstrings.h',%0A        'libmpdec/basearith.h',%0A        'libmpdec/bits.h',%0A        'libmpdec/constants.h',%0A        'libmpdec/convolute.h',%0A        'libmpdec/crt.h',%0A        'libmpdec/difradix2.h',%0A        'libmpdec/fnt.h',%0A        'libmpdec/fourstep.h',%0A        'libmpdec/io.h',%0A        'libmpdec/memory.h',%0A        'libmpdec/mpdecimal.h',%0A        'libmpdec/numbertheory.h',%0A        'libmpdec/sixstep.h',%0A        'libmpdec/transpose.h',%0A        'libmpdec/typearith.h',%0A        'libmpdec/umodarith.h',%0A    %5D%0A%0A    config = %7B%0A        'x64': %5B('CONFIG_64', '1'), ('ASM', '1')%5D,%0A    %7D%0A%0A    cc = 'gcc -pthread'%0A    define_macros = config%5B'x64'%5D%0A%0A    # Increase warning level for gcc:%0A    if 'gcc' in cc:%0A        cmd = (%22echo '' %7C %25s -Wextra -Wno-missing-field-initializers -E - %22%0A               %22%3E /dev/null 2%3E&1%22 %25 cc)%0A        ret = os.system(cmd)%0A        if ret %3E%3E 8 == 0:%0A            extra_compile_args.extend(%5B'-Wextra',%0A                                       '-Wno-missing-field-initializers'%5D)%0A%0A    # Uncomment for extra functionality:%0A    #define_macros.append(('EXTRA_FUNCTIONALITY', 1))%0A    ext = Extension(%0A        'decquad',%0A        include_dirs=include_dirs,%0A        libraries=libraries,%0A        define_macros=define_macros,%0A        undef_macros=undef_macros,%0A        extra_compile_args=extra_compile_args,%0A        sources=sources,%0A        depends=depends%0A    )%0A    return ext%0A%0A%0Amodule1 = Extension(%0A    'decquad',%0A    include_dirs=%5Blibmpdec_src%5D,%0A    sources=%5Bos.path.join(src, 'decquadmodule.c')
 %5D)%0A%0A
@@ -2600,18 +2600,25 @@
 odules=%5B
-module1
+_decimal_ext()
 %5D)%0A

Copy some python's setup.py code