feat(users/Profpatsch): add writers.python3
This is a reexport of nixpkgs.writers.writePython3, but the libraries are passed the package set, like with other writers. Change-Id: Ia5a2ed1b6b329700836a8575d2bde768bf64fb31 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2311 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
parent
533e365c12
commit
6b21b108ba
2 changed files with 34 additions and 9 deletions
|
@ -2,6 +2,14 @@
|
||||||
let
|
let
|
||||||
bins = depot.nix.getBins pkgs.coreutils ["printf" "mkdir" "cat"];
|
bins = depot.nix.getBins pkgs.coreutils ["printf" "mkdir" "cat"];
|
||||||
|
|
||||||
|
python3 = name: args@{
|
||||||
|
libraries ? (_: []),
|
||||||
|
flakeIgnore ? []
|
||||||
|
}: pkgs.writers.writePython3 name {
|
||||||
|
libraries = libraries pkgs.python3Packages;
|
||||||
|
flakeIgnore = flakeIgnore;
|
||||||
|
};
|
||||||
|
|
||||||
python3Lib = { name, libraries ? (_: []) }: moduleString:
|
python3Lib = { name, libraries ? (_: []) }: moduleString:
|
||||||
let srcTree = depot.nix.runExecline.local name { stdin = moduleString; } [
|
let srcTree = depot.nix.runExecline.local name { stdin = moduleString; } [
|
||||||
"importas" "out" "out"
|
"importas" "out" "out"
|
||||||
|
@ -30,10 +38,18 @@ let
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
tests = import ./tests.nix { inherit depot pkgs python3Lib; };
|
tests = import ./tests.nix {
|
||||||
|
inherit
|
||||||
|
depot
|
||||||
|
pkgs
|
||||||
|
python3
|
||||||
|
python3Lib
|
||||||
|
;
|
||||||
|
};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
inherit
|
inherit
|
||||||
|
python3
|
||||||
python3Lib
|
python3Lib
|
||||||
tests
|
tests
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,19 +1,28 @@
|
||||||
{ depot, pkgs, python3Lib }:
|
{ depot, pkgs, python3, python3Lib }:
|
||||||
|
|
||||||
let
|
let
|
||||||
testLib = python3Lib {
|
transitiveLib = python3Lib {
|
||||||
name = "test_lib";
|
name = "transitive";
|
||||||
} ''
|
} ''
|
||||||
def test():
|
def transitive(s):
|
||||||
return "test"
|
return s + " 1 2 3"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
pythonWithLib = pkgs.writers.writePython3 "python-with-lib" {
|
testLib = python3Lib {
|
||||||
libraries = [ testLib ];
|
name = "test_lib";
|
||||||
|
libraries = _: [ transitiveLib ];
|
||||||
|
} ''
|
||||||
|
import transitive
|
||||||
|
def test():
|
||||||
|
return transitive.transitive("test")
|
||||||
|
'';
|
||||||
|
|
||||||
|
pythonWithLib = python3 "python-with-lib" {
|
||||||
|
libraries = _: [ testLib ];
|
||||||
} ''
|
} ''
|
||||||
import test_lib
|
import test_lib
|
||||||
|
|
||||||
assert(test_lib.test() == "test")
|
assert(test_lib.test() == "test 1 2 3")
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
|
Loading…
Reference in a new issue