-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
101 lines (87 loc) · 3.43 KB
/
setup.py
File metadata and controls
101 lines (87 loc) · 3.43 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
#!/usr/bin/env python
import os
import sys
import subprocess
from setuptools import setup, find_packages, Command
from setuptools.command.test import test as TestCommand
import pip
from pip.req import parse_requirements
# Get the version
script_path = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(script_path, 'VERSION')) as version_file:
version = version_file.read().strip()
# Get requirements
install_reqs = parse_requirements(
os.path.join(script_path, 'pip-requirements.txt'),
session=pip.download.PipSession())
reqs = [str(ir.req) for ir in install_reqs]
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 MakeAPI(Command):
"""Command to create API documentation using the pdoc package"""
description = 'Create API documentation using the pdoc package'
user_options = [('api-dir=', 'o', 'Directory to write API docs to')]
def initialize_options(self):
"""Set default values for options."""
self.api_dir = None
def finalize_options(self):
"""Post-process options."""
def run(self):
"""Run command."""
template_dir = script_path+'/lib/api-doc-templates'
if not self.api_dir:
self.api_dir = script_path+'/docs/api'
print('Writing API docs to {}'.format(self.api_dir))
# Deleting existing API docs
subprocess.call('rm -rf {}/*'.format(self.api_dir), shell=True)
# Running pdoc to create API docs
subprocess.call('export PYTHONPATH={} ; pdoc --html '
'--html-dir {} --overwrite --only-pypath '
'--external-links --template-dir {} '
'./data_utils'.format(script_path, self.api_dir,
template_dir),
shell=True)
# Move all HTML files out of the 'data_utils/' directory that was
# created (unnecessary level)
subprocess.call('mv {}/data_utils/* {}'.format(self.api_dir,
self.api_dir),
shell=True)
subprocess.call('rm -rf {}/data_utils'.format(self.api_dir), shell=True)
setup(
name='data-utils',
version=version,
packages=find_packages(),
include_package_data=True,
url='https://cpc-devtools.ncep.noaa.gov/trac/projects/model-post-processing',
license='',
author='Mike Charles',
author_email='mike.charles@noaa.gov',
description='Set of utilities for post-processing gridded model data',
classifiers=[
"Development Status :: 1 - Planning",
"Environment :: Console",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Atmospheric Science",
],
install_requires=install_reqs,
tests_require=['pytest'],
cmdclass={
'test': PyTest,
'makeapi': MakeAPI
},
)