This repository was archived by the owner on Mar 23, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpyproject.toml
More file actions
218 lines (187 loc) · 6.48 KB
/
pyproject.toml
File metadata and controls
218 lines (187 loc) · 6.48 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
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
217
218
[build-system]
requires = [
# N.B.: The lowest version of setuptools to support pyproject.toml [project] configuration.
"setuptools>=61",
"ziglang==0.14.1; python_version >= '3.5'",
]
build-backend = "pexcz_build"
backend-path = ["build-system"]
[project]
name = "pexcz"
version = "0.0.3"
description = "Native Pex."
readme = "README.md"
authors = [
{ name = "The PEX developers", email = "developers@pex-tool.org" }
]
requires-python = ">=2.7"
dependencies = []
[tool.setuptools.packages.find]
where = ["src/python"]
include = ["pexcz*"]
[dependency-groups]
dev = [
"dev-cmd[old-pythons]; python_version >= '3.8'",
# We pin at 0.971 since this is the last version of mypy that supports `--python-version 2.7`.
# The python2 extra uses typed-ast which relies on the PyFutureFeatures symbol which was made
# private here: https://github.com/python/cpython/pull/117412
"mypy[python2]==0.971; python_version >= '3.6' and python_version < '3.13'",
"mypy; python_version >= '3.13'",
"pex>=2.40.2",
"pytest",
"ruff; python_version >= '3.8'",
"types-setuptools",
"ziglang==0.14.1; python_version >= '3.5'",
]
[tool.ruff]
line-length = 100
[tool.ruff.lint]
extend-select = ["I"]
extend-safe-fixes = ["F401"]
[[tool.mypy.overrides]]
# N.B.: pkg_resources is imported by setuptools which we extend in our custom build backend. This
# causes issues type-checking under older Pythons; so we skip deep analysis of this 3rd-party
# package.
module = ["pkg_resources.*"]
follow_imports = "skip"
[tool.uv]
required-version = ">=0.6"
# TODO(John Sirois): The one case this doesn't cover is removal of the zig artifacts from
# src/python/pexcz/__pex__/.lib. Currently, uv is blind to this.
cache-keys = [
# Python:
"build-system/**/*",
"pyproject.toml",
"setup.py",
"MANIFEST.in",
# Zig + Python:
"build.zig",
"build.zig.zon",
"src/**/*",
"tools/**/*",
{ env = "PEXCZ_BUILD_TARGETS" },
{ env = "PEXCZ_RELEASE_MODE" },
{ env = "PEXCZ_UV_FORCE_BUILD" },
{ env = "PEXCZ_ZIG_BUILD" }
]
### `dev-cmd` Commands and Tasks:
### -----------------------------
[tool.dev-cmd.commands]
fmt = ["ruff", "format"]
check-fmt = ["ruff", "format", "--diff"]
lint = ["ruff", "check", "--fix"]
check-lint = ["ruff", "check"]
zig-fmt = ["python", "-m", "ziglang", "fmt", "."]
zig-check-fmt = ["python", "-m", "ziglang", "fmt", ".", "--check"]
zig-test = ["python", "-m", "ziglang", "build", "--color", "on", "test"]
[tool.dev-cmd.commands.type-check.factors]
py = "The Python version to type check in <major>.<minor> form; i.e.: 3.13."
[tool.dev-cmd.commands.type-check]
args = [
"mypy",
"--python-version", "{-py:{markers.python_version}}",
"--cache-dir", ".mypy_cache_{markers.python_version}",
"build-system",
"src"
]
[tool.dev-cmd.commands.pytest]
python = "{-py:}"
env = {"PYTHONPATH" = "..", "PYTHONHASHSEED" = "{--hashseed}"}
args = ["pytest"]
cwd = "src/python/tests"
accepts-extra-args = true
[tool.dev-cmd.commands.zig]
args = ["python", "-m", "ziglang"]
accepts-extra-args = true
[tool.dev-cmd.commands.package]
args = ["scripts/package.py"]
accepts-extra-args = true
[tool.dev-cmd.tasks]
test = [["zig-test", "pytest"]]
[tool.dev-cmd.tasks.checks_lt313]
name = "checks"
description = "Runs all development checks, including auto-formatting code."
when = "python_version < '3.13'"
steps = [[
# Zig formatting and testing are independent of Python checks so we run these as two parallel
# groups.
[
"zig-fmt",
"zig-test"
],
[
"fmt",
"lint",
# Parallelizing the type checks and test is safe (they don't modify files), and it nets a
# ~3x speedup over running them all serially.
["type-check-py{2.7,3.{5..13}}", "pytest"],
]
]]
[tool.dev-cmd.tasks.checks_gte313]
name = "checks"
description = "Runs all development checks, including auto-formatting code."
when = "python_version >= '3.13'"
steps = [[
# Zig formatting and testing are independent of Python checks so we run these as two parallel
# groups.
[
"zig-fmt",
"zig-test"
],
[
"fmt",
"lint",
# Parallelizing the type checks and test is safe (they don't modify files), and it nets a
# ~3x speedup over running them all serially.
["type-check-py3.{5..13}", "pytest"],
]
]]
[tool.dev-cmd.tasks.ci]
description = "Runs all checks used for CI."
# None of the CI checks modify files; so they can all be run in parallel which nets a ~1.5x speedup.
steps = [["check-fmt", "check-lint", "type-check", "pytest", "zig-check-fmt", "zig-test"]]
[tool.dev-cmd]
default = "checks"
exit-style = "immediate"
### Older Pythons Support:
### ----------------------
[[tool.dev-cmd.python]]
when = "python_version >= '3.7'"
# Suppress pyproject cache keys since uv.lock is enough to uniquely determine venv content.
pyproject-cache-keys = []
extra-cache-keys = ["uv.lock"]
3rdparty-export-command = ["uv", "export", "-q", "--no-emit-project", "-o", "{requirements.txt}"]
[[tool.dev-cmd.python]]
when = "python_version >= '3' and python_version < '3.7'"
# Suppress the default extra-reqs of ["-e", "."] and perform the editable install ourselves to
# workaround issues in with older pips + editable installs + pyproject.toml.
extra-requirements = []
finalize-command = [
"{venv-python}", "build-system/pexcz_legacy_editable.py", "{venv-site-packages}"
]
[[tool.dev-cmd.python]]
when = "python_version == '2.7'"
# These `--no-emit-package` exclusions work around a bug in UV where the py3-none-any.whl is locked
# and the py2-non-any.whl is not. We add them back below in extra-reqs along with
# backports.functools-lru-cache which uv omits from the lock completely, but is required.
3rdparty-export-command = [
"uv", "export", "-q",
"--no-emit-project",
"--no-emit-package", "more-itertools",
"--no-emit-package", "typing",
"-o", "{requirements.txt}"
]
3rdparty-pip-install-opts = ["--no-deps"]
extra-requirements = '''
backports.functools-lru-cache==1.6.6 \
--hash=sha256:77e27d0ffbb463904bdd5ef8b44363f6cd5ef503e664b3f599a3bf5843ed37cf
more-itertools==5.0.0 \
--hash=sha256:c0a5785b1109a6bd7fac76d6837fd1feca158e54e521ccd2ae8bfe393cc9d4fc
typing==3.10.0.0 \
--hash=sha256:c7219ef20c5fbf413b4567092adfc46fa6203cb8454eda33c3fc1afe1398a308
'''
# Perform the editable install ourselves to workaround issues in with older pips + editable
# installs + pyproject.toml.
finalize-command = [
"{venv-python}", "build-system/pexcz_legacy_editable.py", "{venv-site-packages}"
]