Add test case for editable mkPoetryEnv

This commit is contained in:
Silvan Mosberger 2020-05-08 17:01:46 +02:00 committed by adisbladis
parent df7afa36e3
commit eb940dc9a3
No known key found for this signature in database
GPG key ID: 110BFAD44C6249B7
5 changed files with 45 additions and 0 deletions

View file

@ -36,6 +36,7 @@ builtins.removeAttrs
canonical-module-names = callTest ./canonical-module-names { }; canonical-module-names = callTest ./canonical-module-names { };
wandb = callTest ./wandb { }; wandb = callTest ./wandb { };
dependency-environment = callTest ./dependency-environment { }; dependency-environment = callTest ./dependency-environment { };
editable = callTest ./editable { };
# Test building poetry # Test building poetry
inherit poetry; inherit poetry;

View file

@ -0,0 +1,24 @@
{ lib, poetry2nix, python3, runCommand }:
let
env = poetry2nix.mkPoetryEnv {
python = python3;
pyproject = ./pyproject.toml;
poetrylock = ./poetry.lock;
editablePackageSources = {
# Usually this would be trivial = ./src
# But we use this here to be able to test it
# in a derivation build
trivial = "/build/src";
};
};
in
runCommand "env-test" { } ''
cp -r --no-preserve=mode ${./src} src
echo 'print("Changed")' > src/trivial/__main__.py
if [[ $(${env}/bin/python -m trivial) != "Changed" ]]; then
echo "Package wasn't editable!"
exit 1
fi
touch $out
'' // { inherit env; }

7
tests/editable/poetry.lock generated Normal file
View file

@ -0,0 +1,7 @@
package = []
[metadata]
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
python-versions = "*"
[metadata.files]

View file

@ -0,0 +1,12 @@
[tool.poetry]
name = "trivial"
version = "0.1.0"
description = "poetry2nix test"
authors = ["Your Name <you@example.com>"]
packages = [
{ include = "trivial", from = "src" },
]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

View file

@ -0,0 +1 @@
print("Original")