diff --git a/examples/python-uv-pyproject/.envrc b/examples/python-uv-pyproject/.envrc new file mode 100644 index 000000000..894571bf4 --- /dev/null +++ b/examples/python-uv-pyproject/.envrc @@ -0,0 +1,3 @@ +source_url "https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc" "sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k=" + +use devenv diff --git a/examples/python-uv-pyproject/.gitignore b/examples/python-uv-pyproject/.gitignore new file mode 100644 index 000000000..8dbeb4b52 --- /dev/null +++ b/examples/python-uv-pyproject/.gitignore @@ -0,0 +1,11 @@ +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml + +__pycache__ diff --git a/examples/python-uv-pyproject/.python-version b/examples/python-uv-pyproject/.python-version new file mode 100644 index 000000000..e4fba2183 --- /dev/null +++ b/examples/python-uv-pyproject/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/examples/python-uv-pyproject/.test.sh b/examples/python-uv-pyproject/.test.sh new file mode 100644 index 000000000..0d371b40a --- /dev/null +++ b/examples/python-uv-pyproject/.test.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +set -ex +uv run hello.py diff --git a/examples/python-uv-pyproject/README.md b/examples/python-uv-pyproject/README.md new file mode 100644 index 000000000..557977d1f --- /dev/null +++ b/examples/python-uv-pyproject/README.md @@ -0,0 +1 @@ +Use `uv run` to run your main file using this project structure. See the [uv documentation](https://docs.astral.sh/uv/). Make sure `.python-version` matches your desired python version, or uv may download it's own python. diff --git a/examples/python-uv-pyproject/devenv.nix b/examples/python-uv-pyproject/devenv.nix new file mode 100644 index 000000000..8ec4788d5 --- /dev/null +++ b/examples/python-uv-pyproject/devenv.nix @@ -0,0 +1,49 @@ +{ pkgs, lib, config, inputs, ... }: + +{ + # https://devenv.sh/basics/ + env.GREET = "devenv"; + + # https://devenv.sh/packages/ + packages = [ pkgs.git ]; + + # https://devenv.sh/languages/ + # languages.rust.enable = true; + languages.python = { + enable = true; + uv.enable = true; + }; + + # https://devenv.sh/processes/ + # processes.cargo-watch.exec = "cargo-watch"; + + # https://devenv.sh/services/ + # services.postgres.enable = true; + + # https://devenv.sh/scripts/ + scripts.hello.exec = '' + echo hello from $GREET + ''; + + enterShell = '' + hello + git --version + ''; + + # https://devenv.sh/tasks/ + # tasks = { + # "myproj:setup".exec = "mytool build"; + # "devenv:enterShell".after = [ "myproj:setup" ]; + # }; + + # https://devenv.sh/tests/ + enterTest = '' + echo "Running tests" + git --version | grep --color=auto "${pkgs.git.version}" + ''; + + # https://devenv.sh/git-hooks/ + # git-hooks.hooks.shellcheck.enable = true; + + # See full reference at https://devenv.sh/reference/options/ +} diff --git a/examples/python-uv-pyproject/devenv.yaml b/examples/python-uv-pyproject/devenv.yaml new file mode 100644 index 000000000..ec3f91a87 --- /dev/null +++ b/examples/python-uv-pyproject/devenv.yaml @@ -0,0 +1,15 @@ +# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json +inputs: + nixpkgs: + url: github:nixos/nixpkgs/nixpkgs-unstable + +# If you're using non-OSS software, you can set allowUnfree to true. +# allowUnfree: true + +# If you're willing to use a package that's vulnerable +# permittedInsecurePackages: +# - "openssl-1.1.1w" + +# If you have more than one devenv you can merge them +#imports: +# - ./backend diff --git a/examples/python-uv-pyproject/hello.py b/examples/python-uv-pyproject/hello.py new file mode 100644 index 000000000..6196989cd --- /dev/null +++ b/examples/python-uv-pyproject/hello.py @@ -0,0 +1,8 @@ +from lib.value import application + +def main(): + print(f"Hello from {application}!") + + +if __name__ == "__main__": + main() diff --git a/examples/python-uv-pyproject/lib/__init__.py b/examples/python-uv-pyproject/lib/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/python-uv-pyproject/lib/value.py b/examples/python-uv-pyproject/lib/value.py new file mode 100644 index 000000000..bc912f7c6 --- /dev/null +++ b/examples/python-uv-pyproject/lib/value.py @@ -0,0 +1 @@ +application = 'devenv' diff --git a/examples/python-uv-pyproject/pyproject.toml b/examples/python-uv-pyproject/pyproject.toml new file mode 100644 index 000000000..17c925344 --- /dev/null +++ b/examples/python-uv-pyproject/pyproject.toml @@ -0,0 +1,7 @@ +[project] +name = "python-uv-pyproject" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.11" +dependencies = [] diff --git a/examples/python-uv-pyproject/uv.lock b/examples/python-uv-pyproject/uv.lock new file mode 100644 index 000000000..d7d59f703 --- /dev/null +++ b/examples/python-uv-pyproject/uv.lock @@ -0,0 +1,7 @@ +version = 1 +requires-python = ">=3.11" + +[[package]] +name = "python-uv-pyproject" +version = "0.1.0" +source = { virtual = "." }