Source

orange-text / setup.py

Diff from to
 #!/usr/bin/env python
-"""\
-Text Mining Add-On for Orange
-
-Orange Text Mining is an addon for the Orange data
-mining software package.
-"""
-DOCLINES = __doc__.split("\n")
 
 try:
-    from setuptools import setup
-    have_setuptools = True
+    import distribute_setup
+    distribute_setup.use_setuptools()
 except ImportError:
-    from distutils.core import setup
-    have_setuptools = False
-    
-from distutils.core import Extension
-import distutils.ccompiler
-import os, sys, glob
+    # For documentation we load setup.py to get version
+    # so it does not matter if importing fails
+    pass
 
+import os, sys
 
-CLASSIFIERS = """\
-Development Status :: 4 - Beta
-Programming Language :: Python
-License :: OSI Approved :: GNU General Public License (GPL)
-Operating System :: POSIX
-Operating System :: Microsoft :: Windows
-Topic :: Scientific/Engineering :: Information Analysis
-Intended Audience :: Education
-Intended Audience :: Science/Research
-"""
+from setuptools import setup, find_packages
 
-KEYWORDS = """\
-data mining 
-machine learning,
-artificial intelligence
-text mining
-"""                      
+# Has to be last import as it seems something is changing it somewhere
+from distutils.extension import Extension
 
-NAME                = "Orange-Text-Mining"
-DESCRIPTION         = DOCLINES[0]
-LONG_DESCRIPTION    = "\n".join(DOCLINES[2:])
-URL                 = "https://bitbucket.org/biolab/orange-addon-text"
-DOWNLOAD_URL        = "https://bitbucket.org/biolab/orange-addon-text/downloads"
-LICENSE             = "GNU General Public License (GPL)"
-CLASSIFIERS         = filter(None, CLASSIFIERS.split("\n"))
-AUTHOR              = "Bojana Dalbelo Basic, Sasa Petrovic, Frane Saric, Mladen Kolar, Annie Morin, Jean-Hugues Chauchat"
-KEYWORDS            = filter(None, KEYWORDS.split('\n'))
+NAME = 'Orange-Text'
+DOCUMENTATION_NAME = 'Orange Text Mining'
 
-MAYOR = 1
-MINOR = 1
-MICRO = 0
-ISRELEASED = False
+VERSION = '1.2'
 
-VERSION = "%i.%ia.%i" % (MAYOR, MINOR, MICRO)
+DESCRIPTION = 'Orange Text Mining add-on for Orange data mining software package.'
+LONG_DESCRIPTION = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
+AUTHOR = 'Bioinformatics Laboratory, FRI UL'
+AUTHOR_EMAIL = 'contact@orange.biolab.si'
+URL = 'http://orange.biolab.si/addons/'
+DOWNLOAD_URL = 'https://bitbucket.org/biolab/orange-text/downloads'
+LICENSE = 'GPLv3'
 
-extra_compile_args=[
-        '-fno-strict-aliasing',
-        '-Wall',
-        '-Wno-sign-compare',
-        '-Woverloaded-virtual'
-        ]
+KEYWORDS = (
+    'data mining',
+    'machine learning',
+    'artificial intelligence',
+    'text mining',
+    'orange',
+    'orange add-on',
+)
 
-if sys.platform == "win32":
-    # For mingw compiler
-    extra_link_args=["-static-libgcc", "-static-libstdc++"] 
-else:
-    extra_link_args = []
-    
-# list all documentation files that need to be included
-docFiles = []
-for (dirp, dirns, n) in os.walk('doc'):
-	nr = [n1.replace('\\', '/') for n1 in n]
-	dirn = dirp.replace('\\', '/')[4:]
-	if len(dirn):
-		dirn = dirn + '/'
-	docFiles.extend( [dirn + n1r for n1r in nr if '.svn' not in dirp + '/' + n1r] )
+CLASSIFIERS = (
+    'Development Status :: 4 - Beta',
+    'Environment :: X11 Applications :: Qt',
+    'Environment :: Console',
+    'Environment :: Plugins',
+    'Programming Language :: Python',
+    'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
+    'Operating System :: OS Independent',
+    'Topic :: Scientific/Engineering :: Artificial Intelligence',
+    'Topic :: Scientific/Engineering :: Visualization',
+    'Topic :: Software Development :: Libraries :: Python Modules',
+    'Intended Audience :: Education',
+    'Intended Audience :: Science/Research',
+    'Intended Audience :: Developers',
+)
 
