/
setup.py
194 lines (175 loc) · 7.5 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# -*- coding: utf-8 -*-
# Copyright or © or Copr. Actimar/IFREMER (2010-2018)
#
# This software is a computer program whose purpose is to provide
# utilities for handling oceanographic and atmospheric data,
# with the ultimate goal of validating the MARS model from IFREMER.
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
# %% Inits
import re, os, shutil
from numpy.distutils.core import setup
from numpy.distutils.misc_util import Configuration
from glob import glob
from numpy.distutils.command.install_data import install_data as numpy_install_data
from numpy.distutils.command.install import install as numpy_install
import distutils.command.bdist_rpm
rootdir = os.path.dirname(__file__)
#sys.path.insert(0, os.path.abspath(os.path.join(rootdir, 'doc/sphinx/source')))
# %% Parse info from __init__
# - from __init__.py
info = {}
f = open(os.path.join(rootdir, 'lib/python/vacumm/__init__.py'))
for line in f:
line = line[:-1].rstrip()
m = re.match(r'__(?P<name>(author|email|version))__\s*=\s*(?P<value>.*$)',
line)
if m is not None:
info[m.groupdict()['name']] = eval(m.groupdict()['value'])
f.close()
# %% Infos
name = "vacumm"
version_sphinx = release_sphinx = version = info['version']
description = 'A library for ocean science'
long_description = ("A library and a collection of scripts for ocean science, "
"mainly designed for data analysis and model validation")
author = info['author']
author_email = info['email']
maintainer = "Stephane Raynaud"
maintainer_email = "stephane.raynaud@gmail.com"
license = "CeCILL-2.1"
url = "http://www.ifremer.fr/vacumm"
classifiers = [#"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
("License :: OSI Approved :: CEA CNRS Inria Logiciel "
"Libre License, version 2.1 (CeCILL-2.1)"),
"Programming Language :: Python :: 2",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Atmospheric Science",
"Topic :: Software Development :: Libraries :: Python Modules",
"Operating System :: POSIX",
"Operating System :: MacOS :: MacOS X",
]
with open(os.path.join(rootdir,'requirements.txt')) as f:
install_requires = [dep[:-1] for dep in f.readlines()]
# %% Setup
def configuration(parent_package='',top_path=None):
# Initialize
config = Configuration(None, parent_package=parent_package,
top_path=top_path)
# Set options
config.set_options(
ignore_setup_xxx_py=True,
assume_default_configuration=True,
quiet=True,
delegate_options_to_subpackages=True,
)
# Add scripts
scripts = []
for pat in ['*.py', '*.bash', '*.sh']:
pat = os.path.join('bin', pat)
scripts.extend(glob(pat))
config.add_scripts(*scripts)
# Add special files
config.add_data_files(('vacumm', ['LICENSE', 'CHANGES.rst']))
config.add_subpackage('vacumm', 'lib/python/vacumm')
config.add_data_dir(('vacumm/vacumm-config', 'config')) # not needed
config.add_data_dir(('vacumm/vacumm-data', 'data')) # all data files
return config
# %% Add the --cfgfile option to install command
class vacumm_install_data(numpy_install_data):
user_options = numpy_install_data.user_options + [
('cfgfiles=', 'c', "VACUMM main and secondary "
"configuration files to replace defaut values")]
def initialize_options (self):
numpy_install_data.initialize_options(self)
self.cfgfiles = (hasattr(self.distribution, 'cfgfiles')
and self.distribution.cfgfiles or None)
def finalize_options(self):
numpy_install_data.finalize_options(self)
self.distribution.cfgfiles = self.cfgfiles
if self.cfgfiles is not None:
cfgfiles = []
for path in self.cfgfiles.split(','):
# self.add_data_files('vacumm/vacumm-config', path)
path = os.path.expanduser(path)
cfgfiles.extend(glob(os.path.abspath(path)))
self.data_files.append(('vacumm/vacumm-config', cfgfiles)) # FIXME: CFG INSTALL DIR NOT CLEAN
class vacumm_install(numpy_install):
user_options = numpy_install.user_options + [
('cfgfiles=', None, "VACUMM main and secondary "
"configuration files to replace defaut values"),
]
def initialize_options (self):
numpy_install.initialize_options(self)
self.cfgfiles = None
def finalize_options(self):
numpy_install.finalize_options(self)
self.distribution.cfgfiles = self.cfgfiles
class vacumm_bdist_rpm(distutils.command.bdist_rpm.bdist_rpm):
def initialize_options (self, *args, **kwargs):
distutils.command.bdist_rpm.bdist_rpm.initialize_options(self)
import vacumm
self.distribution_name = name
self.group = 'Utilities'
self.release = vacumm.__release__
self.vendor = vacumm.__copyright__
self.requires = [
'python >= 2.6',
'python-configobj >= 4.6',
'cdat-lite >= 6.0rc2',
'sphinx-fortran >= 1.0',
]
#self.install_script = 'rpm-install'
#self.post_install = 'rpm-post-install'
#self.pre_uninstall = 'rpm-pre-uninstall'
# %% Exec
if __name__ == '__main__':
# Setup config file
if not os.path.exists('setup.cfg'):
shutil.copy('setup.cfg.simple', 'setup.cfg')
# Lauch setup
setup(name='vacumm',
version = version,
description = description,
long_description = long_description,
author = author,
author_email = author_email,
maintainer = "Stephane Raynaud",
maintainer_email = "stephane.raynaud@gmail.com",
install_requires = install_requires,
license = license,
url=url,
package_dir= {'':'lib/python'},
py_modules = ['vcmq'],
classifiers = classifiers,
cmdclass={'install':vacumm_install, 'install_data':vacumm_install_data,
'bdist_rpm':vacumm_bdist_rpm},
configuration=configuration
)