Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a uv pyproject example #1600

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/python-uv-pyproject/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_url "https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc" "sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k="

use devenv
11 changes: 11 additions & 0 deletions examples/python-uv-pyproject/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Devenv
.devenv*
devenv.local.nix

# direnv
.direnv

# pre-commit
.pre-commit-config.yaml

__pycache__
1 change: 1 addition & 0 deletions examples/python-uv-pyproject/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
3 changes: 3 additions & 0 deletions examples/python-uv-pyproject/.test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
set -ex
uv run hello.py
1 change: 1 addition & 0 deletions examples/python-uv-pyproject/README.md
Original file line number Diff line number Diff line change
@@ -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.
49 changes: 49 additions & 0 deletions examples/python-uv-pyproject/devenv.nix
Original file line number Diff line number Diff line change
@@ -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/
}
15 changes: 15 additions & 0 deletions examples/python-uv-pyproject/devenv.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions examples/python-uv-pyproject/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from lib.value import application

def main():
print(f"Hello from {application}!")


if __name__ == "__main__":
main()
Empty file.
1 change: 1 addition & 0 deletions examples/python-uv-pyproject/lib/value.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application = 'devenv'
7 changes: 7 additions & 0 deletions examples/python-uv-pyproject/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = []
7 changes: 7 additions & 0 deletions examples/python-uv-pyproject/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading