Skip to content

Commit 5f2b652

Browse files
committed
poetry->uv
1 parent 4b4f06f commit 5f2b652

10 files changed

Lines changed: 437 additions & 320 deletions

File tree

.github/workflows/poetry-build-test-release.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,21 @@ jobs:
2323
uses: snok/install-poetry@v1
2424
- name: Install dependencies
2525
run: |
26-
poetry lock --no-interaction
27-
poetry install --no-interaction
26+
uv lock
2827
- name: Build
2928
run: |
30-
poetry build
29+
uv build
3130
- name: Test
3231
run: |
33-
poetry run pytest
32+
uv run pytest
3433
- name: Lint with flake8
3534
continue-on-error: true
3635
run: |
3736
# stop the build if there are Python syntax errors or undefined names
38-
poetry run flake8 ./src --count --select=E9,F63,F7,F82 --show-source --statistics
37+
uv run flake8 ./src --count --select=E9,F63,F7,F82 --show-source --statistics
3938
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
40-
poetry run flake8 ./src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
39+
uv run flake8 ./src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
4140
- name: Publish distribution 📦 to PyPI
4241
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
4342
run: |
44-
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
45-
poetry publish
43+
uv publish --token ${{ secrets.PYPI_TOKEN }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ dist
33

44
__pycache__
55
*.egg-info
6-
.idea
6+
.idea
7+
8+
result

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ This lib depends on `pyserial` and the awesome `construct` lib.
7878
TCP demo:
7979

8080
```bash
81-
poetry run python ./demos/test-tcp.py 192.168.1.7 10
81+
uv run python ./demos/test-tcp.py 192.168.1.7 10
8282
```
8383

8484
Serial:
8585

8686
```bash
8787
socat -v pty,link=/tmp/serial,waitslave tcp:192.168.1.7:23,forever
8888
# in another terminal
89-
poetry run python ./demos/test-serial.py /tmp/serial 1
89+
uv run python ./demos/test-serial.py /tmp/serial 1
9090
```
9191

9292
# Hardware wiring

flake.lock

Lines changed: 73 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 81 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,89 @@
33

44
inputs.flake-utils.url = "github:numtide/flake-utils";
55

6+
inputs.pyproject-nix = {
7+
url = "github:pyproject-nix/pyproject.nix";
8+
inputs.nixpkgs.follows = "nixpkgs";
9+
};
10+
11+
inputs.uv2nix = {
12+
url = "github:pyproject-nix/uv2nix";
13+
inputs.pyproject-nix.follows = "pyproject-nix";
14+
inputs.nixpkgs.follows = "nixpkgs";
15+
};
16+
17+
inputs.pyproject-build-systems = {
18+
url = "github:pyproject-nix/build-system-pkgs";
19+
inputs.pyproject-nix.follows = "pyproject-nix";
20+
inputs.uv2nix.follows = "uv2nix";
21+
inputs.nixpkgs.follows = "nixpkgs";
22+
};
23+
624
# ( printf "~20024642E00202FD33\r"; sleep 1 ) | nc 192.168.10.237 23
7-
outputs = { self, nixpkgs, flake-utils }:
25+
outputs =
26+
{ self
27+
, nixpkgs
28+
, flake-utils
29+
, uv2nix
30+
, pyproject-nix
31+
, pyproject-build-systems
32+
, ...
33+
}:
834
flake-utils.lib.eachDefaultSystem
935
(system:
10-
let
11-
pkgs = import nixpkgs {
12-
inherit system;
13-
config.allowUnfree = true;
14-
};
15-
in
16-
{
17-
devShells.default = pkgs.mkShell {
18-
nativeBuildInputs = with pkgs.buildPackages; [
19-
git
20-
socat
21-
poetry
22-
23-
(python313.withPackages (python-pkgs: [
24-
python-pkgs.pyserial
25-
python-pkgs.construct
26-
python-pkgs.standard-telnetlib
27-
python-pkgs.rich
28-
]))
29-
];
30-
};
31-
}
36+
let
37+
pkgs = import nixpkgs {
38+
inherit system;
39+
config.allowUnfree = true;
40+
};
41+
lib = pkgs.lib;
42+
workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };
43+
44+
overlay = workspace.mkPyprojectOverlay {
45+
sourcePreference = "wheel"; # or sourcePreference = "sdist";
46+
};
47+
48+
pyprojectOverrides = _final: _prev: {
49+
};
50+
51+
python = pkgs.python313;
52+
53+
pythonSet =
54+
(pkgs.callPackage pyproject-nix.build.packages {
55+
inherit python;
56+
}).overrideScope
57+
(
58+
lib.composeManyExtensions [
59+
pyproject-build-systems.overlays.default
60+
overlay
61+
pyprojectOverrides
62+
]
63+
);
64+
in
65+
{
66+
devShells.default = pkgs.mkShell {
67+
nativeBuildInputs = with pkgs.buildPackages; [
68+
git
69+
socat
70+
uv
71+
72+
(python313.withPackages (python-pkgs: [
73+
python-pkgs.pyserial
74+
python-pkgs.construct
75+
python-pkgs.standard-telnetlib
76+
python-pkgs.rich
77+
]))
78+
];
79+
};
80+
81+
packages.default = pythonSet.mkVirtualEnv "pylontechpoller-env" workspace.deps.default;
82+
83+
apps.default = {
84+
type = "app";
85+
program = "${self.packages."${system}".default}/bin/poller";
86+
};
87+
}
3288
);
89+
90+
3391
}

0 commit comments

Comments
 (0)