[Subversion] / PEAK / setup.py  

View of /PEAK/setup.py

Parent Directory | Revision Log
Revision: 911 - (download) (as text)
Thu Feb 20 00:49:43 2003 UTC (21 years, 2 months ago) by pje
File size: 5728 byte(s)
Re-organized setup script to allow leaving out tests, metamodels, or both.
This should make it possible for people who want a compact install for
"embedded" use (e.g. inside an application distributed as a binary).  Tests
aren't needed once PEAK is verified for your target platform, and the
metamodels package will only be needed if your application works directly
with MOF, UML, CWM, etc.  For example, if it's a code generator,
documentation utility, or a model editing program.

Mostly, though, I'm adding these options so I can excuse the later addition
of reams of generated code to the 'peak.metamodels' package to support UML
1.4, MOF 1.4, CWM 1.0, etc.  I can always say to somebody who complains,
"if you don't need it, edit the setup.py before you install".  ;)
#!/usr/bin/env python

"""Distutils setup file"""

include_tests = True        # edit this to stop installation of test modules
include_metamodels = True   # edit this to stop installation of MOF, UML, etc.


# Base packages for installation

packages = [
    'peak', 'peak.api', 'peak.binding', 'peak.config', 'peak.model',
    'peak.naming', 'peak.naming.factories', 'peak.running',
    'peak.storage', 'peak.util',

    'Interface', 'Interface.Common', 'Interface.Registry',
    'Persistence',
]


# Base data files

data_files = [
    ('peak', ['src/peak/peak.ini']),
]
















if include_tests:

    packages += [
        'peak.tests', 'peak.binding.tests', 'peak.config.tests',
        'peak.model.tests', 'peak.naming.tests', 'peak.running.tests',
        'peak.storage.tests', 'peak.util.tests',

        'Interface.tests', 'Interface.Common.tests',
        'Interface.Registry.tests',
    ]

    data_files += [
        ('peak/running/tests', ['src/peak/running/tests/test_cluster.txt']),
    ]


if include_metamodels:

    packages += [
        'peak.metamodels',
        'peak.metamodels.UML13',
        'peak.metamodels.UML13.Foundation',
        'peak.metamodels.UML13.model',
        'peak.metamodels.UML13.model.Foundation',
        'peak.metamodels.UML13.model.Behavioral_Elements',
    ]

    if include_tests:

        packages += [
            'peak.metamodels.tests',
        ]

        data_files += [
            ('peak/metamodels/tests',
                ['src/peak/metamodels/tests/MetaMeta.xml']
            ),
        ]



from distutils.core import setup, Command, Extension
from distutils.command.install_data import install_data
from distutils.command.sdist import sdist as old_sdist
from distutils.command.build_ext import build_ext as old_build_ext
import sys

try:
    from Pyrex.Distutils.build_ext import build_ext
    EXT = '.pyx'
except ImportError:
    build_ext = old_build_ext
    EXT = '.c'


class install_data(install_data):

    """Variant of 'install_data' that installs data to module directories"""
    
    def finalize_options (self):
        self.set_undefined_options('install',
                                   ('install_lib', 'install_dir'),
                                   ('root', 'root'),
                                   ('force', 'force'),
                                  )

class sdist(old_sdist):

    """Variant of 'sdist' that (re)builds the documentation first"""
   
    def run(self):

        # Build docs before source distribution
        self.run_command('happy')

        # Run the standard sdist command
        old_sdist.run(self)





class test(Command):

    """Command to run unit tests after installation"""

    description = "Run unit tests after installation"

    user_options = [('test-module=','m','Test module (default=peak.tests)'),]

    def initialize_options(self):
        self.test_module = None

    def finalize_options(self):

        if self.test_module is None:
            self.test_module = 'peak.api.tests'

        self.test_args = [self.test_module+'.test_suite']

        if self.verbose:
            self.test_args.insert(0,'--verbose')

    def run(self):

        # Install before testing
        self.run_command('install')

        if not self.dry_run:
            from unittest import main
            main(None, None, sys.argv[:1]+self.test_args)












class happy(Command):

    """Command to generate documentation using HappyDoc

        I should probably make this more general, and contribute it to either
        HappyDoc or the distutils, but this does the trick for PEAK for now...
    """

    description = "Generate docs using happydoc"

    user_options = []

    def initialize_options(self):
        self.happy_options = None
        self.doc_output_path = None


    def finalize_options(self):

        if self.doc_output_path is None:
            self.doc_output_path = 'docs/html/reference'

        if self.happy_options is None:
            self.happy_options = [
                '-t', 'PEAK Reference', '-d', self.doc_output_path,
                '-i', 'examples', '-i', 'old', '-i', 'tests',
                '-i', 'Interface', '-i', 'Persistence',
                '-i', 'kjbuckets', '.'
            ]
            if not self.verbose: self.happy_options.insert(0,'-q')

    def run(self):
        from distutils.dir_util import remove_tree, mkpath
        from happydoclib import HappyDoc

        mkpath(self.doc_output_path, 0755, self.verbose, self.dry_run)
        remove_tree(self.doc_output_path, self.verbose, self.dry_run)

        if not self.dry_run:
            HappyDoc(self.happy_options).run()

setup(
    name="PEAK",
    version="0.5a0",

    description="The Python Enterprise Application Kit",

    author="Phillip J. Eby",
    author_email="transwarp@eby-sarna.com",

    url="http://www.telecommunity.com/PEAK/",

    license="PSF or ZPL",
    platforms=['UNIX','Windows'],

    packages    = packages,
    package_dir = {'':'src'},

    cmdclass = {
        'install_data': install_data, 'sdist': sdist, 'happy': happy,
        'test': test, 'sdist_nodoc': old_sdist, 'build_ext': build_ext,
    },

    data_files = data_files,

    ext_modules = [
        Extension("kjbuckets", ["src/kjbuckets/kjbucketsmodule.c"]),
        Extension("Persistence.cPersistence",
            ["src/Persistence/cPersistence.c"]
        ),
        Extension(
            "peak.binding._once", [
                "src/peak/binding/_once" + EXT,
                "src/peak/binding/getdict.c"
            ]
        ),
        Extension("peak.util.buffer_gap", ["src/peak/util/buffer_gap" + EXT]),
        Extension("peak.util._Code", ["src/peak/util/_Code" + EXT]),
    ],

)



cvs-admin@eby-sarna.com

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help