Skip to content

Instantly share code, notes, and snippets.

@odra
Last active September 3, 2015 13:57

Revisions

  1. Leonardo Rossetti renamed this gist Sep 3, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Leonardo Rossetti revised this gist Sep 2, 2015. 1 changed file with 3 additions and 13 deletions.
    16 changes: 3 additions & 13 deletions setup.py
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,5 @@
    # -*- coding: utf-8 -*-
    #source: https://github.com/cython/cython/wiki/PackageHierarchy
    '''
    gd/
    __init__.py
    hello.pxd
    hello.pyx
    greetings/
    __init__.py
    en.pxd
    en.pyx
    '''

    import sys, os
    from distutils.core import setup, Extension
    @@ -33,13 +23,13 @@ def scandir(dir, files=[]):
    return files


    def make_extension(extName):
    extPath = extName.replace('.', os.path.sep) + '.pyx'
    def make_extension(ext_name):
    ext_path = ext_name.replace('.', os.path.sep) + '.pyx'
    options = {
    'extra_compile_args': compile_args,
    'extra_link_args': link_args
    }
    return Extension(extName, [extPath], **options)
    return Extension(ext_name, [ext_path], **options)


    ext_names = scandir(package_dir)
  3. Leonardo Rossetti revised this gist Sep 2, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion setup.py
    Original file line number Diff line number Diff line change
    @@ -42,7 +42,7 @@ def make_extension(extName):
    return Extension(extName, [extPath], **options)


    ext_names = scandir('gd')
    ext_names = scandir(package_dir)
    extensions = [make_extension(name) for name in ext_names]
    options = {
    'name': package_name,
  4. Leonardo Rossetti revised this gist Sep 2, 2015. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion setup.py
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,15 @@
    # -*- coding: utf-8 -*-

    #source: https://github.com/cython/cython/wiki/PackageHierarchy
    '''
    gd/
    __init__.py
    hello.pxd
    hello.pyx
    greetings/
    __init__.py
    en.pxd
    en.pyx
    '''

    import sys, os
    from distutils.core import setup, Extension
  5. Leonardo Rossetti revised this gist Sep 2, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions setup.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    # -*- coding: utf-8 -*-

    #source: https://github.com/cython/cython/wiki/PackageHierarchy

    import sys, os
    from distutils.core import setup, Extension
    from Cython.Distutils import build_ext
  6. Leonardo Rossetti revised this gist Sep 2, 2015. No changes.
  7. Leonardo Rossetti created this gist Sep 2, 2015.
    42 changes: 42 additions & 0 deletions setup.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    # -*- coding: utf-8 -*-

    import sys, os
    from distutils.core import setup, Extension
    from Cython.Distutils import build_ext


    package_name = 'gd'
    package_dir = 'gd'
    packages = ['gd', 'gd.greetings']
    compile_args = ['-Wall']
    link_args = ['-g']


    def scandir(dir, files=[]):
    for file in os.listdir(dir):
    path = os.path.join(dir, file)
    if os.path.isfile(path) and path.endswith('.pyx'):
    files.append(path.replace(os.path.sep, '.')[:-4])
    elif os.path.isdir(path):
    scandir(path, files)
    return files


    def make_extension(extName):
    extPath = extName.replace('.', os.path.sep) + '.pyx'
    options = {
    'extra_compile_args': compile_args,
    'extra_link_args': link_args
    }
    return Extension(extName, [extPath], **options)


    ext_names = scandir('gd')
    extensions = [make_extension(name) for name in ext_names]
    options = {
    'name': package_name,
    'packages': packages,
    'ext_modules': extensions,
    'cmdclass': {'build_ext': build_ext}
    }
    setup(**options)