setup.py :  » IRC » Skype4Py » Skype4Py-1.0.32.0 » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » IRC » Skype4Py 
Skype4Py » Skype4Py 1.0.32.0 » setup.py
#!/usr/bin/env python
"""
Skype4Py distutils script.

Copyright (c) 2007-2009, Arkadiusz Wahlig

All rights reserved.

Distributed under the BSD License, see the
accompanying LICENSE file for more information.
"""

import sys, os
from distutils.core import setup
from distutils.cmd import Command
from distutils.command.install_lib import install_lib


# Change the current dir to where the setup.py is in case we're not there.
path = os.path.split(sys.argv[0])[0]
if path:
    os.chdir(path)


# So that the Skype4Py library may know that the setup is running.
sys.skype4py_setup = True


# Import Skype4Py version from the distribution package.
from Skype4Py import __version__


class install_lib(old_install_lib):
    """Handles the 'install_lib' command.

    This modified version of install_lib command installs only the necessary
    platform modules from the Skype4Py.api subpackage.
    """

    def install(self):
        # The build is done here, now we have to adapt it to current platform
        # before installing.
        self.adapt_build_to_platform()

        # Let the original method do the hard work of copying the files.
        outfiles = old_install_lib.install(self)

        # Also byte_compile for distribution usage.
        if outfiles is not None:
            self.byte_compile(outfiles)

        return outfiles

    def adapt_build_to_platform(self):
        # We have to remove unneeded files from the build directory. First,
        # decide what platform we're on; this code is similar to the one
        # in Skype4Py/api/__init__.py which decides what submodule to
        # import at runtime.
        if sys.platform[:3] == 'win':
            platform = 'windows'
        elif sys.platform == 'darwin':
            platform = 'darwin'
        else:
            platform = 'posix'

        # Scan the <build_dir>/Skype4Py/api directory and remove all files
        # which names do not start with either '__' (for __init__) or the
        # detected platform.
        path = os.path.join(self.build_dir, os.path.join('Skype4Py', 'api'))
        for name in os.listdir(path):
            if not (name.startswith('__') or name.startswith(platform)):
                os.remove(os.path.join(path, name))


class build_doc(Command):
    """Handles the 'build_doc' command.

    This command builds the documentation using epydoc. The documentation is then
    zipped using zipfile standard module.
    """

    description = 'build the documentation'
    user_options = [('pdf', None, 'Builds a PDF documentation instead of a HTML one.')]

    def initialize_options(self):
        self.pdf = None

    def finalize_options(self):
        pass

    def run(self):
        try:
            from epydoc import cli

            epydoc_config = os.path.join('doc', 'epydoc.conf')

            old_argv = sys.argv[1:]
            try:
                sys.argv[1:] = ['--config=%s' % epydoc_config]
                if self.pdf:
                    sys.argv.append('--pdf')
                    sys.argv.append('--output=doc/pdf/')
                else:
                    sys.argv.append('--html')
                    sys.argv.append('--output=doc/html/')
    
                cli.cli()
            finally:
                sys.argv[1:] = old_argv

            print 'zipping the documentation'
            import zipfile
            if self.pdf:
                doctype = 'pdf'
            else:
                doctype = 'html'
            name = 'Skype4Py-%s-%sdoc' % (__version__, doctype)
            z = zipfile.ZipFile(os.path.join('doc', '%s.zip' % name),
                    'w', zipfile.ZIP_DEFLATED)
            path = os.path.join('doc', doctype)
            if self.pdf:
                z.write(os.path.join(path, 'api.pdf'), '%s.pdf' % name)
            else:
                for f in os.listdir(path):
                    z.write(os.path.join(path, f), os.path.join(name, f))
            z.close()

        except ImportError:
            print >>sys.stderr, 'epydoc not installed, skipping build_doc.'


commands = {'build_doc': build_doc,
            'install_lib': install_lib}


# start the distutils setup
setup(name='Skype4Py',
      version=__version__,
      description='Skype API wrapper for Python.',
      long_description='Skype4Py is a high-level, platform independent Skype API\n' \
                       'wrapper for Python with Skype4COM alike interface.',
      author='Arkadiusz Wahlig',
      author_email='arkadiusz.wahlig@gmail.com',
      maintainer='Arkadiusz Wahlig',
      url='https://developer.skype.com/wiki/Skype4Py',
      download_url='http://downloads.sourceforge.net/skype4py/Skype4Py-%s.tar.gz' % __version__,
      license='BSD License',
      platforms=['Windows', 'Linux', 'MacOS X'],
      packages=['Skype4Py', 'Skype4Py.api', 'Skype4Py.lang'],
      package_data={'Skype4Py': ['LICENSE']},
      provides=['Skype4Py'],
      cmdclass=commands)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.