#!/usr/bin/env python |
#!/usr/bin/env python |
|
|
"""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): |
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.5a3" |
|
HAPPYDOC_IGNORE = [ |
|
'-i', 'examples', '-i', 'old', '-i', 'tests', '-i', 'setup', |
|
'-i', 'kjbuckets', '-i', 'ZConfig', '-i', 'persistence', |
|
] |
|
|
"""Variant of 'install_data' that installs data to module directories""" |
# Base packages for installation |
|
scripts = ['scripts/peak'] |
|
|
def finalize_options (self): |
packages = [ |
self.set_undefined_options('install', |
'peak', 'peak.api', 'peak.binding', 'peak.config', 'peak.model', |
('install_purelib', 'install_dir'), |
'peak.naming', 'peak.naming.factories', 'peak.net', 'peak.running', |
('root', 'root'), |
'peak.running.tools', 'peak.running.tools.n2', 'peak.security', |
('force', 'force'), |
'peak.storage', 'peak.util', 'peak.web', 'protocols', |
) |
'peak.running.tools.version' |
|
] |
|
|
class sdist(old_sdist): |
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]), |
|
Extension("protocols._speedups", ["src/protocols/_speedups" + EXT]), |
|
] |
|
|
"""Variant of 'sdist' that (re)builds the documentation first""" |
# Base data files |
|
|
def run(self): |
data_files = [ |
|
('peak', ['src/peak/peak.ini']), |
|
('peak/web', ['src/peak/web/resource_defaults.ini']), |
|
] + findDataFiles('src/peak/running', 1, '*.xml', '*.ini') |
|
|
# Build docs before source distribution |
|
self.run_command('happy') |
|
|
|
# Run the standard sdist command |
if include_tests: |
old_sdist.run(self) |
|
|
packages += [ |
|
'peak.tests', 'peak.binding.tests', 'peak.config.tests', |
|
'peak.model.tests', 'peak.naming.tests', 'peak.running.tests', |
|
'peak.security.tests', 'peak.web.tests', |
|
'peak.storage.tests', 'peak.util.tests', 'protocols.tests', |
|
] |
|
|
|
data_files += [ |
|
('peak/running/tests', ['src/peak/running/tests/test_cluster.txt']), |
|
('peak/config/tests', ['src/peak/config/tests/test_links.ini']), |
|
] + findDataFiles('src/peak/web/tests', 1, '*.pwt') |
|
|
|
|
|
if include_metamodels: |
|
|
|
packages += [ |
|
'peak.metamodels', |
|
'peak.metamodels.UML13', 'peak.metamodels.UML14', |
|
'peak.metamodels.UML13.model', 'peak.metamodels.UML14.model', |
|
'peak.metamodels.UML13.model.Foundation', |
|
'peak.metamodels.UML13.model.Behavioral_Elements', |
|
] |
|
|
|
if include_tests: |
|
|
|
packages += [ 'peak.metamodels.tests' ] |
|
|
|
data_files += findDataFiles('src/peak/metamodels/tests', 1, '*.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 |
|
|
class test(Command): |
except ImportError: |
|
zope_installed = False |
|
|
"""Command to run unit tests after installation""" |
|
|
|
description = "Run unit tests after installation" |
if not zope_installed: |
|
|
user_options = [('test-module=','m','Test module (default=peak.tests)'),] |
packages += [ |
|
'persistence', 'ZConfig', |
|
] |
|
|
|
extensions += [ |
|
Extension("persistence._persistence", ["src/persistence/persistence.c"]) |
|
] |
|
|
|
if include_tests: |
|
packages += [ |
|
'persistence.tests', 'ZConfig.tests', |
|
] |
|
|
def initialize_options(self): |
data_files += findDataFiles( |
self.test_module = None |
'src/ZConfig/tests', 1, '*.xml', '*.txt', '*.conf' |
|
) |
|
|
def finalize_options(self): |
|
|
|
if self.test_module is None: |
|
self.test_module = 'peak.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) |
|
|
|
|
|
|
|
|
|
|
|
|
import sys |
|
|
|
if sys.version_info < (2,3): |
|
# Install datetime module if we're not on 2.3 |
|
packages += ['datetime'] |
|
if include_tests: |
|
packages += ['datetime.tests'] |
|
|
|
|
|
import os |
|
|
|
if os.name=='posix': |
|
|
|
# install 'fcgiapp' module on posix systems |
|
if include_fcgiapp: |
|
extensions += [ |
|
Extension("fcgiapp", [ |
|
"src/fcgiapp/fcgiappmodule.c", "src/fcgiapp/fcgiapp.c" |
|
]) |
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
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', '.' |
|
] |
|
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() |
execfile('src/setup/common.py') |
|
|
setup( |
setup( |
|
name=PACKAGE_NAME, |
|
version=PACKAGE_VERSION, |
|
|
name="PEAK", |
|
version="0.5a1", |
|
description="The Python Enterprise Application Kit", |
description="The Python Enterprise Application Kit", |
|
|
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/", |
|
license="PSF or ZPL", |
|
platforms=['UNIX','Windows'], |
|
|
|
package_dir = {'':'src'}, |
|
packages = packages, |
|
cmdclass = SETUP_COMMANDS, |
|
data_files = data_files, |
|
ext_modules = extensions, |
|
scripts = scripts, |
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
url="http://www.telecommunity.com/PEAK/", |
|
|
|
packages=[ |
|
'peak', 'peak.api', 'peak.binding', 'peak.model', 'peak.metamodels', |
|
'peak.metamodels.mof', 'peak.metamodels.uml', 'peak.metamodels.xmi', |
|
'peak.naming', 'peak.naming.factories', 'peak.util', 'peak.running', |
|
'peak.config', 'peak.storage', |
|
|
|
'peak.binding.tests', |
|
'peak.metamodels.tests', 'peak.util.tests', 'peak.tests', |
|
|
|
'Interface', 'Interface.Common', 'Interface.tests', |
|
], |
|
|
|
package_dir = {'':'src'}, |
|
|
|
cmdclass = { |
|
'install_data': install_data, 'sdist': sdist, 'happy': happy, |
|
'test': test, |
|
}, |
|
|
|
data_files = [ |
|
('peak/metamodels/tests', ['src/peak/metamodels/tests/MetaMeta.xml']), |
|
], |
|
) |
|
|
|
|
|