Changeset 9879:ba03d04ad9e0 in orange for setup.py


Ignore:
Timestamp:
02/07/12 09:34:19 (2 years ago)
Author:
ales_erjavec
Branch:
default
Message:

Changed installation layout. Orange package is installed directly in site-packages dir, and a .pth file is created to put Orange/orng into PYTHONPATH for direct importing of orng* modules.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • setup.py

    r9777 r9879  
    77from distutils.command.build_ext import build_ext 
    88from distutils.command.install_lib import install_lib 
     9from distutils.command.install import install 
     10from distutils.util import convert_path 
    911from distutils.msvccompiler import MSVCCompiler 
    1012from distutils.unixccompiler import UnixCCompiler 
     
    8385        build_ext.finalize_options(self) 
    8486        # add the build_lib dir and build_temp (for  
    85         # liborange_include and liborange)             
     87        # liborange_include and liborange linking)             
    8688        if not self.inplace: 
    87             self.library_dirs.append(self.build_lib) # for linking with liborange.so 
    88             self.library_dirs.append(self.build_temp) # for linking with liborange_include.a 
     89            # for linking with liborange.so (it is in Orange package) 
     90            self.library_dirs.append(os.path.join(self.build_lib, "Orange")) 
     91            # for linking with liborange_include.a 
     92            self.library_dirs.append(self.build_temp) 
    8993        else: 
    90             self.library_dirs.append("./orange") # for linking with liborange.so 
    91             self.library_dirs.append(self.build_temp) # for linking with liborange_include.a 
     94            # for linking with liborange.so 
     95            self.library_dirs.append("./Orange")  
     96            # for linking with liborange_include.a 
     97            self.library_dirs.append(self.build_temp) 
    9298         
    9399    def build_extension(self, ext): 
     
    113119                    os.chdir(ext_path) 
    114120                    # Get the shared library name 
    115                     lib_filename = self.compiler.library_filename(ext.name, lib_type="shared") 
     121                    _, name = ext.name.rsplit(".", 1) 
     122                    lib_filename = self.compiler.library_filename(name, lib_type="shared") 
    116123                    # Create the link 
    117124                    copy_file(ext_filename, lib_filename, link="sym") 
     
    367374        # because copy_tree fails to overwrite it 
    368375        #  
    369         liborange = os.path.join(self.install_dir, "liborange.so") 
     376        liborange = os.path.join(self.install_dir, "Orange", "liborange.so") 
    370377        if self.force and os.path.exists(liborange) and os.path.islink(liborange): 
    371378            log.info("unlinking %s -> %s", liborange, os.path.join(self.install_dir, "orange.so")) 
     
    373380             
    374381        return install_lib.install(self) 
     382     
     383     
     384class my_install(install): 
     385    """ A command to install orange while also creating 
     386    a .pth path to access the old orng* modules and orange,  
     387    orangeom etc.  
     388     
     389    """ 
     390    def run(self): 
     391        install.run(self) 
     392         
     393        # Create a .pth file wiht a path inside the Orange/orng directory 
     394        # so the old modules are importable 
     395        self.path_file, self.extra_dirs = ("orange-orng-modules", "Orange/orng") 
     396        self.extra_dirs = convert_path(self.extra_dirs) 
     397        log.info("creating portal path for orange compatibility.") 
     398        self.create_path_file() 
     399        self.path_file, self.extra_dirs = None, None 
    375400         
    376401             
     
    380405    return files 
    381406 
    382 include_ext = LibStatic("orange_include", get_source_files("source/include/"), include_dirs=include_dirs) 
     407 
     408include_ext = LibStatic("orange_include", 
     409                        get_source_files("source/include/"), 
     410                        include_dirs=include_dirs) 
    383411 
    384412 
     
    429457                                      libraries=orange_libraries, 
    430458                                      extra_pyxtract_cmds = ["../pyxtract/defvectors.py"], 
    431 #                                      depends=["orange/ppp/lists"] 
    432459                                      ) 
    433460 
    434461if sys.platform == "darwin": 
    435462    build_shared_cmd = get_config_var("BLDSHARED") 
    436     if "-bundle" in build_shared_cmd.split(): #dont link liborange.so with orangeom and orangene - MacOS X treats loadable modules and shared libraries different 
     463    # Dont link liborange.so with orangeom and orangene - MacOS X treats 
     464    # loadable modules and shared libraries different 
     465    if "-bundle" in build_shared_cmd.split(): 
    437466        shared_libs = libraries 
    438467    else: 
     
    484513import fnmatch 
    485514matches = [] 
    486 for root, dirnames, filenames in os.walk('Orange'): #Recursively find 
    487 # '__init__.py's 
     515 
     516#Recursively find '__init__.py's 
     517for root, dirnames, filenames in os.walk('Orange'):  
     518 
    488519  for filename in fnmatch.filter(filenames, '__init__.py'): 
    489520      matches.append(os.path.join(root, filename)) 
     
    498529    setuptools_args = {} 
    499530 
    500 setup(cmdclass={"build_ext": pyxtract_build_ext, "install_lib": my_install_lib}, 
     531setup(cmdclass={"build_ext": pyxtract_build_ext, 
     532                "install_lib": my_install_lib, 
     533                "install": my_install}, 
    501534      name ="Orange", 
    502535      version = "2.5a2", 
     
    505538      author_email = "orange@fri.uni-lj.si", 
    506539      url = "http://orange.biolab.si", 
    507       download_url = "http://orange.biolab.si/svn/orange/trunk", 
     540      download_url = "https://bitbucket.org/biolab/orange/downloads", 
    508541      packages = packages + ["Orange.OrangeCanvas", 
    509542                             "Orange.OrangeWidgets", 
     
    520553                             "Orange.OrangeWidgets.plot.primitives", 
    521554                             "Orange.doc", 
    522                              "", # Backward compatibility 
    523555                             ], 
    524       package_dir = {"Orange": "Orange", 
    525                      "" : "Orange/orng"}, # Backward compatibility 
     556       
    526557      package_data = {"Orange": [ 
    527558          "OrangeCanvas/icons/*.png", 
     
    547578          "orangerc.cfg"] 
    548579                      }, 
    549       ext_modules = [include_ext, orange_ext, orangeom_ext, orangene_ext, corn_ext, statc_ext], 
    550       extra_path=("orange", "orange"), 
     580      ext_modules = [include_ext, orange_ext, orangeom_ext, 
     581                     orangene_ext, corn_ext, statc_ext], 
    551582      scripts = ["bin/orange-canvas"], 
    552583      license = "GNU General Public License (GPL)", 
Note: See TracChangeset for help on using the changeset viewer.