This repository was archived by the owner on Mar 11, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
230 lines (184 loc) · 6.73 KB
/
setup.py
File metadata and controls
230 lines (184 loc) · 6.73 KB
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# -*- coding: utf-8 -*-
import os
import sys
import glob
import shutil
from distutils.cmd import Command
import yaml
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = []
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
#import here, cause outside the eggs aren't loaded
import pytest
import shlex
# Pickle data files and move to test directory
data_dir = "test_data"
test_dir = "tests"
search_path = os.path.join(data_dir, "*.py")
test_data_files = glob.glob(search_path)
for test_data_path in test_data_files:
src_path_root = os.path.splitext(test_data_path)[0]
src_path = "{}.pkl".format(src_path_root)
src_file = os.path.split(src_path)[1]
dst_path = os.path.join(test_dir, src_file)
dst_path = os.path.abspath(dst_path)
sys_command = "python {}".format(test_data_path)
os.system(sys_command)
print "copy test data: {}".format(dst_path)
shutil.copyfile(src_path, dst_path)
# Move yaml definitions to test directory
search_path = os.path.join(data_dir, "*.yaml")
test_def_files = glob.glob(search_path)
for test_def_path in test_def_files:
src_file = os.path.split(test_def_path)[1]
dst_path = os.path.join(test_dir, src_file)
dst_path = os.path.abspath(dst_path)
print "copy data definitions: {}".format(dst_path)
shutil.copyfile(test_def_path, dst_path)
# Run the tests
if self.pytest_args:
opts = shlex.split(self.pytest_args)
else:
opts = []
errno = pytest.main(opts)
sys.exit(errno)
class CleanTest(Command):
description = 'clean test files'
clean_list = ['.pyc', '.pkl']
user_options = []
exclude_list = ['.eggs', '.git', '.idea', '.hg', '__pycache__', 'test_data']
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print "start cleanup test files"
for clean_path in self.pickup_clean():
print "remove {}: {}".format(os.path.splitext(clean_path)[1],
clean_path)
os.remove(clean_path)
print "end cleanup"
def is_exclude(self, path):
for item in CleanTest.exclude_list:
if path.find(item) != -1:
return True
return False
def is_clean(self, path):
return path.endswith(tuple(CleanTest.clean_list))
def pickup_clean(self):
for root, dirs, files in os.walk(os.getcwd()):
if self.is_exclude(root):
continue
for fname in files:
if not self.is_clean(fname):
continue
yield os.path.join(root, fname)
class Bootstrap(Command):
user_options = []
def initialize_options(self):
"""Abstract method that is required to be overwritten"""
def finalize_options(self):
"""Abstract method that is required to be overwritten"""
def run(self):
# Setup paths
xl_dir = "dds"
yaml_dir = "dtocean_core\data\yaml"
ignore_column = "Comments"
sys_command = "bootstrap-dds -v -i {} -o {} {} ".format(ignore_column,
yaml_dir,
xl_dir)
# Convert the files
errno = os.system(sys_command)
sys.exit(errno)
def read_yaml(rel_path):
with open(rel_path, 'r') as stream:
data_loaded = yaml.safe_load(stream)
return data_loaded
def get_appveyor_version():
data = read_yaml("appveyor.yml")
if "version" not in data:
raise RuntimeError("Unable to find version string.")
appveyor_version = data["version"]
last_dot_idx = appveyor_version.rindex(".")
return appveyor_version[:last_dot_idx]
setup(name='dtocean-core',
version=get_appveyor_version(),
description='dtocean-core: The core component of the DTOcean tools',
maintainer='Mathew Topper',
maintainer_email='mathew.topper@dataonlygreater.com',
license="GPLv3",
packages=find_packages(),
setup_requires=['pyyaml'],
install_requires=[
'aneris>=0.11.1,<1',
'basemap',
'cma',
'cmocean',
'contours',
'cycler',
'descartes',
'geoalchemy2',
'matplotlib<2',
'monotonic',
'natsort',
'netcdf4',
'numpy',
'openpyxl<3',
'packaging',
'pandas>=0.23',
'pil',
'polite>=0.10,<1',
'psycopg2',
'pyproj',
'pyshp',
# 'PyQt4',
'python-dateutil',
'python-polylabel',
'pyyaml>=5.1',
'ruamel.yaml',
'scipy',
'setuptools',
'shapely',
'utm',
'xarray',
'xlrd<2',
'xlsxwriter<3',
'xlwt'
],
entry_points={
'console_scripts':
[
'add-Te = dtocean_core.utils.hydrodynamics:add_Te_interface',
'dtocean-core = dtocean_core.utils.execute:main_interface',
'dtocean-core-config = '
'dtocean_core.utils.config:init_config_interface',
'dtocean-database = '
'dtocean_core.utils.database:database_convert_interface',
'_dtocean-optim-pos = dtocean_core.strategies.'
'position_optimiser.iterator:interface'
]},
package_data={'dtocean_core': ['data/yaml/*.yaml',
'config/*.ini',
'config/*.yaml',
'strategies/position_optimiser/*.yaml']
},
zip_safe=False, # Important for reading config files
# scripts=['post-install.py'],
tests_require=['mock',
'pytest',
'pytest-catchlog',
'pytest-mock'],
cmdclass={'test': PyTest,
'cleantest': CleanTest,
'bootstrap': Bootstrap,
},
)