From f1f49e7e5231b21156c9b5a95c1c0ce7d168d0d7 Mon Sep 17 00:00:00 2001 From: Matthias Thym Date: Mon, 4 Mar 2024 11:12:01 +0100 Subject: [PATCH] Add example and tests for Python directory option --- examples/python-directory/.gitignore | 5 +++++ examples/python-directory/.test.sh | 10 ++++++++++ examples/python-directory/devenv.nix | 13 +++++++++++++ examples/python-directory/devenv.yaml | 7 +++++++ .../python-directory/directory/pyproject.toml | 17 +++++++++++++++++ 5 files changed, 52 insertions(+) create mode 100644 examples/python-directory/.gitignore create mode 100755 examples/python-directory/.test.sh create mode 100644 examples/python-directory/devenv.nix create mode 100644 examples/python-directory/devenv.yaml create mode 100644 examples/python-directory/directory/pyproject.toml diff --git a/examples/python-directory/.gitignore b/examples/python-directory/.gitignore new file mode 100644 index 000000000..715bef439 --- /dev/null +++ b/examples/python-directory/.gitignore @@ -0,0 +1,5 @@ + +# Devenv +.devenv* +devenv.local.nix + diff --git a/examples/python-directory/.test.sh b/examples/python-directory/.test.sh new file mode 100755 index 000000000..47c0c8436 --- /dev/null +++ b/examples/python-directory/.test.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -exu +POETRY_VENV="$PWD/directory/.venv" +[ -d "$POETRY_VENV" ] +[ "$(poetry env info --path)" = "$POETRY_VENV" ] +[ "$(command -v python)" = "$POETRY_VENV/bin/python" ] +python --version +poetry --version +poetry run python -c 'import requests' +python -c 'import requests' diff --git a/examples/python-directory/devenv.nix b/examples/python-directory/devenv.nix new file mode 100644 index 000000000..db93b10e0 --- /dev/null +++ b/examples/python-directory/devenv.nix @@ -0,0 +1,13 @@ +{ pkgs, config, ... }: + +{ + languages.python = { + enable = true; + directory = "./directory"; + poetry = { + enable = true; + install.enable = true; + activate.enable = true; + }; + }; +} diff --git a/examples/python-directory/devenv.yaml b/examples/python-directory/devenv.yaml new file mode 100644 index 000000000..15728c9fc --- /dev/null +++ b/examples/python-directory/devenv.yaml @@ -0,0 +1,7 @@ +--- + +inputs: + nixpkgs: + url: github:NixOS/nixpkgs/nixpkgs-unstable + nixpkgs-python: + url: github:cachix/nixpkgs-python diff --git a/examples/python-directory/directory/pyproject.toml b/examples/python-directory/directory/pyproject.toml new file mode 100644 index 000000000..99d95e926 --- /dev/null +++ b/examples/python-directory/directory/pyproject.toml @@ -0,0 +1,17 @@ +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + +[tool.poetry] +name = "python-directory" +version = "0.1.0" +description = "" +authors = [ + "Bob van der Linden ", + "Matthias Thym " +] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.11" +requests = "^2.30"