Changeset 10424:f6a8e53e283b in orange


Ignore:
Timestamp:
03/02/12 10:21:06 (2 years ago)
Author:
anzeh <anze.staric@…>
Branch:
default
Message:

Rearrangement of setup.py (inspired by numpy).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • setup.py

    r10391 r10424  
    11#!usr/bin/env python 
     2"""Orange: Machine learning and interactive data mining toolbox. 
     3 
     4Orange is a scriptable environment for fast prototyping of new 
     5algorithms and testing schemes. It is a collection of Python packages 
     6that sit over the core library and implement some functionality for 
     7which execution time is not crucial and which is easier done in Python 
     8than in C++. This includes a variety of tasks such as attribute subset, 
     9bagging and boosting, and alike. 
     10 
     11Orange also includes a set of graphical widgets that use methods from 
     12core library and Orange modules. Through visual programming, widgets 
     13can be assembled together into an application by a visual programming 
     14tool called Orange Canvas. 
     15""" 
     16 
     17DOCLINES = __doc__.split("\n") 
    218 
    319import os, sys         
     
    1834from distutils.msvccompiler import MSVCCompiler 
    1935from distutils.unixccompiler import UnixCCompiler 
    20   
     36import subprocess 
     37 
     38CLASSIFIERS = """\ 
     39Development Status :: 4 - Beta 
     40Programming Language :: Python 
     41License :: OSI Approved :: GNU General Public License (GPL) 
     42Operating System :: POSIX 
     43Operating System :: Microsoft :: Windows 
     44Topic :: Scientific/Engineering :: Artificial Intelligence 
     45Topic :: Scientific/Engineering :: Visualization 
     46Intended Audience :: Education 
     47Intended Audience :: Science/Research 
     48""" 
     49 
     50KEYWORDS = """\ 
     51data mining 
     52machine learning 
     53artificial intelligence 
     54""" 
     55 
     56NAME                = 'Orange' 
     57DESCRIPTION         = DOCLINES[0] 
     58LONG_DESCRIPTION    = "\n".join(DOCLINES[2:]) 
     59URL                 = "http://orange.biolab.si" 
     60DOWNLOAD_URL        = "https://bitbucket.org/biolab/orange/downloads" 
     61LICENSE             = 'GNU General Public License (GPL)' 
     62CLASSIFIERS         = filter(None, CLASSIFIERS.split('\n')) 
     63AUTHOR              = "Bioinformatics Laboratory, FRI UL" 
     64AUTHOR_EMAIL        = "orange@fri.uni-lj.si" 
     65KEYWORDS            = filter(None, KEYWORDS.split('\n')) 
     66MAJOR               = 2 
     67MINOR               = 5 
     68MICRO               = 0 
     69ISRELEASED          = False 
     70VERSION             = '%d.%d.%da5' % (MAJOR, MINOR, MICRO) 
     71 
    2172if have_setuptools: 
    2273    setuptools_args = {"zip_safe": False, 
     
    542593                      ) 
    543594     
    544 import fnmatch 
    545 matches = [] 
    546  
    547 #Recursively find '__init__.py's 
    548 for root, dirnames, filenames in os.walk('Orange'):  
    549  
    550   for filename in fnmatch.filter(filenames, '__init__.py'): 
    551       matches.append(os.path.join(root, filename)) 
    552 packages = [os.path.dirname(pkg).replace(os.path.sep, '.') for pkg in matches] 
    553  
    554  
    555 default_version = "2.5a4" 
    556 ############################################ 
    557 # Try to get the hg revision. Do 
    558 #     $ hg parent --template="2.5a3-r{rev} > version 
    559 # before running setup.py (note the example shown does  
    560 # not conform to StrictVersion needed by bdist_msi).  
    561 ############################################ 
    562 if os.path.exists("version"): 
    563     f = open("version") 
    564     version = f.read() 
    565 else: 
    566     version = default_version 
    567      
    568  
    569 setup(cmdclass={"build_ext": pyxtract_build_ext, 
    570                 "install_lib": my_install_lib, 
    571                 "install": my_install}, 
    572       name ="Orange", 
    573       version = version, 
    574       description = "Machine learning and interactive data mining toolbox.", 
    575       author = "Bioinformatics Laboratory, FRI UL", 
    576       author_email = "orange@fri.uni-lj.si", 
    577       url = "http://orange.biolab.si", 
    578       download_url = "https://bitbucket.org/biolab/orange/downloads", 
    579       packages = packages + ["Orange.OrangeCanvas", 
    580                              "Orange.OrangeWidgets", 
    581                              "Orange.OrangeWidgets.Associate", 
    582                              "Orange.OrangeWidgets.Classify", 
    583                              "Orange.OrangeWidgets.Data", 
    584                              "Orange.OrangeWidgets.Evaluate", 
    585                              "Orange.OrangeWidgets.Prototypes", 
    586                              "Orange.OrangeWidgets.Regression", 
    587                              "Orange.OrangeWidgets.Unsupervised", 
    588                              "Orange.OrangeWidgets.Visualize", 
    589                              "Orange.OrangeWidgets.Visualize Qt", 
    590                              "Orange.OrangeWidgets.plot", 
    591                              "Orange.OrangeWidgets.plot.primitives", 
    592                              ], 
    593        
    594       package_data = { 
    595           "Orange" : ["orangerc.cfg", "doc/datasets/*.tab", "doc/datasets/*.csv", "doc/datasets/*.basket", 
    596                       "doc/networks/*.net", "doc/networks/*.tab", 
    597                       "doc/style.css", "doc/widgets/*/*.*", 
    598                       "testing/regression/tests_20/*.tab", 
    599                       "testing/regression/tests_20/*.net", 
    600                       "testing/regression/tests_20/*.basket", 
    601                       "testing/regression/tests_20/*.csv"], 
    602           "Orange.OrangeCanvas": ["icons/*.png", "orngCanvas.pyw", "WidgetTabs.txt"], 
    603           "Orange.OrangeWidgets":["icons/*.png", "icons/backgrounds/*.png", "report/index.html"], 
    604           "Orange.OrangeWidgets.Associate": ["icons/*.png"], 
    605           "Orange.OrangeWidgets.Classify": ["icons/*.png"], 
    606           "Orange.OrangeWidgets.Data": ["icons/*.png"], 
    607           "Orange.OrangeWidgets.Evaluate": ["icons/*.png"], 
    608           "Orange.OrangeWidgets.Prototypes": ["icons/*.png"], 
    609           "Orange.OrangeWidgets.Regression": ["icons/*.png"], 
    610           "Orange.OrangeWidgets.Unsupervised": ["icons/*.png"], 
    611           "Orange.OrangeWidgets.Visualize": ["icons/*.png"], 
    612           "Orange.OrangeWidgets.Visualize Qt": ["icons/*.png"], 
    613           "Orange.OrangeWidgets.plot": ["*.gs", "*.vs"], 
    614           "Orange.OrangeWidgets.plot.primitives": ["*.obj"], 
    615           }, 
    616       ext_modules = [include_ext, orange_ext, orangeom_ext, 
    617                      orangene_ext, corn_ext, statc_ext], 
    618       scripts = ["bin/orange-canvas"], 
    619       license = "GNU General Public License (GPL)", 
    620       keywords = ["data mining", "machine learning", "artificial intelligence"], 
    621       classifiers = ["Development Status :: 4 - Beta", 
    622                      "Programming Language :: Python", 
    623                      "License :: OSI Approved :: GNU General Public License (GPL)", 
    624                      "Operating System :: POSIX", 
    625                      "Operating System :: Microsoft :: Windows", 
    626                      "Topic :: Scientific/Engineering :: Artificial Intelligence", 
    627                      "Topic :: Scientific/Engineering :: Visualization", 
    628                      "Intended Audience :: Education", 
    629                      "Intended Audience :: Science/Research" 
    630                      ], 
    631       long_description="""\ 
    632 Orange data mining library 
    633 ========================== 
    634  
    635 Orange is a scriptable environment for fast prototyping of new 
    636 algorithms and testing schemes. It is a collection of Python packages 
    637 that sit over the core library and implement some functionality for 
    638 which execution time is not crucial and which is easier done in Python 
    639 than in C++. This includes a variety of tasks such as attribute subset, 
    640 bagging and boosting, and alike. 
    641  
    642 Orange also includes a set of graphical widgets that use methods from  
    643 core library and Orange modules. Through visual programming, widgets 
    644 can be assembled together into an application by a visual programming 
    645 tool called Orange Canvas. 
    646 """, 
    647       **setuptools_args) 
    648        
    649  
     595 
     596def get_packages(): 
     597    import fnmatch 
     598    matches = [] 
     599 
     600    #Recursively find '__init__.py's 
     601    for root, dirnames, filenames in os.walk('Orange'): 
     602      # Add packages for Orange 
     603      for filename in fnmatch.filter(filenames, '__init__.py'): 
     604          matches.append(os.path.join(root, filename)) 
     605    return [os.path.dirname(pkg).replace(os.path.sep, '.') for pkg in matches] 
     606 
     607def get_package_data(): 
     608    package_data = { 
     609        "Orange": 
     610            ["orangerc.cfg", "doc/style.css", "doc/widgets/*/*.*"] +\ 
     611             all_with_extension(path="doc/datasets", extensions=("tab", "csv", "basket")) +\ 
     612             all_with_extension(path="doc/networks", extensions=("net", "tab")) +\ 
     613             all_with_extension(path="testing/regression/tests_20", extensions=("net", "tab", "basket", "csv")), 
     614        "Orange.OrangeCanvas": ["icons/*.png", "orngCanvas.pyw", "WidgetTabs.txt"], 
     615        "Orange.OrangeWidgets": ["icons/*.png", "icons/backgrounds/*.png", "report/index.html"], 
     616        "Orange.OrangeWidgets.Associate": ["icons/*.png"], 
     617        "Orange.OrangeWidgets.Classify": ["icons/*.png"], 
     618        "Orange.OrangeWidgets.Data": ["icons/*.png"], 
     619        "Orange.OrangeWidgets.Evaluate": ["icons/*.png"], 
     620        "Orange.OrangeWidgets.Prototypes": ["icons/*.png"], 
     621        "Orange.OrangeWidgets.Regression": ["icons/*.png"], 
     622        "Orange.OrangeWidgets.Unsupervised": ["icons/*.png"], 
     623        "Orange.OrangeWidgets.Visualize": ["icons/*.png"], 
     624        "Orange.OrangeWidgets.Visualize Qt": ["icons/*.png"], 
     625        "Orange.OrangeWidgets.plot": ["*.gs", "*.vs"], 
     626        "Orange.OrangeWidgets.plot.primitives": ["*.obj"], 
     627    } 
     628 
     629    return package_data 
     630 
     631def all_with_extension(path, extensions): 
     632    return [os.path.join(path, "*.%s"%extension) for extension in extensions] 
     633 
     634def hg_revision(): 
     635    # Copied from numpy setup.py and modified to work with hg 
     636    def _minimal_ext_cmd(cmd): 
     637        # construct minimal environment 
     638        env = {} 
     639        for k in ['SYSTEMROOT', 'PATH']: 
     640            v = os.environ.get(k) 
     641            if v is not None: 
     642                env[k] = v 
     643        # LANGUAGE is used on win32 
     644        env['LANGUAGE'] = 'C' 
     645        env['LANG'] = 'C' 
     646        env['LC_ALL'] = 'C' 
     647        out = subprocess.Popen(cmd, stdout = subprocess.PIPE, env=env).communicate()[0] 
     648        return out 
     649 
     650    try: 
     651        out = _minimal_ext_cmd(['hg', 'ide', '-i']) 
     652        HG_REVISION = out.strip().decode('ascii') 
     653    except OSError: 
     654        HG_REVISION = "Unknown" 
     655 
     656    return HG_REVISION 
     657 
     658def write_version_py(filename='Orange/version.py'): 
     659    # Copied from numpy setup.py 
     660    cnt = """ 
     661# THIS FILE IS GENERATED FROM ORANGE SETUP.PY 
     662short_version = '%(version)s' 
     663version = '%(version)s' 
     664full_version = '%(full_version)s' 
     665hg_revision = '%(hg_revision)s' 
     666release = %(isrelease)s 
     667 
     668if not release: 
     669    version = full_version 
     670""" 
     671    FULLVERSION = VERSION 
     672    if os.path.exists('.hg'): 
     673        HG_REVISION = hg_revision() 
     674    elif os.path.exists('Orange/version.py'): 
     675        # must be a source distribution, use existing version file 
     676        from Orange.version import hg_revision as HG_REVISION 
     677    else: 
     678        HG_REVISION = "Unknown" 
     679 
     680    if not ISRELEASED: 
     681        FULLVERSION += '.dev-' + HG_REVISION[:7] 
     682 
     683    a = open(filename, 'w') 
     684    try: 
     685        a.write(cnt % {'version': VERSION, 
     686                       'full_version' : FULLVERSION, 
     687                       'hg_revision' : HG_REVISION, 
     688                       'isrelease': str(ISRELEASED)}) 
     689    finally: 
     690        a.close() 
     691 
     692def setup_package(): 
     693    write_version_py() 
     694 
     695    setup(name =NAME, 
     696          description = DESCRIPTION, 
     697          version = VERSION, 
     698          author = AUTHOR, 
     699          author_email = AUTHOR_EMAIL, 
     700          url = URL, 
     701          download_url = DOWNLOAD_URL, 
     702          classifiers = CLASSIFIERS, 
     703          long_description=LONG_DESCRIPTION, 
     704          license = LICENSE, 
     705          keywords = KEYWORDS, 
     706 
     707          cmdclass={"build_ext": pyxtract_build_ext, 
     708                    "install_lib": my_install_lib, 
     709                    "install": my_install}, 
     710          packages = get_packages(), 
     711          package_data = get_package_data(), 
     712          ext_modules = [include_ext, orange_ext, orangeom_ext, 
     713                         orangene_ext, corn_ext, statc_ext], 
     714          scripts = ["bin/orange-canvas"], 
     715          **setuptools_args) 
     716 
     717if __name__ == '__main__': 
     718    setup_package() 
Note: See TracChangeset for help on using the changeset viewer.