/
setup.py
executable file
·97 lines (78 loc) · 2.74 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
#!/usr/bin/env python
'''
Created on 07/12/2011
@author: Moises P. Sena "<moisespsena" + "@" + "gmail.com>"
'''
from distutils.cmd import Command
from setuptools import setup
from unittest.runner import TextTestRunner
from unittest.suite import TestSuite
import os
import re
import sys
import unittest
import shutil
THIS_PATH = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
PKG_DIR = os.path.join(THIS_PATH, "sdag")
TEST_DIR = os.path.join(THIS_PATH, "tests")
def read(fname):
global THIS_PATH
return open(os.path.join(THIS_PATH, fname)).read()
class TestCommand(Command):
user_options = [ ]
def initialize_options(self):
self._dir = os.getcwd()
def finalize_options(self):
pass
def run(self):
global THIS_PATH, PKG_DIR, TEST_DIR
sys.path.insert(0, PKG_DIR)
suite = TestSuite()
loaded = unittest.defaultTestLoader.discover(TEST_DIR, pattern='*Test.py')
for all_test_suite in loaded:
for test_suite in all_test_suite:
suite.addTests(test_suite)
runner = TextTestRunner(verbosity = 2)
runner.run(suite)
class CleanCommand(Command):
user_options = [ ]
def initialize_options(self):
self.rmPaths = [ ]
for f in os.listdir(THIS_PATH):
if re.search("(^(build|dist)$|\.egg-info)", f):
self.rmPaths.append(f)
for root, dirs, files in os.walk(THIS_PATH):
for f in files:
if f.endswith(".pyc") or f.endswith(".pyc"):
self.rmPaths.append(os.path.join(root, f))
def finalize_options(self):
pass
def run(self):
for p in self.rmPaths:
if os.path.isdir(p):
print("Remove directory: " + p)
shutil.rmtree(p)
else:
print("Remove file : " + p)
os.unlink(p)
setup(
name = "py-sdag",
version = "1.0",
author = "Moises P. Sena",
author_email = "moisespsena@gmail.com",
description = ("Simple Directed Acyclic Graph whith Cicle Detector and TopoloGical sorter utilities."),
license = "BSD",
keywords = "utils utilities directed graph digraph topological sorter simple",
url = "https://github.com/moisespsena/py-sdag",
packages=["sdag"],
long_description=read('README.md'),
classifiers=[
"Development Status :: 5 - Production/Stable",
"Topic :: Utilities",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2.7"
],
cmdclass={'test' : TestCommand, 'clean': CleanCommand}
)