|
|
"""Distutils setup file""" |
"""Distutils setup file""" |
|
|
from distutils.core import setup, Command |
execfile('src/setup/prologue.py') |
from distutils.command.install_data import install_data |
|
from distutils.command.sdist import sdist as old_sdist |
|
import sys |
|
|
|
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_purelib', '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) |
|
|
|
|
|
|
|
|
|
|
include_tests = True # edit this to stop installation of test modules |
|
include_metamodels = True # edit this to stop installation of MOF, UML, etc. |
|
include_fcgiapp = True # edit this to stop installation of 'fcgiapp' |
|
|
|
# Metadata |
|
|
|
PACKAGE_NAME = "PEAK" |
|
PACKAGE_VERSION = "0.5a1" |
|
|
|
HAPPYDOC_IGNORE = [ |
|
'-i', 'examples', '-i', 'old', '-i', 'tests', '-i', 'zope', '-i', 'setup', |
|
'-i', 'kjbuckets', '-i', 'ZConfig', '-i', 'persistence', |
|
] |
|
|
|
|
|
# Base packages for installation |
|
|
class test(Command): |
packages = [ |
|
'peak', 'peak.api', 'peak.binding', 'peak.config', 'peak.model', |
|
'peak.naming', 'peak.naming.factories', 'peak.running', |
|
'peak.storage', 'peak.util', |
|
] |
|
|
"""Command to run unit tests after installation""" |
extensions = [ |
|
Extension("kjbuckets", ["src/kjbuckets/kjbucketsmodule.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]), |
|
] |
|
|
description = "Run unit tests after installation" |
# Base data files |
|
|
user_options = [('test-module=','m','Test module (default=TW.tests)'),] |
data_files = [ |
|
('peak', ['src/peak/peak.ini']), |
|
] |
|
|
def initialize_options(self): |
|
self.test_module = None |
|
|
|
def finalize_options(self): |
if include_tests: |
|
|
if self.test_module is None: |
packages += [ |
self.test_module = 'TW.tests' |
'peak.tests', 'peak.binding.tests', 'peak.config.tests', |
|
'peak.model.tests', 'peak.naming.tests', 'peak.running.tests', |
|
'peak.storage.tests', 'peak.util.tests', |
|
] |
|
|
self.test_args = [self.test_module+'.test_suite'] |
data_files += [ |
|
('peak/running/tests', ['src/peak/running/tests/test_cluster.txt']), |
|
] |
|
|
if self.verbose: |
|
self.test_args.insert(0,'--verbose') |
|
|
|
def run(self): |
if include_metamodels: |
|
|
# Install before testing |
packages += [ |
self.run_command('install') |
'peak.metamodels', |
|
'peak.metamodels.UML13', |
|
'peak.metamodels.UML13.model', |
|
'peak.metamodels.UML13.model.Foundation', |
|
'peak.metamodels.UML13.model.Behavioral_Elements', |
|
] |
|
|
if not self.dry_run: |
if include_tests: |
from unittest import main |
|
main(None, None, sys.argv[:1]+self.test_args) |
|
|
|
|
packages += [ 'peak.metamodels.tests' ] |
|
|
|
data_files += [ |
|
('peak/metamodels/tests', |
|
['src/peak/metamodels/tests/MetaMeta.xml'] |
|
), |
|
] |
|
|
|
|
|
try: |
|
# Check if Zope X3 is installed; we use zope.component |
|
# because we don't install it ourselves; if we used something we |
|
# install, we'd get a false positive if PEAK was previously installed. |
|
import zope.component |
|
zope_installed = True |
|
|
|
except ImportError: |
|
zope_installed = False |
|
|
|
|
|
if not zope_installed: |
|
|
|
packages += [ |
|
'zope', 'zope.interface', 'zope.interface.common', |
|
'persistence', 'ZConfig', |
|
] |
|
|
|
extensions += [ |
|
Extension("persistence._persistence", ["src/persistence/persistence.c"]) |
|
] |
|
|
|
if include_tests: |
|
packages += [ |
|
'zope.interface.tests', 'persistence.tests', 'ZConfig.tests', |
|
'zope.interface.common.tests', |
|
] |
|
|
|
data_files += findDataFiles('src/ZConfig/tests', 1, '*.xml', '*.txt', '*.conf') |
|
|
|
|
|
|
|
|
|
|
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 TW for now... |
|
""" |
|
|
|
description = "Generate docs using happydoc" |
|
|
|
user_options = [] |
|
|
|
|
|
def initialize_options(self): |
|
self.happy_options = None |
|
self.doc_output_path = None |
|
|
|
|
import os |
|
|
def finalize_options(self): |
if os.name=='posix': |
|
|
if self.doc_output_path is None: |
# install 'peak' script on Unix-like OS's (including cygwin) |
self.doc_output_path = 'docs/html/reference' |
scripts = ['scripts/peak'] |
|
|
if self.happy_options is None: |
# install 'fcgiapp' module, too |
self.happy_options = [ |
if include_fcgiapp: |
'-t', 'TransWarp Reference', '-d', self.doc_output_path, |
extensions += [ |
'-i', 'examples', '-i', 'old', '-i', 'tests', '.', |
Extension("fcgiapp", [ |
|
"src/fcgiapp/fcgiappmodule.c", "src/fcgiapp/fcgiapp.c" |
|
]) |
] |
] |
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) |
else: |
remove_tree(self.doc_output_path, self.verbose, self.dry_run) |
# Nothing to see here, move along... |
|
scripts = [] |
|
|
if not self.dry_run: |
|
HappyDoc(self.happy_options).run() |
|
|
|
|
execfile('src/setup/common.py') |
|
|
setup( |
setup( |
|
name=PACKAGE_NAME, |
|
version=PACKAGE_VERSION, |
|
|
name="TransWarp", |
description="The Python Enterprise Application Kit", |
version="0.2pre1", |
|
description="The TransWarp Software Automation Toolkit", |
|
|
|
author="Phillip J. Eby", |
author="Phillip J. Eby", |
author_email="transwarp@eby-sarna.com", |
author_email="transwarp@eby-sarna.com", |
|
url="http://peak.telecommunity.com/", |
url="http://www.telecommunity.com/TransWarp/", |
license="PSF or ZPL", |
|
platforms=['UNIX','Windows'], |
packages=[ |
|
'TW', 'TW.API', 'TW.Database', 'TW.MOF', 'TW.SEF', 'TW.UML', 'TW.XMI', |
|
'TW.Utils', 'TW.API.tests', 'TW.Database.tests', 'TW.SEF.tests', |
|
'TW.Utils.tests', 'TW.tests', 'TWX', 'TWX.Diagrams', |
|
], |
|
|
|
package_dir = {'':'src'}, |
package_dir = {'':'src'}, |
|
packages = packages, |
cmdclass = { |
cmdclass = SETUP_COMMANDS, |
'install_data': install_data, 'sdist': sdist, 'happy': happy, |
data_files = data_files, |
'test': test, |
ext_modules = extensions, |
}, |
scripts = scripts, |
|
|
data_files = [ |
|
('TW/SEF/tests', ['src/TW/SEF/tests/MetaMeta.xml']), |
|
], |
|
) |
) |
|
|
|
|