forked from HelikarLab/candis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·99 lines (78 loc) · 3.02 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
#!/usr/bin/env python
import sys
import os
import shutil
import codecs
from distutils.core import Command
from distutils.command.clean import clean as Clean
from package import package
ABSPATH_ROOTDIR = os.path.dirname(os.path.abspath(__file__))
RELPATH_FILES_CLEAN = ['build', 'dist', '{name}.egg-info'.format(name = package['name']), '.cache']
RELPATH_WALK_FILES_EXT_CLEAN = ['.pyc', '.DS_Store']
RELPATH_WALK_DIRS_CLEAN = ['__pycache__']
class CleanCommand(Clean):
def run(self):
Clean.run(self)
for filename in RELPATH_FILES_CLEAN:
if os.path.exists(filename):
shutil.rmtree(filename)
for dirpath, dirnames, filenames in os.walk(ABSPATH_ROOTDIR):
for filename in filenames:
for extension in RELPATH_WALK_FILES_EXT_CLEAN:
if filename.endswith(extension):
path = os.path.join(dirpath, filename)
os.unlink(path)
for dirname in dirnames:
if dirname in RELPATH_WALK_DIRS_CLEAN:
path = os.path.join(dirpath, dirname)
shutil.rmtree(path, ignore_errors = True)
class TestCommand(Command):
user_options = [('pytest=', 'a', 'arguments to be passed to pytest')]
def initialize_options(self):
self.args_pytest = [ ]
def finalize_options(self):
pass
def run(self):
import pytest
errno = pytest.main(self.args_pytest)
sys.exit(errno)
def main(argv = None):
code = os.EX_OK
try:
from setuptools import setup
args_setuptools = dict(
keywords = ', '.join([keyword for keyword in package['keywords']])
)
except ImportError:
from distutils.core import setup
args_setuptools = dict()
metadata = dict(
name = package['name'],
version = package['version'],
description = package['description'],
long_description = package['long_description'],
author = ','.join([author['name'] for author in package['authors']]),
author_email = ','.join([author['email'] for author in package['authors']]),
maintainer = ','.join([maintainer['name'] for maintainer in package['maintainers']]),
maintainer_email = ','.join([maintainer['email'] for maintainer in package['maintainers']]),
license = package['license'],
packages = package['modules'],
url = package['homepage'],
# install_requires = package['dependencies']['production'],
cmdclass = dict(
clean = CleanCommand, test = TestCommand
),
include_package_data = True,
entry_points = dict(
console_scripts = [
'candis = candis:main'
]
),
**args_setuptools
)
setup(**metadata)
return code
if __name__ == '__main__':
args = sys.argv[1:]
code = main(args)
sys.exit(code)