-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpavement.py
More file actions
148 lines (120 loc) · 3.6 KB
/
Copy pathpavement.py
File metadata and controls
148 lines (120 loc) · 3.6 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
"""Pavement for Pygritia"""
import shlex
import sys
import paver.doctools # pylint: disable=unused-import
import paver.virtual # pylint: disable=unused-import
from paver.easy import * # pylint: disable=unused-wildcard-import,wildcard-import
from paver.options import Bunch
from paver.path import path
from paver.setuputils import setup
if sys.version_info < (3, 7):
sys.exit("Pygritia requires Python >= 3.7")
options = environment.options # pylint: disable=invalid-name
HERE = path(__file__).dirname().abspath()
setup_params = dict( # pylint: disable=invalid-name
name="pygritia",
version="0.2.0",
description="Pygritia: Lazy Symbolic Evaluation",
long_description=open(HERE / 'README.md').read(),
long_description_content_type="text/markdown",
url="https://github.com/gwangyi/pygritia",
author="Sungkwang Lee",
author_email="[email protected]",
license="MIT",
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
],
package_data={'pygritia': ['py.typed']},
packages=['pygritia'],
)
options(
minilib=Bunch(
extra_files=['doctools'],
versioned_name=False,
extra_packages=[],
),
sphinx=Bunch(
docroot='sphinx',
builddir='build',
sourcedir='source',
apidoc_opts=['-e'],
),
)
setup(**setup_params)
@task
@no_help
def env():
"""Ready env"""
import os
def pathify(key, *args):
paths = os.environ.get(key, '').split(os.path.pathsep)
os.environ[key] = os.path.pathsep.join(list(args) + paths)
pathify('MYPYPATH', HERE)
pathify('PYTHONPATH', HERE, *sys.path)
@task
@needs(['env'])
def test():
"""Run unittest"""
try:
import pytest # type: ignore
except ImportError:
raise BuildFailure('install pytest to test')
pytestopts = ['--cov=' + setup_params['name'], '--cov-report=html', '--cov-report=term']
dry('pytest {}'.format(' '.join(pytestopts)), pytest.main, pytestopts)
@task
@needs(['env'])
def typecheck():
"""Run mypy"""
try:
import mypy.main
except ImportError:
raise BuildFailure('install mypy to typecheck')
mypyopts = ['--strict', '-p', setup_params['name']]
dry('mypy {}'.format(' '.join(mypyopts)), mypy.main.main, None, mypyopts)
@task
@needs(['env'])
def lint():
"""Run mypy and pylint"""
try:
import pylint.lint # type: ignore
except ImportError:
raise BuildFailure('install pylint to lint')
pylintopts = ['pavement.py', 'paverlib', setup_params['name']]
dry('pylint {}'.format(' '.join(pylintopts)), pylint.lint.Run, pylintopts)
@task
@needs(['env'])
@consume_args
def shell(args):
"""Run shell"""
import os
sh(' '.join(shlex.quote(arg) for arg in args)
if args else os.environ.get('SHELL', '/bin/bash'))
@task
@needs(['env'])
def nvim():
"""Launch neovim with env"""
import os
os.environ['BULLETTRAIN_VIRTUALENV_PREFIX'] = 'py'
sh('nvim "+bot sp +terminal" +NERDTreeToggle')
@task
@needs(['paverlib.doctools.apidoc', 'paverlib.doctools.html'])
def html():
"""Override html task to copy result to 'docs' directory"""
import shutil
try:
shutil.rmtree(HERE / 'docs')
except FileNotFoundError:
pass
shutil.copytree(
HERE /
options.sphinx.docroot /
options.sphinx.builddir /
'html',
HERE /
'docs')
@task
@needs('generate_setup', 'minilib', 'setuptools.command.sdist')
def sdist():
"""Overrides sdist to make sure that our setup.py is generated."""