forked from gslab-econ/gslab_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
72 lines (60 loc) · 2.45 KB
/
setup.py
File metadata and controls
72 lines (60 loc) · 2.45 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
import os
import re
import sys
import shutil
from setuptools import setup, find_packages
from setuptools.command.build_py import build_py
from glob import glob
# Determine if the user has specified which paths to report coverage for
is_include_arg = map(lambda x: bool(re.search('^--include=', x)),
sys.argv)
if True in is_include_arg:
include_arg = sys.argv[is_include_arg.index(True)]
include_arg = sys.argv[is_include_arg.index(True)]
del sys.argv[is_include_arg.index(True)]
else:
include_arg = None
class TestRepo(build_py):
'''Build command for running tests in repo'''
def run(self):
if include_arg:
coverage_command = 'coverage report -m %s' % include_arg
else:
coverage_command = 'coverage report -m --omit=setup.py,*/__init__.py,.eggs/*'
if sys.platform != 'win32':
os.system("coverage run --branch --source ./ setup.py test1 2>&1 "
"| tee test.log")
# http://unix.stackexchange.com/questions/80707/
# how-to-output-text-to-both-screen-and-file-inside-a-shell-script
os.system("%s 2>&1 | tee -a test.log" % coverage_command)
else:
os.system("coverage run --branch --source ./ setup.py "
"> test.log")
os.system("%s >> test.log" % coverage_command)
sys.exit()
class CleanRepo(build_py):
'''Build command for clearing setup directories after installation'''
def run(self):
# i) Remove the .egg-info folder
egg_directories = glob('./*.egg-info')
map(shutil.rmtree, egg_directories)
# ii) Remove the ./build and ./dist directories
if os.path.isdir('./build'):
shutil.rmtree('./build')
if os.path.isdir('./dist'):
shutil.rmtree('./dist')
# Requirements
requirements = ['requests']
setup(name = 'GSLab_Tools',
version = '4.0.1',
description = 'Python tools for GSLab',
url = 'https://github.com/gslab-econ/gslab_python',
author = 'Matthew Gentzkow, Jesse Shapiro',
author_email = 'gentzkow@stanford.edu, jesse_shapiro_1@brown.edu',
license = 'MIT',
packages = find_packages(),
install_requires = requirements,
zip_safe = False,
cmdclass = {'test': TestRepo, 'clean': CleanRepo},
setup_requires = ['pytest-runner', 'coverage'],
tests_require = ['pytest', 'coverage'])