-
-
Notifications
You must be signed in to change notification settings - Fork 751
/
Copy pathpants.toml
216 lines (197 loc) · 7.55 KB
/
pants.toml
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
[anonymous-telemetry]
# This is opt-in by default, but we explicitly disable here as well.
enabled = false
# repo_id here allows individuals to opt-in on their machine
# To opt-in, use ~/.pants.rc or envrc to set [anonymous-telemetry].enabled=true
repo_id = "de0dea7a-9f6a-4c6e-aa20-6ba5ad969b8a"
[GLOBAL]
pants_version = "2.14.0"
pythonpath = ["%(buildroot)s/pants-plugins"]
backend_packages = [
# python
"pants.backend.python",
"pants.backend.experimental.python", # activates twine `publish` support
"pants.backend.python.mixed_interpreter_constraints",
"pants.backend.python.lint.bandit",
"pants.backend.python.lint.black",
"pants.backend.python.lint.flake8",
"pants.backend.python.lint.pylint",
# shell
"pants.backend.shell",
"pants.backend.shell.lint.shellcheck",
# internal plugins in pants-plugins/
"pants.backend.plugin_development",
]
# pants ignores files in .gitignore, .*/ directories, /dist/ directory, and __pycache__.
pants_ignore.add = [
# TODO: remove these once we start building wheels with pants.
"dist_utils.py",
"setup.py",
# keep tailor from using legacy requirements files (not for pants)
"contrib/examples/requirements.txt",
"contrib/hello_st2/requirements.txt",
"contrib/runners/*/in-requirements.txt",
"contrib/runners/*/requirements.txt",
"st2*/in-requirements.txt",
"st2*/requirements.txt",
"st2common/tests/fixtures/requirements-used-for-tests.txt",
"/fixed-requirements.txt",
"/test-requirements.txt",
# ignore requirements.txt for now, preferring interim files that are decoupled from
# legacy requirements files generation: requirements-pants.txt & lockfiles/st2-constraints.txt
"/requirements.txt",
]
[source]
# recording each pack individually under root patterns is not great, but resolves these issues:
# - Using a /contrib/* or other glob in root_patterns is dodgy as runners & schemas are in the same dir.
# In particular, with /contrib/* in root_patterns, *_runner imports become ambiguous
# (eg `import noop_runner` should use runners/noop_runner/noop_runner not runners/noop_runner).
# - Using pack.yaml in marker_filenames prevents pants from inferring which fixture packs are
# used by which tests. We import a PACK_NAME and PACK_PATH from fixture.py in each of these
# fixture packs to enable this dependency inferrence. Having fine grained inferrence in-turn
# reduces the number of tests that need to be re-run when we change a fixture.
# - Using another marker_file, like PACK_ROOT, is also problematic because of the core pack.
# /contrib/core is symlinked to /st2tests/st2tests/fixtures/packs/core for use as a fixture.
# It is used in quite a few tests, so it needs to continue living in both places.
# But, overlapping source roots (for st2tests and the pack) make importing from the fixture
# as we do with the other fixtures impossible.
# Thus, we really do need to register each pack in contrib (but never under st2tests) separately.
# We might also need to register packs in st2tests/testpacks.
root_patterns = [
# root conftest.py
"/",
# core libs
"/st2*",
# runners
"/contrib/runners/*_runner",
# packs (list /contrib/* packs individually; see note above)
"/contrib/chatops",
"/contrib/core", # WARNING: also symlinked to st2tests/st2tests/fixtures/packs/core
"/contrib/default",
"/contrib/examples",
"/contrib/hello_st2",
"/contrib/linux",
"/contrib/packs",
"/st2tests/testpacks/checks",
"/st2tests/testpacks/errorcheck",
# odd import in examples.isprime
"/contrib/examples/lib",
# lint plugins
"/pylint_plugins",
# pants plugins
"/pants-plugins",
# misc
"/scripts",
"/tools",
# benchmarks
"/st2common/benchmarks/micro",
]
[python]
# resolver_version is always "pip-2020-resolver". legacy is not supported.
enable_resolves = true
default_resolve = "st2"
interpreter_constraints = [
# python_distributions needs a single constraint (vs one line per python version).
# officially, we exclude 3.7 support, but that adds unnecessary complexity: "CPython>=3.6,!=3.7.*,<3.9",
"CPython>=3.6,<3.9",
]
[python.resolves]
st2 = "lockfiles/st2.lock"
pylint_plugins = "lockfiles/pylint_plugins.lock" # lockfiles/pylint.lock should have same contents
pants-plugins = "lockfiles/pants-plugins.lock"
[python.resolves_to_interpreter_constraints]
pants-plugins = [
# this should match the pants interpreter_constraints:
# https://github.com/pantsbuild/pants/blob/2.14.x/pants.toml#L125
# See: https://www.pantsbuild.org/docs/prerequisites
"CPython>=3.7,<3.10",
]
[python.resolves_to_constraints_file]
# Our direct requirements are in requirements-pants.txt;
# put indirect/transitive version constraints here:
st2 = "lockfiles/st2-constraints.txt"
[python-infer]
# https://www.pantsbuild.org/docs/reference-python-infer#unowned_dependency_behavior
# The default changed from "ignore" to "warning" in pants 2.14.
# Many of the new warnings however have been adressed via explicit deps,
# so the warnings are not helpful. In pants 2.16, a "visibility" feature might help
# us to disambiguate deps between files without those explicit BUILD dependencies,
# and without adding "# pants: no-infer-dep" comments all over the codebase.
# Revisit this in pants 2.16 to see if it is feasible to use the default "warning".
unowned_dependency_behavior = "ignore"
[bandit]
lockfile = "lockfiles/bandit.lock"
version = "bandit==1.7.0"
args = [
"-lll", # only HIGH severity level
"--exclude",
"build,dist",
"--quiet", # only show output in the case of an error
]
extra_requirements = [
"setuptools",
# bandit needs stevedore which needs importlib-metadata<5
# see: https://github.com/PyCQA/bandit/pull/952
"importlib-metadata<5;python_version<'3.8'",
]
[black]
lockfile = "lockfiles/black.lock"
version = "black==22.3.0"
interpreter_constraints = [
"CPython>=3.6.2,<3.9",
]
[flake8]
lockfile = "lockfiles/flake8.lock"
version = "flake8==4.0.1" # st2flake8 does not support flake8 v5
extra_requirements = [
# license check plugin
"st2flake8==0.1.0", # TODO: remove in favor of regex-lint
]
config = "lint-configs/python/.flake8"
[pylint]
lockfile = "lockfiles/pylint.lock"
version = "pylint~=2.8.2"
extra_requirements = [
"setuptools", # includes pkg_resources
]
config = "lint-configs/python/.pylintrc"
source_plugins = [
# the /pylint_plugins directory
"pylint_plugins",
]
args = [
# match the current Makefile usage with -E (TODO: drop this)
"--errors-only",
# needed in st2* components, runners, packs
"--load-plugins=api_models",
# needed in st2* components, runners
"--load-plugins=db_models",
]
[pytest]
lockfile = "lockfiles/pytest.lock"
version = "pytest==7.0.1" # copied from https://www.pantsbuild.org/v2.14/docs/reference-pytest#version
extra_requirements.add = [
"pytest-benchmark[histogram]==3.4.1", # used for st2common/benchmarks
#"pytest-timer[colorama]", # report test timing (--with-timer ala nose-timer)
"pytest-icdiff", # make diff output easier to read
"pygments", # highlight code in tracebacks
# other possible plugins
#"pytest-timeout", # time limit on tests
#"pytest-mock", # more convenient mocking
# included by default with pants
#"pytest-cov", # coverage
#"pytest-xdist", # parallel test runs (pants uses this if [pytest].xdist_enabled)
]
args = [
"--no-header", # don't print pytest version for every tested file
]
execution_slot_var = "ST2TESTS_PARALLEL_SLOT"
[regex-lint]
config = "@lint-configs/regex-lint.yaml"
[setuptools]
# setuptools 59.7 (at least) does not support python 3.6
version = "setuptools>=50.3.0,<59.0"
lockfile = "lockfiles/setuptools.lock"
[twine]
lockfile = "lockfiles/twine.lock"
version = "twine>=3.7.1,<3.8"