source: trunk/anuga_core/setup.py @ 9674

Last change on this file since 9674 was 9674, checked in by steve, 9 years ago

Update version

  • Property svn:keywords set to Revision
File size: 5.8 KB
Line 
1#! /usr/bin/env python
2#
3# Copyright (C) 2007-2009 Cournapeau David <cournape@gmail.com>
4#               2010 Fabian Pedregosa <fabian.pedregosa@inria.fr>
5# License: 3-clause BSD
6#
7# Setup.py taken from scikit learn
8
9
10descr = """A set of python modules for modelling the effect of tsunamis and flooding"""
11
12import sys
13import os
14import shutil
15from distutils.command.clean import clean as Clean
16
17
18if sys.version_info[0] < 3:
19    import __builtin__ as builtins
20else:
21    import builtins
22
23
24# This is the numpy/scipy hack: Set a global variable so that the main
25# anuga __init__ can detect if it is being loaded by the setup routine, to
26# avoid attempting to load components that aren't built yet.
27builtins.__ANUGA_SETUP__ = True
28
29#==============================================================================
30DISTNAME = 'anuga'
31DESCRIPTION = 'A set of python modules for tsunami and flood modelling'
32with open('README.rst') as f:
33    LONG_DESCRIPTION = f.read()
34MAINTAINER = 'Stephen Roberts'
35MAINTAINER_EMAIL = 'stephen.roberts@anu.edu.au'
36URL = "http://anuga.anu.edu.au"
37LICENSE = 'GPL'
38DOWNLOAD_URL = "http://sourceforge.net/projects/anuga/"
39#===============================================================================
40
41
42# We can actually import a restricted version of anuga that
43# does not need the compiled code
44import anuga
45
46VERSION = anuga.__version__
47
48
49
50# Return the svn revision as a string
51def svn_revision():
52
53    return filter(str.isdigit, "$Revision: 9674 $")
54
55###############################################################################
56# Optional setuptools features
57# We need to import setuptools early, if we want setuptools features,
58# as it monkey-patches the 'setup' function
59
60# For some commands, use setuptools
61SETUPTOOLS_COMMANDS = set([
62    'develop', 'release', 'bdist_egg', 'bdist_rpm',
63    'bdist_wininst', 'install_egg_info', 'build_sphinx',
64    'egg_info', 'easy_install', 'upload', 'bdist_wheel',
65    '--single-version-externally-managed',
66])
67
68
69if len(SETUPTOOLS_COMMANDS.intersection(sys.argv)) > 0:
70    import setuptools
71    extra_setuptools_args = dict(
72        zip_safe=False,  # the package can run out of an .egg file
73        include_package_data=True,
74                install_requires=['numpy', 
75                          'scipy', 
76                          'netcdf4', 
77                          'nose', 
78                          'matplotlib',
79                          'gdal']
80    )
81else:
82    extra_setuptools_args = dict()
83
84###############################################################################
85
86
87class CleanCommand(Clean):
88    description = "Remove build artifacts from the source tree"
89
90    def run(self):
91        Clean.run(self)
92        if os.path.exists('build'):
93            shutil.rmtree('build')
94        for dirpath, dirnames, filenames in os.walk('anuga'):
95            for filename in filenames:
96                if (filename.endswith('.so') or filename.endswith('.pyd')
97                        or filename.endswith('.pyc')):
98                    os.unlink(os.path.join(dirpath, filename))
99            for dirname in dirnames:
100                if dirname == '__pycache__':
101                    shutil.rmtree(os.path.join(dirpath, dirname))
102
103
104###############################################################################
105def configuration(parent_package='', top_path=None):
106    if os.path.exists('MANIFEST'):
107        os.remove('MANIFEST')
108
109    from numpy.distutils.misc_util import Configuration
110    config = Configuration(None, parent_package, top_path)
111
112    # Avoid non-useful msg:
113    # "Ignoring attempt to set 'name' (from ... "
114    config.set_options(ignore_setup_xxx_py=True,
115                       assume_default_configuration=True,
116                       delegate_options_to_subpackages=True,
117                       quiet=True)
118
119    config.add_subpackage('anuga')
120
121    return config
122
123
124def setup_package():
125    metadata = dict(name=DISTNAME,
126                    maintainer=MAINTAINER,
127                    maintainer_email=MAINTAINER_EMAIL,
128                    description=DESCRIPTION,
129                    license=LICENSE,
130                    url=URL,
131                    version=VERSION,
132                    download_url=DOWNLOAD_URL,
133                    long_description=LONG_DESCRIPTION,
134                    classifiers=['Intended Audience :: Science/Research',
135                                 'Intended Audience :: Developers',
136                                 'License :: OSI Approved',
137                                 'Programming Language :: C',
138                                 'Programming Language :: Python',
139                                 'Topic :: Software Development',
140                                 'Topic :: Scientific/Engineering',
141                                 'Operating System :: Microsoft :: Windows',
142                                 'Operating System :: POSIX',
143                                 'Operating System :: Unix',
144                                 'Operating System :: MacOS',
145                                 'Programming Language :: Python :: 2.6',
146                                 'Programming Language :: Python :: 2.7',
147                                 ],
148                    cmdclass={'clean': CleanCommand},
149                    **extra_setuptools_args)
150
151    if (len(sys.argv) >= 2
152            and ('--help' in sys.argv[1:] or sys.argv[1]
153                 in ('--help-commands', 'egg_info', '--version', 'clean'))):
154
155        # For these actions, NumPy is not required.
156        #
157        # They are required to succeed without Numpy for example when
158        # pip is used to install anuga when Numpy is not yet present in
159        # the system.
160        try:
161            from setuptools import setup
162        except ImportError:
163            from distutils.core import setup
164
165        metadata['version'] = VERSION
166    else:
167        from numpy.distutils.core import setup
168
169        metadata['configuration'] = configuration
170
171    setup(**metadata)
172
173
174if __name__ == "__main__":
175
176
177    setup_package()
178   
Note: See TracBrowser for help on using the repository browser.