switch to uv and stuff

This commit is contained in:
Prunebutt 2025-10-14 00:01:19 +02:00
parent 1f3eb16391
commit bb1b8eecb9
6 changed files with 133 additions and 56 deletions

61
flake.lock generated
View file

@ -1,43 +1,58 @@
{
"nodes": {
"nixpkgs": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1760164275,
"narHash": "sha256-gKl2Gtro/LNf8P+4L3S2RsZ0G390ccd5MyXYrTdMCFE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "362791944032cb532aabbeed7887a441496d5e6e",
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"pyproject-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"nixpkgs": {
"locked": {
"lastModified": 1759739877,
"narHash": "sha256-XfcxM4nzSuuRmFGiy/MhGwYf9EennQ2+0jjR2aJqtKE=",
"owner": "pyproject-nix",
"repo": "pyproject.nix",
"rev": "966e0961f9670f847439ba90dc25ffaa112d8803",
"lastModified": 1760284886,
"narHash": "sha256-TK9Kr0BYBQ/1P5kAsnNQhmWWKgmZXwUQr4ZMjCzWf2c=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "cf3f5c4def3c7b5f1fc012b3d839575dbe552d43",
"type": "github"
},
"original": {
"owner": "pyproject-nix",
"repo": "pyproject.nix",
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"pyproject-nix": "pyproject-nix"
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},

113
flake.nix
View file

@ -1,41 +1,90 @@
{
description = "Flake using pyproject.toml metadata";
inputs.pyproject-nix.url = "github:pyproject-nix/pyproject.nix";
inputs.pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# pyproject-nix.url = "github:pyproject-nix/pyproject.nix";
# pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{ nixpkgs, pyproject-nix, ... }:
let
inherit (nixpkgs) lib;
forAllSystems = lib.genAttrs lib.systems.flakeExposed;
outputs = {
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
project = pyproject-nix.lib.project.loadPyproject {
projectRoot = ./.;
pyproject = builtins.fromTOML (builtins.readFile ./pyproject.toml);
project = pyproject.project;
package = pkgs.python3Packages.buildPythonPackage {
pname = project.name;
inherit (project) version;
format = "pyproject";
src = ./.;
build-system = with pkgs.python3Packages; [
uv-build
];
# # test dependencies
nativeCheckInputs = with pkgs; [
# python3Packages.mypy
# python3Packages.pytest
taplo
];
# checkPhase = '''';
propagatedBuildInputs = with pkgs; [
python3Packages.click
] ++ builtins.map (dep: pkgs.python3Packages.${dep}) project.dependencies;
};
pythonAttr = "python3";
in
{
devShells = forAllSystems (system: {
default =
let
pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.${pythonAttr};
pythonEnv = python.withPackages (project.renderers.withPackages { inherit python; });
in
pkgs.mkShell { packages = [ pythonEnv ]; };
});
editablePackage = pkgs.python3.pkgs.mkPythonEditablePackage {
pname = project.name;
inherit (project) scripts version;
root = "$PWD";
};
in {
devShells = {
default = pkgs.mkShell {
inputsFrom = [
package
];
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.${pythonAttr};
in
{
default = python.pkgs.buildPythonPackage (project.renderers.buildPythonPackage { inherit python; });
}
);
};
buildInputs = [
# our package
editablePackage
#################
# VARIOUS TOOLS #
#################
pkgs.python3Packages.build
pkgs.python3Packages.ipython
####################
# EDITOR/LSP TOOLS #
####################
# LSP server:
pkgs.python3Packages.python-lsp-server
# LSP server plugins of interest:
pkgs.python3Packages.pylsp-mypy
pkgs.python3Packages.pylsp-rope
pkgs.python3Packages.python-lsp-ruff
];
};
};
packages = {
"${project.name}" = package;
default = self.packages.${system}.${project.name};
};
});
}

View file

@ -1,9 +1,15 @@
[project]
name = "hello-python"
name = "protestswap"
version = "0.1.0"
license-files = ["LICEN[CS]E*"]
description = "A minimal pyproject.toml"
authors = [ ]
requires-python = ">=3.13"
dependencies = [ "insightface", "opencv-python", "matplotlib" ]
[project.scripts]
protestswap-cli = "protestswap.cli:main"
[build-system]
requires = ["uv_build >= 0.8.17, <0.9.0"]
build-backend = "uv_build"

View file

7
src/protestswap/cli.py Normal file
View file

@ -0,0 +1,7 @@
import protestswap
def main():
print("hello protest")
if __name__ == "__main__":
main()