-
Notifications
You must be signed in to change notification settings - Fork 3
Add nix flake and convert to modern pyproject #5
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
Open
patrickjeremic
wants to merge
5
commits into
master
Choose a base branch
from
nix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8d72ca0
Code formatting
patrickjeremic d8a1800
Replace setup.py with modern pyproject
patrickjeremic 01b2ad9
Add nix flake and convert to modern pyproject
patrickjeremic f5600dc
Change to the uv2nix template
patrickjeremic cb26912
Fix remainder qt warnings
patrickjeremic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| *.egg-info | ||
| __pycache__ |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| { | ||
| description = "xfer - Utility to allow out-of-band sending of arbitrary data"; | ||
|
|
||
| inputs = { | ||
| nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11"; | ||
| flake-utils.url = "github:numtide/flake-utils"; | ||
|
|
||
| pyproject-nix = { | ||
| url = "github:pyproject-nix/pyproject.nix"; | ||
| inputs.nixpkgs.follows = "nixpkgs"; | ||
| }; | ||
|
|
||
| uv2nix = { | ||
| url = "github:pyproject-nix/uv2nix"; | ||
| inputs.pyproject-nix.follows = "pyproject-nix"; | ||
| inputs.nixpkgs.follows = "nixpkgs"; | ||
| }; | ||
|
|
||
| pyproject-build-systems = { | ||
| url = "github:pyproject-nix/build-system-pkgs"; | ||
| inputs.pyproject-nix.follows = "pyproject-nix"; | ||
| inputs.uv2nix.follows = "uv2nix"; | ||
| inputs.nixpkgs.follows = "nixpkgs"; | ||
| }; | ||
| }; | ||
|
|
||
| outputs = | ||
| { | ||
| nixpkgs, | ||
| flake-utils, | ||
| pyproject-nix, | ||
| uv2nix, | ||
| pyproject-build-systems, | ||
| ... | ||
| }: | ||
| let | ||
| workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; }; | ||
|
|
||
| projectOverlay = workspace.mkPyprojectOverlay { | ||
| sourcePreference = "wheel"; | ||
| }; | ||
|
|
||
| editableOverlay = workspace.mkEditablePyprojectOverlay { | ||
| root = "$REPO_ROOT"; | ||
| }; | ||
| in | ||
| flake-utils.lib.eachDefaultSystem ( | ||
| system: | ||
| let | ||
| pkgs = import nixpkgs { inherit system; }; | ||
| python = pkgs.python313; | ||
| runtimeLibs = with pkgs; [ | ||
| glib | ||
| libGL | ||
| stdenv.cc.cc.lib | ||
| xorg.libxcb | ||
| zbar | ||
| zlib | ||
|
|
||
| # Required for the uv package opencv wheel | ||
| fontconfig | ||
| dejavu_fonts | ||
| ]; | ||
|
|
||
| pythonSet = | ||
| (pkgs.callPackage pyproject-nix.build.packages { | ||
| inherit python; | ||
| }).overrideScope | ||
| ( | ||
| pkgs.lib.composeManyExtensions [ | ||
| pyproject-build-systems.overlays.wheel | ||
| projectOverlay | ||
| ] | ||
| ); | ||
|
|
||
| editablePythonSet = pythonSet.overrideScope editableOverlay; | ||
|
|
||
| appVenv = pythonSet.mkVirtualEnv "xfer-env" workspace.deps.default; | ||
| devVenv = editablePythonSet.mkVirtualEnv "xfer-dev-env" workspace.deps.all; | ||
| appWrapped = pkgs.symlinkJoin { | ||
| name = "xfer"; | ||
| paths = [ appVenv ]; | ||
| nativeBuildInputs = [ pkgs.makeWrapper ]; | ||
| postBuild = '' | ||
| wrapProgram $out/bin/xfer \ | ||
| --prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath runtimeLibs} | ||
| ''; | ||
| }; | ||
| in | ||
| { | ||
| packages.default = appWrapped; | ||
| apps.default = flake-utils.lib.mkApp { | ||
| drv = appWrapped; | ||
| exePath = "/bin/xfer"; | ||
| }; | ||
|
|
||
| devShells.default = pkgs.mkShell { | ||
| packages = [ | ||
| devVenv | ||
| pkgs.uv | ||
| ] | ||
| ++ runtimeLibs; | ||
|
|
||
| UV_NO_SYNC = "1"; | ||
| UV_PYTHON = editablePythonSet.python.interpreter; | ||
| UV_PYTHON_DOWNLOADS = "never"; | ||
| LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath runtimeLibs; | ||
| NIX_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath runtimeLibs; | ||
| NIX_LD = pkgs.lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker"; | ||
| QT_QPA_FONTDIR = "${pkgs.dejavu_fonts}/share/fonts/truetype"; | ||
| XFER_QT_FONTDIR = "${pkgs.dejavu_fonts}/share/fonts/truetype"; | ||
| QT_QPA_PLATFORM = "xcb"; | ||
| FONTCONFIG_FILE = "${pkgs.fontconfig.out}/etc/fonts/fonts.conf"; | ||
| FONTCONFIG_PATH = "${pkgs.fontconfig.out}/etc/fonts"; | ||
|
|
||
| shellHook = '' | ||
| unset PYTHONPATH | ||
| export REPO_ROOT=$(git rev-parse --show-toplevel) | ||
| export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath runtimeLibs}:$LD_LIBRARY_PATH" | ||
| export QT_QPA_FONTDIR="${pkgs.dejavu_fonts}/share/fonts/truetype" | ||
| export XFER_QT_FONTDIR="${pkgs.dejavu_fonts}/share/fonts/truetype" | ||
| export QT_QPA_PLATFORM="xcb" | ||
| export FONTCONFIG_FILE="${pkgs.fontconfig.out}/etc/fonts/fonts.conf" | ||
| export FONTCONFIG_PATH="${pkgs.fontconfig.out}/etc/fonts" | ||
| unset QT_STYLE_OVERRIDE | ||
| ''; | ||
| }; | ||
| } | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| [build-system] | ||
| requires = ["setuptools>=69", "wheel"] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [project] | ||
| name = "xfer" | ||
| version = "0.0.5" | ||
| description = "Utility to allow out-of-band sending of arbitrary data" | ||
| readme = "README.md" | ||
| requires-python = ">=3.10" | ||
| license = { file = "LICENSE.md" } | ||
| authors = [{ name = "Chorus One", email = "tech@chorus.one" }] | ||
| classifiers = [ | ||
| "Operating System :: OS Independent", | ||
| "Programming Language :: Python", | ||
| "Programming Language :: Python :: 3", | ||
| "Natural Language :: English", | ||
| "Intended Audience :: Developers", | ||
| "Intended Audience :: Financial and Insurance Industry", | ||
| ] | ||
| dependencies = [ | ||
| "click>=8.0", | ||
| "imageio>=2.9", | ||
| "numpy>=1.26", | ||
| "opencv-python>=4.10", | ||
| "pillow>=10.0", | ||
| "pyzbar>=0.1.9", | ||
| "qrcode>=7.4", | ||
| ] | ||
|
|
||
| [project.urls] | ||
| Homepage = "https://chorus.one" | ||
|
|
||
| [project.scripts] | ||
| xfer = "xfer:main" | ||
|
|
||
| [dependency-groups] | ||
| dev = [] | ||
|
|
||
| [tool.setuptools] | ||
| py-modules = ["xfer"] | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly also
<2.0unless you have fixed that problem.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In uv.lock you can see numpy being at2.2.6and i confirmed both flows (read and write) with it. Not sure what was causing the issue outside of nix beforeYou're correct, running
uv sync+uv run python xfer.py readin the nix shell doesn't seem to work. Just runningnix run .#defaultseems to run successfully. Seems to be something off with the python deps still.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I converted the project to
uv2nix(https://pyproject-nix.github.io/uv2nix/templates.html) and it now covers all potential paths (Runningpython xfer.py,uv run python xfer.pyandxferin the dev shell, where xfer is just a wrapper to the xfer.py file). I also confirmed the stand alone binary to work. I didn't see any issues with the new numpy version interestingly.