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

115
flake.nix
View file

@ -1,41 +1,90 @@
{ {
description = "Flake using pyproject.toml metadata"; description = "Flake using pyproject.toml metadata";
inputs.pyproject-nix.url = "github:pyproject-nix/pyproject.nix"; inputs = {
inputs.pyproject-nix.inputs.nixpkgs.follows = "nixpkgs"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# pyproject-nix.url = "github:pyproject-nix/pyproject.nix";
outputs = # pyproject-nix.inputs.nixpkgs.follows = "nixpkgs";
{ nixpkgs, pyproject-nix, ... }: flake-utils.url = "github:numtide/flake-utils";
let
inherit (nixpkgs) lib;
forAllSystems = lib.genAttrs lib.systems.flakeExposed;
project = pyproject-nix.lib.project.loadPyproject {
projectRoot = ./.;
}; };
pythonAttr = "python3"; outputs = {
in self,
{ nixpkgs,
devShells = forAllSystems (system: { flake-utils,
default = ...
let }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.${pythonAttr};
pythonEnv = python.withPackages (project.renderers.withPackages { inherit python; }); pyproject = builtins.fromTOML (builtins.readFile ./pyproject.toml);
in project = pyproject.project;
pkgs.mkShell { packages = [ pythonEnv ]; }; 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;
};
editablePackage = pkgs.python3.pkgs.mkPythonEditablePackage {
pname = project.name;
inherit (project) scripts version;
root = "$PWD";
};
in {
devShells = {
default = pkgs.mkShell {
inputsFrom = [
package
];
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};
};
}); });
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.${pythonAttr};
in
{
default = python.pkgs.buildPythonPackage (project.renderers.buildPythonPackage { inherit python; });
}
);
};
} }

View file

@ -1,9 +1,15 @@
[project] [project]
name = "hello-python" name = "protestswap"
version = "0.1.0" version = "0.1.0"
license-files = ["LICEN[CS]E*"]
description = "A minimal pyproject.toml" description = "A minimal pyproject.toml"
authors = [ ] authors = [ ]
requires-python = ">=3.13" requires-python = ">=3.13"
dependencies = [ "insightface", "opencv-python", "matplotlib" ] 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()