{ lib, buildPythonPackage, fetchPypi, cmake, ninja, zig_0_16, # build-system hatchling, scikit-build-core, hatch-vcs, nanobind, # deps anthropic, antlr4-python3-runtime, atopile-easyeda2kicad, atopile-kicad-python, black, case-converter, cookiecutter, dataclasses-json, deprecated, fastapi, fastapi-github-oidc, freetype-py, gitpython, httpx, jinja2, keyring, kicadcliwrapper, matplotlib, mcp, more-itertools, natsort, numpy, openai, ordered-set, pathvalidate, pint, platformdirs, prompt-toolkit, psutil, pyaaf2, pydantic-settings, pygls, pytest, pyyaml, questionary, rich, ruamel-yaml, ruff, semver, sexpdata, shapely, truststore, typer, typing-extensions, urllib3, uvicorn, watchdog, websockets, zstd, pythonOlder, # tests gitMinimal, hypothesis, pytest-xdist, pytestCheckHook, versionCheckHook, writableTmpDirAsHomeHook, }: buildPythonPackage (finalAttrs: { pname = "atopile"; version = "0.15.9"; pyproject = true; disabled = pythonOlder "3.14"; # Upstream stopped pushing tags (and commits) to GitHub after v0.14.x. # The PyPI sdist also ships the PKG-INFO metadata needed by hatch-vcs. src = fetchPypi { inherit (finalAttrs) pname version; hash = "sha256-aBzB4SNkbdEz3jG2Ma7a9OqsiGgmE7T4LR2ks++LTo4="; }; # Upstream pins a fork of scikit-build-core (editable-mode patch) we don't need. postPatch = '' substituteInPlace pyproject.toml \ --replace-fail \ 'scikit-build-core @ git+https://github.com/atopile/scikit-build-core.git@feature/allow_editable' \ 'scikit-build-core' \ --replace-fail '"ziglang==0.16.0",' "" ''; build-system = [ hatchling scikit-build-core hatch-vcs nanobind ]; dontUseCmakeConfigure = true; # skip cmake configure invocation # The CMake build shells out to `python -m ziglang ...` (the ziglang pip # wheel, not packaged in nixpkgs). Provide a shim module that execs the real # zig, and give zig a writable cache dir. preBuild = '' mkdir -p zigshim/ziglang touch zigshim/ziglang/__init__.py printf 'import os, sys\nos.execv("%s/bin/zig", ["zig", *sys.argv[1:]])\n' "${zig_0_16}" > zigshim/ziglang/__main__.py export PYTHONPATH="$PWD/zigshim:$PYTHONPATH" export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig-cache" ''; nativeBuildInputs = [ cmake ninja zig_0_16 # replaces the ziglang pip build-dep; build calls zig to compile faebryk core ]; dependencies = [ anthropic antlr4-python3-runtime atopile-easyeda2kicad atopile-kicad-python black # used as a dependency case-converter cookiecutter dataclasses-json deprecated fastapi fastapi-github-oidc freetype-py gitpython httpx jinja2 keyring kicadcliwrapper matplotlib mcp more-itertools nanobind natsort numpy openai ordered-set pathvalidate pint platformdirs prompt-toolkit psutil pyaaf2 pydantic-settings pygls pytest # imported at runtime pyyaml questionary rich ruamel-yaml ruff semver sexpdata shapely truststore typer typing-extensions urllib3 uvicorn watchdog websockets zstd ] ++ mcp.optional-dependencies.cli; pythonRelaxDeps = [ "deprecated" "prompt-toolkit" "ruff" ]; pythonImportsCheck = [ "atopile" ]; nativeCheckInputs = [ gitMinimal hypothesis pytest-xdist pytestCheckHook versionCheckHook writableTmpDirAsHomeHook ]; env.SKIP_EASYEDA = "1"; preCheck = # Use a per-worker log dir: workers racing on the shared sqlite log DB at # collection time cause `sqlite3.OperationalError: disk I/O error`. # Also, app_root()/repo_root() look for pyproject.toml/.git above the installed module. '' cat - conftest.py > conftest.py.new <