diff --git a/tests/default.nix b/tests/default.nix index a0ce11d..ec50295 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -35,6 +35,7 @@ builtins.removeAttrs source-filter = callTest ./source-filter { }; canonical-module-names = callTest ./canonical-module-names { }; wandb = callTest ./wandb { }; + dependency-environment = callTest ./dependency-environment { }; # Test building poetry inherit poetry; diff --git a/tests/dependency-environment/default.nix b/tests/dependency-environment/default.nix new file mode 100644 index 0000000..153cad6 --- /dev/null +++ b/tests/dependency-environment/default.nix @@ -0,0 +1,15 @@ +{ curl, lib, poetry2nix, python3, runCommand }: +let + app = poetry2nix.mkPoetryApplication { + python = python3; + src = lib.cleanSource ./.; + pyproject = ./pyproject.toml; + poetrylock = ./poetry.lock; + }; +in +runCommand "app-env-test" { } '' + ${app.dependencyEnv}/bin/gunicorn --bind=unix:socket trivial:app & + sleep 1 + ${curl}/bin/curl --unix-socket socket localhost + touch $out +'' diff --git a/tests/dependency-environment/poetry.lock b/tests/dependency-environment/poetry.lock new file mode 100644 index 0000000..4fdf3f5 --- /dev/null +++ b/tests/dependency-environment/poetry.lock @@ -0,0 +1,22 @@ +[[package]] +category = "main" +description = "WSGI HTTP Server for UNIX" +name = "gunicorn" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*" +version = "19.10.0" + +[package.extras] +eventlet = ["eventlet (>=0.9.7)"] +gevent = ["gevent (>=0.13)"] +tornado = ["tornado (>=0.2)"] + +[metadata] +content-hash = "0114cd5ff6f51e66caf2a287d7cd723e38549ec1c57b4999a2585ac6c86b9b06" +python-versions = "*" + +[metadata.files] +gunicorn = [ + {file = "gunicorn-19.10.0-py2.py3-none-any.whl", hash = "sha256:c3930fe8de6778ab5ea716cab432ae6335fa9f03b3f2c3e02529214c476f4bcb"}, + {file = "gunicorn-19.10.0.tar.gz", hash = "sha256:f9de24e358b841567063629cd0a656b26792a41e23a24d0dcb40224fc3940081"}, +] diff --git a/tests/dependency-environment/pyproject.toml b/tests/dependency-environment/pyproject.toml new file mode 100644 index 0000000..d7cb5f6 --- /dev/null +++ b/tests/dependency-environment/pyproject.toml @@ -0,0 +1,12 @@ +[tool.poetry] +name = "trivial" +version = "0.1.0" +description = "poetry2nix test" +authors = ["Your Name "] + +[tool.poetry.dependencies] +gunicorn = "*" + +[build-system] +requires = ["poetry>=0.12"] +build-backend = "poetry.masonry.api" diff --git a/tests/dependency-environment/trivial.py b/tests/dependency-environment/trivial.py new file mode 100644 index 0000000..f098632 --- /dev/null +++ b/tests/dependency-environment/trivial.py @@ -0,0 +1,10 @@ +def app(environ, start_response): + """Simplest possible application object""" + data = b'Hello, World!\n' + status = '200 OK' + response_headers = [ + ('Content-type', 'text/plain'), + ('Content-Length', str(len(data))) + ] + start_response(status, response_headers) + return iter([data])