From bb1b8eecb918d1adf3f0c555fc8f8284e536dfdc Mon Sep 17 00:00:00 2001 From: Prunebutt Date: Tue, 14 Oct 2025 00:01:19 +0200 Subject: [PATCH] switch to uv and stuff --- flake.lock | 61 ++++++---- flake.nix | 113 +++++++++++++----- pyproject.toml | 8 +- src/protestswap/__init__.py | 0 src/protestswap/cli.py | 7 ++ .../protestswap.py} | 0 6 files changed, 133 insertions(+), 56 deletions(-) create mode 100644 src/protestswap/__init__.py create mode 100644 src/protestswap/cli.py rename src/{faceswap.py => protestswap/protestswap.py} (100%) diff --git a/flake.lock b/flake.lock index e4f40ad..4672eeb 100644 --- a/flake.lock +++ b/flake.lock @@ -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" } } }, diff --git a/flake.nix b/flake.nix index 832cf8c..446c016 100644 --- a/flake.nix +++ b/flake.nix @@ -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}; + }; + }); } diff --git a/pyproject.toml b/pyproject.toml index 6179bdc..c67b0fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/src/protestswap/__init__.py b/src/protestswap/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/protestswap/cli.py b/src/protestswap/cli.py new file mode 100644 index 0000000..bcd35ad --- /dev/null +++ b/src/protestswap/cli.py @@ -0,0 +1,7 @@ +import protestswap + +def main(): + print("hello protest") + +if __name__ == "__main__": + main() diff --git a/src/faceswap.py b/src/protestswap/protestswap.py similarity index 100% rename from src/faceswap.py rename to src/protestswap/protestswap.py