summaryrefslogtreecommitdiff
path: root/Biz/Bild
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2023-08-16 14:18:10 -0400
committerBen Sima <ben@bsima.me>2023-08-16 18:25:00 -0400
commit7d7e0c02351303489d5555627337a39b519b536a (patch)
tree794817b6d6046a265a129c910885339058773198 /Biz/Bild
parent30d03210f7ac5b12235760f625bac5ff3aa3f85a (diff)
Get python targets building
I added 'black' to Biz/Lint.hs, but not the others because they rely on dependencies being in the PYTHONPATH to work, so they are only relevant in nix builds and repls. I also made some other tweaks to the python checkPhase and linted all the files. Everything should be building and linting correctly now.
Diffstat (limited to 'Biz/Bild')
-rw-r--r--Biz/Bild/Builder.nix11
-rw-r--r--Biz/Bild/Deps/exllama.nix1
-rw-r--r--Biz/Bild/Deps/llama-cpp.nix1
-rw-r--r--Biz/Bild/Deps/nostr-rs-relay.nix2
-rw-r--r--Biz/Bild/Example.py13
-rw-r--r--Biz/Bild/Sources.nix2
6 files changed, 18 insertions, 12 deletions
diff --git a/Biz/Bild/Builder.nix b/Biz/Bild/Builder.nix
index 214c110..2b1403a 100644
--- a/Biz/Bild/Builder.nix
+++ b/Biz/Bild/Builder.nix
@@ -59,10 +59,13 @@ in {
buildInputs = sysdeps_;
checkInputs = [(private.pythonWith (p: with p; [black mypy pylint]))];
checkPhase = ''
- black --quiet --exclude 'setup\.py$' --check .
- pylint --errors-only .
- mypy --strict --no-error-summary --exclude 'setup\.py$' .
- python -m ${main} test
+ check() {
+ $@ || { echo "fail: $name: $3"; exit 1; }
+ }
+ check python -m black --quiet --exclude 'setup\.py$' --check .
+ check python -m pylint --errors-only .
+ check python -m mypy --strict --no-error-summary --exclude 'setup\.py$' .
+ check python -m ${main} test
'';
preBuild = ''
# initialize possibly-empty subdirectories as python modules
diff --git a/Biz/Bild/Deps/exllama.nix b/Biz/Bild/Deps/exllama.nix
index 54d6df1..1f7e529 100644
--- a/Biz/Bild/Deps/exllama.nix
+++ b/Biz/Bild/Deps/exllama.nix
@@ -2,7 +2,6 @@
, sources
, buildPythonPackage
, pythonOlder
-, fetchFromGitHub
, torch # tested on 2.0.1 and 2.1.0 (nightly) with cu118
, safetensors
, sentencepiece
diff --git a/Biz/Bild/Deps/llama-cpp.nix b/Biz/Bild/Deps/llama-cpp.nix
index 85bd778..b247252 100644
--- a/Biz/Bild/Deps/llama-cpp.nix
+++ b/Biz/Bild/Deps/llama-cpp.nix
@@ -1,5 +1,4 @@
{ stdenv
-, pkgs
, sources
, python3
, cmake
diff --git a/Biz/Bild/Deps/nostr-rs-relay.nix b/Biz/Bild/Deps/nostr-rs-relay.nix
index 83d477c..bb0a1cd 100644
--- a/Biz/Bild/Deps/nostr-rs-relay.nix
+++ b/Biz/Bild/Deps/nostr-rs-relay.nix
@@ -1,4 +1,4 @@
-{ lib, fetchFromSourcehut, rustPlatform, pkg-config, openssl }:
+{ fetchFromSourcehut, rustPlatform, pkg-config, openssl }:
rustPlatform.buildRustPackage rec {
pname = "nostr-rs-relay";
diff --git a/Biz/Bild/Example.py b/Biz/Bild/Example.py
index 78a8a6a..25686fa 100644
--- a/Biz/Bild/Example.py
+++ b/Biz/Bild/Example.py
@@ -1,15 +1,16 @@
+"""
+Example Python file that also serves as a test case for bild.
+fernet."""
# : out example
# : dep cryptography
import sys
-from typing import List
-
-from cryptography.fernet import Fernet
+import cryptography.fernet
def cryptic_hello(name: str) -> str:
"Example taken from `cryptography` docs."
- key = Fernet.generate_key()
- f = Fernet(key)
+ key = cryptography.fernet.Fernet.generate_key()
+ f = cryptography.fernet.Fernet(key)
token = f.encrypt(hello(name).encode("utf-8"))
ret = f.decrypt(token).decode("utf-8")
assert ret == hello(name)
@@ -17,10 +18,12 @@ def cryptic_hello(name: str) -> str:
def hello(name: str) -> str:
+ "Say hello"
return f"Hello {name}"
def main() -> None:
+ "Entrypoint"
if "test" in sys.argv:
print("testing success")
print(cryptic_hello("world"))
diff --git a/Biz/Bild/Sources.nix b/Biz/Bild/Sources.nix
index 1938409..927683a 100644
--- a/Biz/Bild/Sources.nix
+++ b/Biz/Bild/Sources.nix
@@ -126,6 +126,7 @@ let
optionalAttrs = cond: as: if cond then as else {};
# fetchTarball version that is compatible between all the versions of Nix
+ # deadnix: skip
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchTarball;
@@ -136,6 +137,7 @@ let
fetchTarball attrs;
# fetchurl version that is compatible between all the versions of Nix
+ # deadnix: skip
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchurl;