source: orange/setup.py @ 11306:a4b336affb0f

Revision 11306:a4b336affb0f, 29.9 KB checked in by Ales Erjavec <ales.erjavec@…>, 15 months ago (diff)

Removed new orange-canvas gui script, reverted to the old one.

  • Property exe set to *
Line 
1#!/usr/bin/env python2
2
3try:
4    import distribute_setup
5    distribute_setup.use_setuptools()
6except ImportError:
7    # For documentation we load setup.py to get version
8    # so it does not matter if importing fails
9    pass
10
11import glob, os, sys, types
12from distutils import log
13from distutils.command.build import build
14from distutils.command.build_ext import build_ext
15from distutils.command.install_lib import install_lib
16from distutils.dep_util import newer_group
17from distutils.errors import DistutilsSetupError
18from distutils.file_util import copy_file
19from distutils.msvccompiler import MSVCCompiler
20from distutils.unixccompiler import UnixCCompiler
21from distutils.util import convert_path
22from distutils.sysconfig import get_python_inc, get_config_var
23import subprocess
24from subprocess import check_call
25
26from setuptools import setup, find_packages
27from setuptools.command.install import install
28
29# Has to be last import as it seems something is changing it somewhere
30from distutils.extension import Extension
31
32NAME = 'Orange'
33
34VERSION = '2.6.1'
35ISRELEASED = False
36
37DESCRIPTION = 'Orange, a component-based data mining framework.'
38LONG_DESCRIPTION = open(os.path.join(os.path.dirname(__file__), 'README.txt')).read()
39AUTHOR = 'Bioinformatics Laboratory, FRI UL'
40AUTHOR_EMAIL = 'contact@orange.biolab.si'
41URL = 'http://orange.biolab.si/'
42DOWNLOAD_URL = 'https://bitbucket.org/biolab/orange/downloads'
43LICENSE = 'GPLv3'
44
45KEYWORDS = (
46    'data mining',
47    'machine learning',
48    'artificial intelligence',
49)
50
51CLASSIFIERS = (
52    'Development Status :: 4 - Beta',
53    'Environment :: X11 Applications :: Qt',
54    'Environment :: Console',
55    'Environment :: Plugins',
56    'Programming Language :: Python',
57    'Framework :: Orange',
58    'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
59    'Operating System :: POSIX',
60    'Operating System :: Microsoft :: Windows',
61    'Topic :: Scientific/Engineering :: Artificial Intelligence',
62    'Topic :: Scientific/Engineering :: Visualization',
63    'Topic :: Software Development :: Libraries :: Python Modules',
64    'Intended Audience :: Education',
65    'Intended Audience :: Science/Research',
66    'Intended Audience :: Developers',
67)
68
69try:
70    import numpy
71    numpy_include_dir = numpy.get_include()
72except ImportError:
73    # When setup.py is first run to install orange, numpy can still be missing
74    pass
75    numpy_include_dir = None
76
77python_include_dir = get_python_inc(plat_specific=1)
78
79include_dirs = [python_include_dir, numpy_include_dir, 'source/include']
80
81if sys.platform == 'darwin':
82    extra_compile_args = '-fPIC -fpermissive -fno-common -w -DDARWIN'.split()
83    extra_link_args = '-headerpad_max_install_names -undefined dynamic_lookup'.split()
84elif sys.platform == 'win32':
85    extra_compile_args = ['-EHsc']
86    extra_link_args = []
87elif sys.platform.startswith('linux'):
88    extra_compile_args = '-fPIC -fpermissive -w -DLINUX'.split()
89    extra_link_args = ['-Wl,-R$ORIGIN']
90else:
91    extra_compile_args = []
92    extra_link_args = []
93
94# Get the command for building orangeqt extension from
95# source/orangeqt/setup.py file.
96# Fails without PyQt4.
97import imp
98try:
99    orangeqt_setup = imp.load_source('orangeqt_setup', os.path.join(os.path.dirname(__file__), 'source/orangeqt/setup.py'))
100    build_pyqt_ext = orangeqt_setup.build_pyqt_ext
101except ImportError:
102    orangeqt_setup = None
103    build_pyqt_ext = None
104
105class LibStatic(Extension):
106    pass
107
108class PyXtractExtension(Extension):
109    def __init__(self, *args, **kwargs):
110        for name, default in [("extra_pyxtract_cmds", []), ("lib_type", "dynamic")]:
111            setattr(self, name, kwargs.get(name, default))
112            if name in kwargs:
113                del kwargs[name]
114
115        Extension.__init__(self, *args, **kwargs)
116
117class PyXtractSharedExtension(PyXtractExtension):
118    pass
119
120class pyxtract_build_ext(build_ext):
121    def run_pyxtract(self, ext, dir):
122        original_dir = os.path.realpath(os.path.curdir)
123        log.info("running pyxtract for %s" % ext.name)
124        try:
125            os.chdir(dir)
126            ## we use the commands which are used for building under windows
127            pyxtract_cmds = [cmd.split() for cmd in getattr(ext, "extra_pyxtract_cmds", [])]
128            if os.path.exists("_pyxtract.bat"):
129                pyxtract_cmds.extend([cmd.split()[1:] for cmd in open("_pyxtract.bat").read().strip().splitlines()])
130            for cmd in pyxtract_cmds:
131                log.info(" ".join([sys.executable] + cmd))
132                check_call([sys.executable] + cmd)
133            if pyxtract_cmds:
134                ext.include_dirs.append(os.path.join(dir, "ppp"))
135                ext.include_dirs.append(os.path.join(dir, "px"))
136
137        finally:
138            os.chdir(original_dir)
139
140    def finalize_options(self):
141        build_ext.finalize_options(self)
142        # add the build_lib dir and build_temp (for
143        # liborange_include and liborange linking)
144        if not self.inplace:
145            # for linking with liborange.so (it is in Orange package)
146            self.library_dirs.append(os.path.join(self.build_lib, "Orange"))
147            # for linking with liborange_include.a
148            self.library_dirs.append(self.build_temp)
149        else:
150            # for linking with liborange.so
151            self.library_dirs.append("./Orange") 
152            # for linking with liborange_include.a
153            self.library_dirs.append(self.build_temp)
154
155    def build_extension(self, ext):
156        if isinstance(ext, LibStatic):
157            # Build static library
158            self.build_static(ext)
159        elif isinstance(ext, PyXtractExtension):
160            # Build pyextract extension
161            self.build_pyxtract(ext)
162        elif orangeqt_setup and isinstance(ext, orangeqt_setup.PyQt4Extension):
163            # Skip the build (will be handled by build_pyqt_ext command)
164            return
165        else:
166            build_ext.build_extension(self, ext)
167
168        if isinstance(ext, PyXtractSharedExtension):
169            # Fix extension modules so they can be linked
170            # by other modules
171            if self.dry_run:
172                # No need to do anything here.
173                return
174
175            if isinstance(self.compiler, MSVCCompiler):
176                # Copy ${TEMP}/orange/orange.lib to ${BUILD}/orange.lib
177                ext_fullpath = self.get_ext_fullpath(ext.name)
178                # Get the last component of the name
179                ext_name = ext.name.rsplit(".", 1)[-1]
180                libs = glob.glob(os.path.join(self.build_temp,
181                                              "*", "*", ext_name + ".lib"))
182                if not libs:
183                    log.info("Could not locate library %r in directory %r" \
184                             % (ext_name, self.build_temp))
185                else:
186                    lib = libs[0]
187                    lib_path = os.path.splitext(ext_fullpath)[0] + ".lib"
188                    copy_file(lib, lib_path, dry_run=self.dry_run)
189            else:
190                # Make lib{name}.so link to {name}.so
191                ext_path = self.get_ext_fullpath(ext.name)
192                ext_path, ext_filename = os.path.split(ext_path)
193                realpath = os.path.realpath(os.curdir)
194                try:
195                    os.chdir(ext_path)
196                    # Get the shared library name
197                    _, name = ext.name.rsplit(".", 1)
198                    lib_filename = self.compiler.library_filename(name, lib_type="shared")
199                    # Create the link
200                    copy_file(ext_filename, lib_filename, link="sym",
201                              dry_run=self.dry_run)
202                except OSError, ex:
203                    log.info("failed to create shared library for %s: %s" % (ext.name, str(ex)))
204                finally:
205                    os.chdir(realpath)
206
207    def build_pyxtract(self, ext):
208        ## mostly copied from build_extension
209        sources = ext.sources
210        if sources is None or type(sources) not in (types.ListType, types.TupleType):
211            raise DistutilsSetupError, \
212                  ("in 'ext_modules' option (extension '%s'), " +
213                   "'sources' must be present and must be " +
214                   "a list of source filenames") % ext.name
215        sources = list(sources)
216
217        ext_path = self.get_ext_fullpath(ext.name)
218
219        depends = sources + ext.depends
220        if not (self.force or newer_group(depends, ext_path, 'newer')):
221            log.debug("skipping '%s' extension (up-to-date)", ext.name)
222            return
223        else:
224            log.info("building '%s' extension", ext.name)
225
226        # First, scan the sources for SWIG definition files (.i), run
227        # SWIG on 'em to create .c files, and modify the sources list
228        # accordingly.
229        sources = self.swig_sources(sources, ext)
230
231        # Run pyxtract in dir this adds ppp and px dirs to include_dirs
232        dir = os.path.commonprefix([os.path.split(s)[0] for s in ext.sources])
233        self.run_pyxtract(ext, dir)
234
235        # Next, compile the source code to object files.
236
237        # XXX not honouring 'define_macros' or 'undef_macros' -- the
238        # CCompiler API needs to change to accommodate this, and I
239        # want to do one thing at a time!
240
241        # Two possible sources for extra compiler arguments:
242        #   - 'extra_compile_args' in Extension object
243        #   - CFLAGS environment variable (not particularly
244        #     elegant, but people seem to expect it and I
245        #     guess it's useful)
246        # The environment variable should take precedence, and
247        # any sensible compiler will give precedence to later
248        # command line args.  Hence we combine them in order:
249        extra_args = ext.extra_compile_args or []
250
251        macros = ext.define_macros[:]
252        for undef in ext.undef_macros:
253            macros.append((undef,))
254
255        objects = self.compiler.compile(sources,
256                                         output_dir=self.build_temp,
257                                         macros=macros,
258                                         include_dirs=ext.include_dirs,
259                                         debug=self.debug,
260                                         extra_postargs=extra_args,
261                                         depends=ext.depends)
262
263        # XXX -- this is a Vile HACK!
264        #
265        # The setup.py script for Python on Unix needs to be able to
266        # get this list so it can perform all the clean up needed to
267        # avoid keeping object files around when cleaning out a failed
268        # build of an extension module.  Since Distutils does not
269        # track dependencies, we have to get rid of intermediates to
270        # ensure all the intermediates will be properly re-built.
271        #
272        self._built_objects = objects[:]
273
274        # Now link the object files together into a "shared object" --
275        # of course, first we have to figure out all the other things
276        # that go into the mix.
277        if ext.extra_objects:
278            objects.extend(ext.extra_objects)
279        extra_args = ext.extra_link_args or []
280
281        # Detect target language, if not provided
282        language = ext.language or self.compiler.detect_language(sources)
283
284        self.compiler.link_shared_object(
285            objects, ext_path,
286            libraries=self.get_libraries(ext),
287            library_dirs=ext.library_dirs,
288            runtime_library_dirs=ext.runtime_library_dirs,
289            extra_postargs=extra_args,
290            export_symbols=self.get_export_symbols(ext),
291            debug=self.debug,
292            build_temp=self.build_temp,
293            target_lang=language)
294
295
296    def build_static(self, ext):
297        ## mostly copied from build_extension, changed
298        sources = ext.sources
299        if sources is None or type(sources) not in (types.ListType, types.TupleType):
300            raise DistutilsSetupError, \
301                  ("in 'ext_modules' option (extension '%s'), " +
302                   "'sources' must be present and must be " +
303                   "a list of source filenames") % ext.name
304        sources = list(sources)
305
306        # Static libs get build in the build_temp directory
307        output_dir = self.build_temp
308        if not os.path.exists(output_dir): #VSC fails if the dir does not exist
309            os.makedirs(output_dir)
310
311        lib_filename = self.compiler.library_filename(ext.name, lib_type='static', output_dir=output_dir)
312
313        depends = sources + ext.depends
314        if not (self.force or newer_group(depends, lib_filename, 'newer')):
315            log.debug("skipping '%s' extension (up-to-date)", ext.name)
316            return
317        else:
318            log.info("building '%s' extension", ext.name)
319
320        # First, scan the sources for SWIG definition files (.i), run
321        # SWIG on 'em to create .c files, and modify the sources list
322        # accordingly.
323        sources = self.swig_sources(sources, ext)
324
325        # Next, compile the source code to object files.
326
327        # XXX not honouring 'define_macros' or 'undef_macros' -- the
328        # CCompiler API needs to change to accommodate this, and I
329        # want to do one thing at a time!
330
331        # Two possible sources for extra compiler arguments:
332        #   - 'extra_compile_args' in Extension object
333        #   - CFLAGS environment variable (not particularly
334        #     elegant, but people seem to expect it and I
335        #     guess it's useful)
336        # The environment variable should take precedence, and
337        # any sensible compiler will give precedence to later
338        # command line args.  Hence we combine them in order:
339        extra_args = ext.extra_compile_args or []
340
341        macros = ext.define_macros[:]
342        for undef in ext.undef_macros:
343            macros.append((undef,))
344
345        objects = self.compiler.compile(sources,
346                                         output_dir=self.build_temp,
347                                         macros=macros,
348                                         include_dirs=ext.include_dirs,
349                                         debug=self.debug,
350                                         extra_postargs=extra_args,
351                                         depends=ext.depends)
352
353        # XXX -- this is a Vile HACK!
354        #
355        # The setup.py script for Python on Unix needs to be able to
356        # get this list so it can perform all the clean up needed to
357        # avoid keeping object files around when cleaning out a failed
358        # build of an extension module.  Since Distutils does not
359        # track dependencies, we have to get rid of intermediates to
360        # ensure all the intermediates will be properly re-built.
361        #
362        self._built_objects = objects[:]
363
364        # Now link the object files together into a "shared object" --
365        # of course, first we have to figure out all the other things
366        # that go into the mix.
367        if ext.extra_objects:
368            objects.extend(ext.extra_objects)
369        extra_args = ext.extra_link_args or []
370
371        # Detect target language, if not provided
372        language = ext.language or self.compiler.detect_language(sources)
373       
374        #first remove old library (ar only appends the contents if archive already exists)
375        try:
376            os.remove(lib_filename)
377        except OSError, ex:
378            log.debug("failed to remove obsolete static library %s: %s" %(ext.name, str(ex)))
379
380        # The static library is created in the temp dir, it is used during the compile step only
381        # it should not be included in the final install
382        self.compiler.create_static_lib(
383            objects, ext.name, output_dir,
384            debug=self.debug,
385            target_lang=language)
386
387    def get_libraries(self, ext):
388        """ Change the 'orange' library name to 'orange_d' if
389        building in debug mode. Using ``get_ext_filename`` to discover if
390        _d postfix is required.
391       
392        """
393        libraries = build_ext.get_libraries(self, ext)
394        if "orange" in libraries and self.debug:
395            filename = self.get_ext_filename("orange")
396            basename = os.path.basename(filename)
397            name, ext = os.path.splitext(basename)
398            if name.endswith("_d"):
399                index = libraries.index("orange")
400                libraries[index] = "orange_d"
401
402        return libraries
403
404    if not hasattr(build_ext, "get_ext_fullpath"):
405        #On mac OS X python 2.6.1 distutils does not have this method
406        def get_ext_fullpath(self, ext_name):
407            """Returns the path of the filename for a given extension.
408           
409            The file is located in `build_lib` or directly in the package
410            (inplace option).
411            """
412            import string
413            # makes sure the extension name is only using dots
414            all_dots = string.maketrans('/' + os.sep, '..')
415            ext_name = ext_name.translate(all_dots)
416            fullname = self.get_ext_fullname(ext_name)
417            modpath = fullname.split('.')
418            filename = self.get_ext_filename(ext_name)
419            filename = os.path.split(filename)[-1]
420            if not self.inplace:
421                # no further work needed
422                # returning :
423                #   build_dir/package/path/filename
424                filename = os.path.join(*modpath[:-1] + [filename])
425                return os.path.join(self.build_lib, filename)
426            # the inplace option requires to find the package directory
427            # using the build_py command for that
428            package = '.'.join(modpath[0:-1])
429            build_py = self.get_finalized_command('build_py')
430            package_dir = os.path.abspath(build_py.get_package_dir(package))
431            # returning
432            #   package_dir/filename
433            return os.path.join(package_dir, filename)
434
435# Add build_pyqt_ext to build subcommands
436class orange_build(build):
437    def has_pyqt_extensions(self):
438        # For now this is disabled unless specifically requested
439        # using build_pyqt_ext command
440        return False
441#        return any([isinstance(ext, orangeqt_setup.PyQt4Extension) \
442#                   for ext in self.distribution.ext_modules]
443#                   )
444
445    sub_commands = build.sub_commands
446    if orangeqt_setup:
447        sub_commands += [("build_pyqt_ext", has_pyqt_extensions)]
448
449
450class orange_install_lib(install_lib):
451    """ An command to install orange (preserves liborange.so -> orange.so symlink)
452    """
453    def run(self):
454        install_lib.run(self)
455
456    def copy_tree(self, infile, outfile, preserve_mode=1, preserve_times=1,
457                  preserve_symlinks=1, level=1):
458        """ Run copy_tree with preserve_symlinks=1 as default
459        """
460        install_lib.copy_tree(self, infile, outfile, preserve_mode,
461                              preserve_times, preserve_symlinks, level)
462
463    def install(self):
464        """ Copy build_dir to install_dir
465        """
466        # A Hack to unlink liborange.so -> orange.so if it already exists,
467        # because copy_tree fails to overwrite it
468        #
469        liborange = os.path.join(self.install_dir, "Orange", "liborange.so")
470        if os.path.exists(liborange) and os.path.islink(liborange):
471            log.info("unlinking %s -> %s", liborange,
472                     os.path.join(self.install_dir, "orange.so"))
473
474            if not self.dry_run:
475                os.unlink(liborange)
476
477        return install_lib.install(self)
478
479
480class orange_install(install):
481    """ A command to install orange while also creating
482    a .pth path to access the old orng* modules and orange,
483    orangeom etc.
484
485    """
486    def run(self):
487        install.run(self)
488        # Create a .pth file with a path inside the Orange/orng directory
489        # so the old modules are importable
490        self.path_file, self.extra_dirs = ("Orange-orng-modules", "Orange/orng")
491        self.extra_dirs = convert_path(self.extra_dirs)
492        log.info("creating portal path for orange compatibility.")
493        self.create_path_file()
494        self.path_file, self.extra_dirs = None, None
495
496
497def get_source_files(path, ext="cpp", exclude=[]):
498    files = glob.glob(os.path.join(path, "*." + ext))
499    files = [file for file in files if os.path.basename(file) not in exclude]
500    return files
501
502include_ext = LibStatic("orange_include",
503                        get_source_files("source/include/"),
504                        include_dirs=include_dirs)
505
506
507if sys.platform == "win32": # ?? mingw/cygwin
508    libraries = ["orange_include"]
509else:
510    libraries = ["stdc++", "orange_include"]
511
512import ConfigParser
513config = ConfigParser.RawConfigParser()
514
515config.read(["setup-site.cfg",
516             os.path.expanduser("~/.orange-site.cfg")]
517            )
518
519orange_sources = get_source_files("source/orange/")
520orange_include_dirs = list(include_dirs)
521orange_libraries = list(libraries)
522
523if config.has_option("blas", "library"):
524    # Link external blas library
525    orange_libraries += [config.get("blas", "library")]
526else:
527    orange_sources += get_source_files("source/orange/blas/", "c")
528
529if config.has_option("R", "library"):
530    # Link external R library (for linpack)
531    orange_libraries += [config.get("R", "library")]
532else:
533    orange_sources += get_source_files("source/orange/linpack/", "c")
534
535if config.has_option("liblinear", "library"):
536    # Link external LIBLINEAR library
537    orange_libraries += [config.get("liblinear", "library")]
538else:
539    orange_sources += get_source_files("source/orange/liblinear/", "cpp")
540    orange_include_dirs += ["source/orange/liblinear"]
541
542if config.has_option("libsvm", "library"):
543    # Link external LibSVM library
544    orange_libraries += [config.get("libsvm", "library")]
545else:
546    orange_sources += get_source_files("source/orange/libsvm/", "cpp")
547
548orange_ext = PyXtractSharedExtension("Orange.orange", orange_sources,
549                                      include_dirs=orange_include_dirs,
550                                      extra_compile_args = extra_compile_args + ["-DORANGE_EXPORTS"],
551                                      extra_link_args = extra_link_args,
552                                      libraries=orange_libraries,
553                                      extra_pyxtract_cmds = ["../pyxtract/defvectors.py"],
554                                      )
555
556if sys.platform == "darwin":
557    build_shared_cmd = get_config_var("BLDSHARED")
558    # Dont link liborange.so with orangeom and orangene - MacOS X treats
559    # loadable modules and shared libraries different
560    if "-bundle" in build_shared_cmd.split():
561        shared_libs = libraries
562    else:
563        shared_libs = libraries + ["orange"]
564else:
565    shared_libs = libraries + ["orange"]
566
567orangeom_sources = get_source_files("source/orangeom/", exclude=["lib_vectors.cpp"])
568orangeom_libraries = list(shared_libs)
569orangeom_include_dirs = list(include_dirs)
570
571if config.has_option("qhull", "library"):
572    # Link external qhull library
573    orangeom_libraries += [config.get("qhull", "library")]
574else:
575    orangeom_sources += get_source_files("source/orangeom/qhull/", "c")
576    orangeom_include_dirs += ["source/orangeom"]
577
578orangeom_ext = PyXtractExtension("Orange.orangeom", orangeom_sources,
579                                  include_dirs=orangeom_include_dirs + ["source/orange/"],
580                                  extra_compile_args = extra_compile_args + ["-DORANGEOM_EXPORTS"],
581                                  extra_link_args = extra_link_args,
582                                  libraries=orangeom_libraries,
583                                  )
584
585orangene_ext = PyXtractExtension("Orange.orangene",
586    get_source_files("source/orangene/", exclude=["lib_vectors.cpp"]),
587                                  include_dirs=include_dirs + ["source/orange/"], 
588                                  extra_compile_args = extra_compile_args + ["-DORANGENE_EXPORTS"],
589                                  extra_link_args = extra_link_args,
590                                  libraries=shared_libs,
591                                  )
592
593corn_ext = Extension("Orange.corn", get_source_files("source/corn/"),
594                     include_dirs=include_dirs + ["source/orange/"], 
595                     extra_compile_args = extra_compile_args + ["-DCORN_EXPORTS"],
596                     extra_link_args = extra_link_args,
597                     libraries=libraries
598                     )
599
600statc_ext = Extension("Orange.statc", get_source_files("source/statc/"),
601                      include_dirs=include_dirs + ["source/orange/"], 
602                      extra_compile_args = extra_compile_args + ["-DSTATC_EXPORTS"],
603                      extra_link_args = extra_link_args,
604                      libraries=libraries
605                      )
606
607
608ext_modules = [include_ext, orange_ext, orangeom_ext,
609               orangene_ext, corn_ext, statc_ext]
610
611cmdclass = {"build": orange_build,
612            "build_ext": pyxtract_build_ext,
613            "install_lib": orange_install_lib,
614            "install": orange_install}
615                   
616if orangeqt_setup:
617    orangeqt_ext = orangeqt_setup.orangeqt_ext
618    # Fix relative paths, name etc.
619    orangeqt_ext.name = "Orange.orangeqt"
620    orangeqt_ext.sources = ["source/orangeqt/orangeqt.sip"] + \
621                           get_source_files("source/orangeqt", "cpp",
622                                exclude=["canvas3d.cpp", "plot3d.cpp", 
623                                         "glextensions.cpp"]
624                                            )
625
626    orangeqt_ext.include_dirs += ["source/orangeqt"]
627
628    ext_modules += [orangeqt_ext]
629
630    cmdclass["build_pyqt_ext"] = build_pyqt_ext
631
632def all_with_extension(path, extensions):
633    return [os.path.join(path, "*.%s"%extension) for extension in extensions]
634
635# TODO: Simply replace with include_package_data = True and configure missed files in MANIFEST.in?
636
637#Marko 20120128: Removed "doc/style.css", "doc/widgets/*/*.*" from the package
638
639def get_package_data():
640    package_data = {
641        "Orange":
642            ["orangerc.cfg" ] +\
643             all_with_extension(path="datasets", extensions=("tab", "csv", "basket")) +\
644             all_with_extension(path="testing/regression/tests_20", extensions=("net", "tab", "basket", "csv")),
645        "Orange.OrangeCanvas": ["icons/*.png", "icons/*.svg",
646                                "orngCanvas.pyw", "WidgetTabs.txt"],
647        "Orange.OrangeCanvas.styles": ["*.qss", "orange/*.svg"],
648        "Orange.OrangeWidgets": ["icons/*.png", "icons/backgrounds/*.png",
649                                 "report/index.html"],
650        "Orange.OrangeWidgets.Associate": ["icons/*.png", "icons/*.svg"],
651        "Orange.OrangeWidgets.Classify": ["icons/*.png", "icons/*.svg"],
652        "Orange.OrangeWidgets.Data": ["icons/*.png", "icons/*.svg"],
653        "Orange.OrangeWidgets.Evaluate": ["icons/*.png", "icons/*.svg"],
654        "Orange.OrangeWidgets.Prototypes": ["icons/*.png", "icons/*.svg"],
655        "Orange.OrangeWidgets.Regression": ["icons/*.png", "icons/*.svg"],
656        "Orange.OrangeWidgets.Unsupervised": ["icons/*.png", "icons/*.svg"],
657        "Orange.OrangeWidgets.Visualize": ["icons/*.png", "icons/*.svg"],
658        "Orange.OrangeWidgets.Visualize Qt": ["icons/*.png", "icons/*.svg"],
659        "Orange.OrangeWidgets.plot": ["*.gs", "*.vs"],
660        "Orange.OrangeWidgets.plot.primitives": ["*.obj"],
661    }
662
663    return package_data
664
665def hg_revision():
666    # Copied from numpy setup.py and modified to work with hg
667    def _minimal_ext_cmd(cmd):
668        # construct minimal environment
669        env = {}
670        for k in ['SYSTEMROOT', 'PATH']:
671            v = os.environ.get(k)
672            if v is not None:
673                env[k] = v
674        # LANGUAGE is used on win32
675        env['LANGUAGE'] = 'C'
676        env['LANG'] = 'C'
677        env['LC_ALL'] = 'C'
678        out = subprocess.Popen(cmd, stdout = subprocess.PIPE, env=env).communicate()[0]
679        return out
680
681    try:
682        out = _minimal_ext_cmd(['hg', 'ide', '-i'])
683        HG_REVISION = str(out.strip().decode('ascii'))
684    except OSError:
685        HG_REVISION = "Unknown"
686
687    return HG_REVISION
688
689def write_version_py(filename='Orange/version.py'):
690    # Copied from numpy setup.py
691    cnt = """
692# THIS FILE IS GENERATED FROM ORANGE SETUP.PY
693short_version = '%(version)s'
694version = '%(version)s'
695full_version = '%(full_version)s'
696hg_revision = '%(hg_revision)s'
697release = %(isrelease)s
698
699if not release:
700    version = full_version
701"""
702    FULLVERSION = VERSION
703    if os.path.exists('.hg'):
704        HG_REVISION = hg_revision()
705    elif os.path.exists('Orange/version.py'):
706        # must be a source distribution, use existing version file
707        version = imp.load_source("Orange.version", "Orange/version.py")
708        HG_REVISION = version.hg_revision
709    else:
710        HG_REVISION = "Unknown"
711
712    if not ISRELEASED:
713        FULLVERSION += '.dev-' + HG_REVISION[:7]
714
715    a = open(filename, 'w')
716    try:
717        a.write(cnt % {'version': VERSION,
718                       'full_version' : FULLVERSION,
719                       'hg_revision' : HG_REVISION,
720                       'isrelease': str(ISRELEASED)})
721    finally:
722        a.close()
723
724PACKAGES = find_packages()
725
726PACKAGE_DATA = get_package_data()
727
728SETUP_REQUIRES = (
729    'setuptools',
730)
731
732# If you change the requirements, check whether all ADD-ons still work!
733
734INSTALL_REQUIRES = (
735    'setuptools',
736    'numpy',
737)
738
739EXTRAS_REQUIRE = {
740    'GUI': (
741        'PyQt4',
742        'PyQwt',
743    ),
744    'reST': (
745        'numpydoc',
746    ),
747}
748
749DEPENDENCY_LINKS = (
750)
751
752ENTRY_POINTS = {
753#    'gui_scripts': (
754#            'orange-canvas = Orange.OrangeCanvas.main:main',
755#    ),
756    'orange.canvas.help': (
757            'intersphinx = Orange.OrangeWidgets:intersphinx',
758    )
759}
760
761
762def setup_package():
763    write_version_py()
764    setup(
765        name = NAME,
766        version = VERSION,
767        description = DESCRIPTION,
768        long_description = LONG_DESCRIPTION,
769        author = AUTHOR,
770        author_email = AUTHOR_EMAIL,
771        url = URL,
772        download_url = DOWNLOAD_URL,
773        license = LICENSE,
774        keywords = KEYWORDS,
775        classifiers = CLASSIFIERS,
776        packages = PACKAGES,
777        package_data = PACKAGE_DATA,
778        setup_requires = SETUP_REQUIRES,
779        extras_require = EXTRAS_REQUIRE,
780        install_requires = INSTALL_REQUIRES,
781        dependency_links = DEPENDENCY_LINKS,
782        entry_points = ENTRY_POINTS,
783        include_package_data = True,
784        zip_safe = False,
785
786        cmdclass = cmdclass,
787        ext_modules = ext_modules,
788        scripts = (
789            'bin/orange-canvas',
790        ),
791    )
792
793if __name__ == '__main__':
794    setup_package()
Note: See TracBrowser for help on using the repository browser.