-modules = [
-        Extension(
-                '_orngTextWrapper',
-                sources=[
-                                'source/orngTextWrapper/Wrapper_wrap.cxx',
-                                'source/orngTextWrapper/Wrapper.cpp',
-                                'source/tmt/common/Common.cpp',
-                                'source/tmt/common/Files.cpp',
-                                'source/tmt/lemmatization/FSADictionary.cpp',
-                                'source/tmt/lemmatization/FSALemmatization.cpp',
-                                'source/tmt/lemmatization/Lemmatization.cpp',
-                                'source/tmt/lemmatization/PorterStemmer.cpp',
-                                'source/tmt/strings/StringUtils.cpp',
-                                'source/tmt/strings/UTF8Tokenizer.cpp',
-                                'source/lemmagen/RdrLemmatizer.cpp'
-                ],
-                extra_compile_args=extra_compile_args,
-                include_dirs=['.', 'source'],
-                define_macros=[('TMTNOZLIB','1'), ('NDEBUG', '1')],
-                language='c++',
-                extra_link_args=extra_link_args
-        )
+PACKAGES = find_packages(
+    exclude = ('*.tests', '*.tests.*', 'tests.*', 'tests'),
+)
+
+PACKAGE_DATA = {
+}
+
+SETUP_REQUIRES = (
+    'setuptools',
+)
+
+INSTALL_REQUIRES = (
+    'Orange',
+    'setuptools',
+),
+
+EXTRAS_REQUIRE = {
+    'GUI': (
+        # Dependencies which are problematic to install automatically
+        #'PyQt', # No setup.py
+    ),
+}
+
+DEPENDENCY_LINKS = (
+)
+
+ENTRY_POINTS = {
+    'orange.addons': (
+        'text = _text',
+    ),
+    'orange.widgets': (
+        'Text Mining = _text.widgets',
+    ),
+}
+
+extra_compile_args = [
+    '-fno-strict-aliasing',
+    '-Wall',
+    '-Wno-sign-compare',
+    '-Woverloaded-virtual',
 ]
 
-DEST_DIR="Orange/add-ons/Text"
+extra_link_args = [
+]
 
-if os.path.exists("VERSION.txt"):
-    VERSION = open("VERSION.txt", "rb").read()
+if sys.platform == 'win32':
+    # For MinGW compiler
+    extra_link_args += [
+        '-static-libgcc',
+        '-static-libstdc++',
+    ]
+    
+EXT_MODULES = [
+    Extension(
+        '_text._orngTextWrapper',
+        sources = [
+            'src/orngTextWrapper/Wrapper_wrap.cxx',
+            'src/orngTextWrapper/Wrapper.cpp',
+            'src/tmt/common/Common.cpp',
+            'src/tmt/common/Files.cpp',
+            'src/tmt/lemmatization/FSADictionary.cpp',
+            'src/tmt/lemmatization/FSALemmatization.cpp',
+            'src/tmt/lemmatization/Lemmatization.cpp',
+            'src/tmt/lemmatization/PorterStemmer.cpp',
+            'src/tmt/strings/StringUtils.cpp',
+            'src/tmt/strings/UTF8Tokenizer.cpp',
+            'src/lemmagen/RdrLemmatizer.cpp',
+        ],
+        language = 'c++',
+        extra_compile_args = extra_compile_args,
+        extra_link_args = extra_link_args,
+        include_dirs = [
+            os.path.abspath(os.path.join(os.path.dirname(__file__), 'src')),
+        ],
+        define_macros = [
+            ('TMTNOZLIB', '1'),
+            ('NDEBUG', '1'),
+        ],
+    ),
+]
 
-if have_setuptools:
-    setuptool_args = {"install_requires": ["Orange"],
-                      "zip_safe": False,
-                     }
-else:
-    setuptool_args = {}
-    
-    
-PACKAGES = [ 'widgets', 'widgets.prototypes', 'doc', '' ]
-
-PACKAGE_DATA = {'doc': docFiles, 
-                'widgets': ['icons/*.png'],
-                '': ['addon.xml']
-                }
-
-if __name__ == "__main__":
-        setup(name = NAME,
-              version = VERSION,
-              description = DESCRIPTION,
-              long_description = LONG_DESCRIPTION,
-              author = AUTHOR,
-              url = URL,
-              download_url = DOWNLOAD_URL,
-              license = LICENSE,
-              package_dir = {"": "."},
-              packages = PACKAGES,
-              package_data = PACKAGE_DATA,
-              py_modules = [ 'orngText', 'orngTextWrapper', 'textConfiguration'],
-              extra_path = ("orange-text", DEST_DIR),
-              ext_modules = modules,
-              **setuptool_args)
-
+if __name__ == '__main__':
+    setup(
+        name = NAME,
+        version = VERSION,
+        description = DESCRIPTION,
+        long_description = LONG_DESCRIPTION,
+        author = AUTHOR,
+        author_email = AUTHOR_EMAIL,
+        url = URL,
+        download_url = DOWNLOAD_URL,
+        license = LICENSE,
+        keywords = KEYWORDS,
+        classifiers = CLASSIFIERS,
+        packages = PACKAGES,
+        package_data = PACKAGE_DATA,
+        setup_requires = SETUP_REQUIRES,
+        install_requires = INSTALL_REQUIRES,
+        extras_require = EXTRAS_REQUIRE,
+        dependency_links = DEPENDENCY_LINKS,
+        entry_points = ENTRY_POINTS,
+        include_package_data = True,
+        zip_safe = False,
+        ext_modules = EXT_MODULES,
+    )