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