Add currently-failing example of editable shell

This commit is contained in:
Silvan Mosberger 2020-05-23 23:48:09 +02:00
parent 1b12594c8e
commit e646d6e4f0
No known key found for this signature in database
GPG key ID: E8F1E9EAD284E17D
6 changed files with 122 additions and 0 deletions

View file

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

View file

@ -0,0 +1,42 @@
{ lib, poetry2nix, python3, runCommand, curl }:
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
run() {
${env}/bin/gunicorn --bind=unix:socket --paste ${./paste.ini} &
sleep 1
result=$(${curl}/bin/curl --unix-socket socket localhost)
echo "Got: $result" >&2
kill $!
echo "$result"
}
if [[ "$(run)" != "Original" ]]; then
echo "Package didn't return Original string"
exit 1
fi
sed -i 's/Original/Changed/' src/trivial/__init__.py
if [[ "$(run)" == "Original" ]]; then
echo "Package wasn't editable, still returning the Original string even after the source was changed"
exit 1
fi
touch $out
''

View file

@ -0,0 +1,4 @@
[app:main]
use = egg:trivial

42
tests/editable-egg/poetry.lock generated Normal file
View file

@ -0,0 +1,42 @@
[[package]]
category = "main"
description = "WSGI HTTP Server for UNIX"
name = "gunicorn"
optional = false
python-versions = ">=3.4"
version = "20.0.4"
[package.dependencies]
setuptools = ">=3.0"
[package.extras]
eventlet = ["eventlet (>=0.9.7)"]
gevent = ["gevent (>=0.13)"]
setproctitle = ["setproctitle"]
tornado = ["tornado (>=0.2)"]
[[package]]
category = "main"
description = "Load, configure, and compose WSGI applications and servers"
name = "pastedeploy"
optional = false
python-versions = "*"
version = "2.1.0"
[package.extras]
docs = ["Sphinx (>=1.7.5)", "pylons-sphinx-themes"]
paste = ["paste"]
[metadata]
content-hash = "c92b82bfb17f2a071c3c5bf512e46f2c6c38a85b7f92a618033a4d8c85a3fced"
python-versions = "^3.7"
[metadata.files]
gunicorn = [
{file = "gunicorn-20.0.4-py2.py3-none-any.whl", hash = "sha256:cd4a810dd51bf497552cf3f863b575dabd73d6ad6a91075b65936b151cbf4f9c"},
{file = "gunicorn-20.0.4.tar.gz", hash = "sha256:1904bb2b8a43658807108d59c3f3d56c2b6121a701161de0ddf9ad140073c626"},
]
pastedeploy = [
{file = "PasteDeploy-2.1.0-py2.py3-none-any.whl", hash = "sha256:bc6578735a32c77435a3e0769426983d3df6dc53a7229290c495ec10aefb81a5"},
{file = "PasteDeploy-2.1.0.tar.gz", hash = "sha256:e7559878b6e92023041484be9bcb6d767cf4492fc3de7257a5dae76a7cc11a9b"},
]

View file

@ -0,0 +1,20 @@
[tool.poetry]
name = "trivial"
version = "0.1.0"
description = "poetry2nix test"
authors = ["Your Name <you@example.com>"]
packages = [
{ include = "trivial", from = "src" },
]
[tool.poetry.plugins."paste.app_factory"]
main = "trivial:app_factory"
[tool.poetry.dependencies]
python = "^3.7"
gunicorn = "^20.0.4"
pastedeploy = "^2.1.0"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

View file

@ -0,0 +1,13 @@
def app(environ, start_response):
"""Simplest possible application object"""
data = b'Original\n'
status = '200 OK'
response_headers = [
('Content-type', 'text/plain'),
('Content-Length', str(len(data)))
]
start_response(status, response_headers)
return iter([data])
def app_factory(global_config, **local_conf):
return app