Skip to content

Commit

Permalink
template/python: fix some things
Browse files Browse the repository at this point in the history
  • Loading branch information
42LoCo42 committed Dec 12, 2024
1 parent 46ba48d commit e8edf13
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
3 changes: 3 additions & 0 deletions templates/python/examplepy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python3

print("Hello, World!")
27 changes: 22 additions & 5 deletions templates/python/flake.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
inputs = {
pyproject.url = "pyproject-nix/build-system-pkgs";
pyproject.url = "github:pyproject-nix/build-system-pkgs";
pyproject.inputs.nixpkgs.follows = "nixpkgs";
};

Expand All @@ -9,16 +9,20 @@
let
pkgs = import nixpkgs { inherit system; };

inherit (pkgs.lib) composeManyExtensions;
inherit (pkgs.lib) composeManyExtensions pipe;
inherit (pkgs.lib.fileset) toSource unions;
inherit (pyproject.inputs) pyproject-nix uv2nix;

pname = "example";
pname = pipe ./pyproject.toml [
builtins.readFile
builtins.fromTOML
(x: x.project.name)
];

src = toSource {
root = ./.;
fileset = unions [
./main.py
./${pname}.py
./pyproject.toml
./uv.lock
];
Expand All @@ -42,7 +46,20 @@
venv = pythonSet.mkVirtualEnv pname workspace.deps.default;
in
{
packages.default = pythonSet.${pname};
packages.default = pkgs.stdenv.mkDerivation {
inherit pname;
inherit (pythonSet.${pname}) version;
dontUnpack = true;

installPhase = ''
mkdir -p $out/bin
cat << EOF > $out/bin/${pname}
#!${venv}/bin/python
import ${pname}
EOF
chmod +x $out/bin/${pname}
'';
};

devShells.default = pkgs.mkShell {
packages = with pkgs; [ venv uv ];
Expand Down
6 changes: 0 additions & 6 deletions templates/python/hello.py

This file was deleted.

3 changes: 1 addition & 2 deletions templates/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[project]
name = "example"
name = "examplepy"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = []
2 changes: 1 addition & 1 deletion templates/python/uv.lock

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

0 comments on commit e8edf13

Please sign in to comment.