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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
{
lib,
buildPythonPackage,
fetchFromGitHub,
fetchpatch,
cmake,
ninja,
# build-system
hatchling,
scikit-build-core,
hatch-vcs,
nanobind,
# deps
antlr4-python3-runtime,
atopile-easyeda2kicad,
black,
case-converter,
cookiecutter,
dataclasses-json,
deprecated,
fastapi-github-oidc,
freetype-py,
gitpython,
kicad-python,
kicadcliwrapper,
matplotlib,
mcp,
more-itertools,
natsort,
numpy,
ordered-set,
pathvalidate,
pint,
posthog,
psutil,
pydantic-settings,
pygls,
questionary,
requests,
rich,
ruamel-yaml,
ruff,
semver,
sexpdata,
shapely,
truststore,
typer,
urllib3,
zstd,
pythonOlder,
# tests
pytestCheckHook,
pytest-benchmark,
pytest-timeout,
pytest-datafiles,
pytest-xdist,
hypothesis,
writableTmpDirAsHomeHook,
versionCheckHook,
}:
buildPythonPackage (finalAttrs: {
pname = "atopile";
version = "0.12.4";
pyproject = true;
disabled = pythonOlder "3.13";
src = fetchFromGitHub {
owner = "atopile";
repo = "atopile";
tag = "v${finalAttrs.version}";
hash = "sha256-SB6D1738t3kQJI+V9ClVsByHm6BsLl078N/wDAHJE6E=";
};
patches = [
(fetchpatch {
name = "migrate-to-pygls-v2.patch";
url = "https://github.com/atopile/atopile/pull/1533.patch";
hash = "sha256-yyRtYFwwcwliz38l7WkzT+zvi+uxWzHdZ06cl8q09Ec=";
})
];
build-system = [
hatchling
scikit-build-core
hatch-vcs
nanobind
];
dontUseCmakeConfigure = true; # skip cmake configure invocation
nativeBuildInputs = [
cmake
ninja
];
dependencies = [
antlr4-python3-runtime
atopile-easyeda2kicad
black # used as a dependency
case-converter
cookiecutter
dataclasses-json
deprecated
fastapi-github-oidc
freetype-py
gitpython
kicad-python
kicadcliwrapper
matplotlib
mcp
more-itertools
natsort
numpy
ordered-set
pathvalidate
pint
posthog
psutil
pydantic-settings
pygls
questionary
requests
rich
ruamel-yaml
ruff
semver
sexpdata
shapely
truststore
typer
urllib3
zstd
];
pythonRelaxDeps = [
"posthog"
"prompt-toolkit"
"zstd"
];
pythonImportsCheck = [ "atopile" ];
nativeCheckInputs = [
writableTmpDirAsHomeHook
pytestCheckHook
pytest-xdist
pytest-benchmark
pytest-datafiles
pytest-timeout
hypothesis
versionCheckHook
];
versionCheckProgramArg = "--version";
preCheck = ''
# do not report worker logs to filee
substituteInPlace test/conftest.py \
--replace-fail "worker_id =" "worker_id = None #"
# unrecognized flags
substituteInPlace pyproject.toml \
--replace-fail "--html=artifacts/test-report.html" "" \
--replace-fail "--self-contained-html" "" \
--replace-fail "--numprocesses=auto" "" \
# Replace this function call that cause test to hang
substituteInPlace \
test/cli/test_packages.py \
test/library/test_names.py \
test/test_examples.py \
test/test_parse_utils.py \
--replace-fail "_repo_root()" "Path('$(pwd)')"
# Fix crash due to empty list in fixture tests
substituteInPlace \
test/test_examples.py \
test/test_parse_utils.py \
--replace-fail "p.stem" "p.stem if isinstance(p, Path) else p"
'';
disabledTestPaths = [
# timouts
"test/test_cli.py"
"test/cli/test_packages.py"
"test/end_to_end/test_net_naming.py"
"test/end_to_end/test_pcb_export.py"
"test/exporters/bom/test_bom.py"
"test/front_end/test_front_end_pick.py"
"test/libs/picker/test_pickers.py"
];
disabledTests = [
# timeout
"test_build_error_logging"
"test_can_evaluate_literals"
"test_examples_build"
"test_net_names_deterministic"
"test_performance_mifs_bus_params"
"test_regression_rp2040_usb_diffpair"
"test_reserved_attrs"
"test_resistor"
# requires internet
"test_simple_pick"
"test_simple_negative_pick"
"test_jlcpcb_pick_resistor"
"test_jlcpcb_pick_capacitor"
"test_regression_rp2040_usb_diffpair_full"
"test_model_translations"
# FileNotFoundError: [Errno 2] No such file or directory: '/build/source/build/logs/latest'
"test_muster_diamond_dependencies"
"test_muster_disconnected_components"
"test_muster_register_decorator"
"test_muster_select_skips_targets_with_failed_dependencies"
"test_muster_select_skips_targets_with_partial_failed_dependencies"
"test_muster_select_yields_targets_with_all_successful_dependencies"
"test_muster_specific_targets_with_dependencies"
];
# in order to use pytest marker, we need to use ppytestFlagsArray
# using pytestFlags causes `ERROR: file or directory not found: slow`
pytestFlagsArray = [
"-m='not slow and not not_in_ci and not regression'"
"--timeout=10" # any test taking long, timouts with more than 60s
"--benchmark-disable"
"--tb=line"
];
doCheck = true;
meta = {
description = "Design circuit boards with code";
homepage = "https://atopile.io";
downloadPage = "https://github.com/atopile/atopile";
changelog = "https://github.com/atopile/atopile/releases/tag/${finalAttrs.src.tag}";
license = with lib.licenses; [ mit ];
maintainers = with lib.maintainers; [ sigmanificient ];
mainProgram = "ato";
};
})
|