-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
124 lines (95 loc) · 3.32 KB
/
Copy pathsetup.py
File metadata and controls
124 lines (95 loc) · 3.32 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
# -*- coding: utf-8 -*-
"""This module contains the installation code of dtocean-maintenance
.. module:: setup.py
:platform: Windows
:synopsis: installation code of dtocean-maintenance
.. moduleauthor:: Mathew Topper <mathew.topper@tecnalia.com>
"""
# pylint: disable=wrong-import-order
import os
import sys
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
errno = pytest.main(self.pytest_args)
sys.exit(errno)
class CleanPyc(Command):
description = 'clean *.pyc'
user_options = []
exclude_list = ['.egg', '.git', '.idea', '__pycache__']
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print "start cleanup pyc files."
for pyc_path in self.pickup_pyc():
print "remove pyc: {0}".format(pyc_path)
os.remove(pyc_path)
print "the end."
def is_exclude(self, path):
for item in CleanPyc.exclude_list:
if path.find(item) != -1:
return True
return False
def is_pyc(self, path):
return path.endswith('.pyc')
def pickup_pyc(self):
for root, dirs, files in os.walk(os.getcwd()):
for fname in files:
if self.is_exclude(root):
continue
if not self.is_pyc(fname):
continue
yield os.path.join(root, fname)
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-maintenance',
version=get_appveyor_version(),
description='The maintenance operations module for the DTOcean tools',
maintainer='Mathew Topper',
maintainer_email='mathew.topper@dataonlygreater.com',
license="GPLv3",
packages=find_packages(),
package_data={'dtocean_maintenance': ['config/*.yaml']
},
setup_requires=['pyyaml'],
install_requires=[
'dtocean-economics >= 2.0, <3',
'dtocean-logistics >= 3.0, <4',
'dtocean-reliability >= 3.0, <4',
'numpy',
'pandas >=0.17',
'polite >=0.9, <1',
'setuptools'
],
zip_safe=False, # Important for reading config files
tests_require=['mock',
'pytest',
'pytest-mock'],
cmdclass = {'test': PyTest,
'cleanpyc': CleanPyc,
},
)