Source code for setup

#!/usr/bin/env python
''' is the main PETGEM setup script, it is based on python
# Standard module import
import os
import sys
import glob
import shutil
from builder import (package_check, log, cmdclass, INFO)
from petgem.base.styles import set_str_format as strFormat
from petgem.base.styles import (petgemHeader, petgemFooter)

VERSION = INFO.__version__

# Development Status :: 1 - Alpha
# Intended Audience :: Science/Research
# Intended Audience :: Developers
# License ::
# Programming Language :: Python
# Topic :: Scientific/Computing/HPC
# Operating System :: LINUX
# """

# Remove MANIFEST file since distutils doesn't properly update it
# when the contents of directories change.
if os.path.exists('MANIFEST'):

[docs]def configuration(parent_package='', top_path=None): ''' Configure a local environment. :param str parent_package: initial parent package of PETGEM :param str top_path: top path of PETGEM directory :return: config structure :rtype: list ''' from numpy.distutils.misc_util import Configuration config = Configuration(None, parent_package, top_path) config.set_options(ignore_setup_xxx_py=True, assume_default_configuration=True, delegate_options_to_subpackages=True, quiet=True) config.add_subpackage('petgem') aux_utils = [''] aux_utils = [os.path.join('utils', ii) for ii in aux_utils] config.add_data_files(('petgem', ('VERSION', 'INSTALL', 'README', 'LICENSE', 'AUTHORS', '', 'examples/', 'Makefile'))) # Sets subdirectories config.add_data_dir(('petgem/utils', 'utils')) config.add_data_dir(('petgem/examples', 'examples')) # Sets config.version config.get_version('petgem/') return config
[docs]def check_versions(show_only=False): ''' Check all requires packages for **PETGEM** installation. ''' # Check hard and soft dependencies. package_check('numpy', INFO.NUMPY_MIN_VERSION, show_only=show_only) package_check('scipy', INFO.SCIPY_MIN_VERSION, show_only=show_only) package_check('h5py', INFO.H5PY_MIN_VERSION, show_only=show_only) # package_check('petsc4py', INFO.PETSC4PY_MIN_VERSION, optional=True, # show_only=show_only) package_check('mpi4py', INFO.MPI4PY_MIN_VERSION, optional=True, show_only=show_only)
DOCLINES = __doc__.split("\n")
[docs]def setup_package(): ''' Setup a package for a specific installation. ''' from numpy.distutils.core import setup old_path = os.getcwd() local_path = os.path.dirname(os.path.abspath(sys.argv[0])) os.chdir(local_path) sys.path.insert(0, local_path) # Retrive version sys.path.insert(0, os.path.join(local_path, 'petgem')) # Write the version file. fd = open('VERSION', 'w') fd.write(VERSION) fd.close() # TODO : include main utils in root directory data_files = main_utils = [] if == 'linux': main_utils = ['petgem-run'] try: setup(name='petgem', maintainer="Octavio Castillo Reyes", maintainer_email="", description=DOCLINES[0], long_description="\n".join(DOCLINES[2:]), url="", download_url="", license='', classifiers=filter(None, CLASSIFIERS.split('\n')), platforms="Linux", scripts=main_utils, data_files=data_files, cmdclass=cmdclass, configuration=configuration) finally: del sys.path[0] os.chdir(old_path) return
if __name__ == '__main__': petgemHeader() # Setup PETGEM package setup_package() msg = 'Required and optional packages found:' msg = strFormat(msg, FORMAT='OkBlue') print(msg) # Check versions of packages required check_versions(show_only=True) # Print last message action = sys.argv[1] print(action) if action == 'htmldocs': msg = 'HTML PETGEM documentation built successfully!!.' msg = strFormat(msg, FORMAT='OkGreen') print(msg) elif action == 'pdfdocs': msg = 'PDF PETGEM documentation built successfully!!.' msg = strFormat(msg, FORMAT='OkGreen') print(msg) elif action == 'clean': msg = 'The PETGEM clean was successfull!!.' msg = strFormat(msg, FORMAT='OkGreen') print(msg) else: msg = 'The PETGEM setup was successfull!!.' msg = strFormat(msg, FORMAT='OkGreen') print(msg) petgemFooter()