source: orange/setup.py @ 11622:aa4629f97256

Revision 11622:aa4629f97256, 30.1 KB checked in by Ales Erjavec <ales.erjavec@…>, 9 months ago (diff)

Set the minimum distutils version back to 0.6.26.

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