Commits

Aleš Erjavec committed f9f319d

Cleanup of setup.py script, use setuptools if available.

Comments (0)

Files changed (1)

-from distutils.core import setup
+#!/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 ssetuptools import setup
+    have_setuptools = True
+except ImportError:
+    from distutils.core import setup
+    have_setuptools = False
+    
 from distutils.core import Extension
 import distutils.ccompiler
 import os, sys, glob
 
+
+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
+"""
+
+KEYWORDS = """\
+data mining 
+machine learning,
+artificial intelligence
+text mining
+"""                      
+
+NAME                = "Orange-Text-Mining"
+DESCRIPTION         = DOCLINES[0]
+LONG_DESCRIPTION    = "\n".join(DOCLINES[2:])
+URL                 = "https://bitbucket.org/biolab/orange-addon-text"
+DOWNLOAD            = "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'))
+
+MAYOR = 1
+MINOR = 1
+MICRO = 0
+ISRELEASED = False
+
+VERSION = "{0}.{1}a.{2}".format(MAYOR,MINOR, MICRO)
+
 extra_compile_args=[
         '-fno-strict-aliasing',
         '-Wall',
                 extra_link_args=extra_link_args
         )
 ]
-destDir="Orange/add-ons/Text"
 
-# list all language files that need to be included
-#lngFiles = glob.glob('language_data/*.bin') + glob.glob('language_data/*.fsa') + glob.glob('language_data/*.txt')
-#lngFiles = [f.replace('\\', '/').split('/')[1] for f in lngFiles]
-def writeMakeFileDepends():
-        f = open("Makefile.depends", "wt")
+DEST_DIR="Orange/add-ons/Text"
 
-        includePaths = []
-        macros = []
-        compileArgs = []
-        for ext in modules:
-                if ext.include_dirs <> []:
-                        for p in ext.include_dirs:
-                                includePaths.append( "-I%s" % (p))
-                if ext.define_macros <> []:
-                        for m in ext.define_macros:
-                                macros.append( "-D%s=%s" % m)
-                if ext.extra_compile_args <> []:
-                        for e in ext.extra_compile_args:
-                                compileArgs.append(e)
-        includePaths = " ".join(includePaths)
-        macros = " ".join(macros)
-        compileArgs = " ".join(compileArgs)
+if os.path.exists("VERSION.txt"):
+    VERSION = open("VERSION.txt", "rb").read()
 
-        compileOptions = " ".join([includePaths, macros, compileArgs])
+if have_setuptools:
+    setuptool_args = {"install_requires": ["Orange"],
+                      "zip_safe": False,
+                     }
+else:
+    setuptool_args = {}
+    
+    
+PACKAGES = [ 'widgets', 'widgets.prototypes', 'doc', '' ]
 
-        if compileOptions <> "":
-                f.write("COMPILEOPTIONSMODULES = %s\n" % (compileOptions))
-        f.write("DESTDIR = $(PYTHONSITEPKGS)/%s\n" % (destDir))
-
-        f.write("modules:")
-        for ext in modules:
-                f.write(" %s.so" % (ext.name))
-        f.write("\n")
-
-        for ext in modules:
-                objs = []
-                for s in ext.sources:
-                        if s[-2:] == '.c' or s[-4:] == '.cpp' or s[-4:] == '.cxx':
-                                objfname = os.path.splitext(os.path.join("..", s))[0] + ".o"
-                                objs.append( objfname)
-                objs = " ".join(objs)
-                f.write("%s.so: %s\n" % (ext.name, objs))
-                f.write("\t$(LINKER) $(LINKOPTIONS) %s -o %s.so\n" % (objs, os.path.join("..", ext.name)))
-                f.write("ifeq ($(OS), Darwin)\n")
-                f.write("\tinstall_name_tool -id $(DESTDIR)/%s.so %s.so\n" % (ext.name, os.path.join("..", ext.name)))
-                f.write("endif\n")
-        f.close()
+PACKAGE_DATA = {'doc': docFiles, 
+                'widgets': ['icons/*.png'],
+                '': ['addon.xml']
+                }
 
 if __name__ == "__main__":
-        setup(name = "Orange Text Mining",
-                version = "0.1.0",
-                description = "Text Mining Add-On for Orange",
-                packages = [ 'widgets', 'widgets.prototypes', 'doc', '.' ],
+        setup(name = NAME,
+              version = VERSION,
+              description = DESCRIPTION,
+              long_description = LONG_DESCRIPTION,
+              package_dir = {"": "."},
+              packages = PACKAGES,
+              package_data = PACKAGE_DATA,
+              py_modules = [ 'orngText', 'orngTextWrapper', 'textConfiguration'],
+              extra_path = ("orange-text", DEST_DIR),
+              ext_modules = modules,
+              url = URL,
+              author = AUTHOR,
+              license = LICENSE,
+              **setuptool_args)
 
-                package_data = {'doc': docFiles, 'widgets': ['icons/*.png'], '.':['addon.xml'] },
-
-                py_modules = [ 'orngText', 'orngTextWrapper', 'textConfiguration'],
-                extra_path = ("orange-text", destDir),
-                ext_modules = modules
-        )
-