Skip to content

Commit 9d67e52

Browse files
committed
feat: replace poetry with uv in Makefiles
Extract package versions from pyproject.toml directly instead of using poetry commands. Use `uv run` to execute flake8, pytest and other Python tools consistently.
1 parent c18dd8a commit 9d67e52

File tree

8 files changed

+35
-102
lines changed

8 files changed

+35
-102
lines changed

Makefile

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -477,11 +477,11 @@ check: check-units installcheck pytest
477477

478478
pytest: $(ALL_PROGRAMS) $(DEFAULT_TARGETS) $(ALL_TEST_PROGRAMS) $(ALL_TEST_GEN)
479479
ifeq ($(PYTEST),)
480-
@echo "py.test is required to run the integration tests, please install using 'pip3 install -r requirements.txt', and rerun 'configure'."
480+
@echo "pytest is required to run the integration tests, please install using 'uv sync --all-extras --all-groups', and rerun 'configure'."
481481
exit 1
482482
else
483483
# Explicitly hand VALGRIND so you can override on make cmd line.
484-
PYTHONPATH=$(MY_CHECK_PYTHONPATH) TEST_DEBUG=1 VALGRIND=$(VALGRIND) $(PYTEST) $(PYTEST_TESTS) $(PYTEST_OPTS)
484+
PYTHONPATH=$(MY_CHECK_PYTHONPATH) TEST_DEBUG=1 VALGRIND=$(VALGRIND) uv run $(PYTEST) $(PYTEST_TESTS) $(PYTEST_OPTS)
485485
endif
486486

487487
check-fuzz: $(ALL_FUZZ_TARGETS)
@@ -542,7 +542,7 @@ PYSRC=$(shell git ls-files "*.py" | grep -v /text.py)
542542
# allows it to find that
543543
PYLN_PATH=$(shell pwd)/lightningd:$(PATH)
544544
check-pyln-%: $(BIN_PROGRAMS) $(PKGLIBEXEC_PROGRAMS) $(PLUGINS)
545-
@(cd contrib/$(shell echo $@ | cut -b 7-) && PATH=$(PYLN_PATH) PYTHONPATH=$(MY_CHECK_PYTHONPATH) $(MAKE) check)
545+
@(cd contrib/$(shell echo $@ | cut -b 7-) && PATH=$(PYLN_PATH) PYTHONPATH=$(MY_CHECK_PYTHONPATH) uv run $(MAKE) check)
546546

547547
check-python: check-python-flake8 check-pytest-pyln-proto check-pyln-client check-pyln-testing
548548

@@ -551,10 +551,10 @@ check-python-flake8:
551551
@# E731 do not assign a lambda expression, use a def
552552
@# W503: line break before binary operator
553553
@# E741: ambiguous variable name
554-
@flake8 --ignore=E501,E731,E741,W503,F541,E275 --exclude $(shell echo ${PYTHON_GENERATED} | sed 's/ \+/,/g') ${PYSRC}
554+
@uv run flake8 --ignore=E501,E731,E741,W503,F541,E275 --exclude $(shell echo ${PYTHON_GENERATED} | sed 's/ \+/,/g') ${PYSRC}
555555

556556
check-pytest-pyln-proto:
557-
PATH=$(PYLN_PATH) PYTHONPATH=$(MY_CHECK_PYTHONPATH) $(PYTEST) contrib/pyln-proto/tests/
557+
PATH=$(PYLN_PATH) PYTHONPATH=$(MY_CHECK_PYTHONPATH) uv run $(PYTEST) contrib/pyln-proto/tests/
558558

559559
check-includes: check-src-includes check-hdr-includes
560560
@tools/check-includes.sh
@@ -745,29 +745,19 @@ clean: obsclean
745745
find . -name '*gcno' -delete
746746
find . -name '*.nccout' -delete
747747
if [ "${RUST}" -eq "1" ]; then cargo clean; fi
748+
rm -rf .venv
748749

749750

750751
PYLNS=client proto testing
751752
# See doc/contribute-to-core-lightning/contributor-workflow.md
752-
update-versions: update-pyln-versions update-wss-proxy-version update-poetry-lock update-dot-version update-doc-examples
753-
754-
update-pyln-versions: $(PYLNS:%=update-pyln-version-%)
755-
756-
update-pyln-version-%:
757-
@if [ -z "$(NEW_VERSION)" ]; then echo "Set NEW_VERSION!" >&2; exit 1; fi
758-
cd contrib/pyln-$* && $(MAKE) upgrade-version
759753

760754
pyln-release: $(PYLNS:%=pyln-release-%)
761755

762756
pyln-release-%:
763757
cd contrib/pyln-$* && $(MAKE) prod-release
764758

765-
update-wss-proxy-version:
766-
@if [ -z "$(NEW_VERSION)" ]; then echo "Set NEW_VERSION!" >&2; exit 1; fi
767-
cd plugins/wss-proxy && $(MAKE) upgrade-version
768-
769-
update-poetry-lock:
770-
poetry update wss-proxy pyln-client pyln-proto pyln-testing update-reckless-version
759+
update-lock:
760+
uv sync --all-extras --all-groups
771761

772762
update-reckless-version:
773763
@if [ -z "$(NEW_VERSION)" ]; then echo "Set NEW_VERSION!" >&2; exit 1; fi

contrib/pyln-client/Makefile

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/make
22

33
PKG=client
4-
VERSION := $(shell poetry version -s)
4+
VERSION := $(shell grep 'version' pyproject.toml | head -n1 | cut -d'"' -f2)
55

66
# You can set these variables from the command line.
77
SPHINXOPTS =
@@ -17,31 +17,20 @@ check: check-source check-pytest
1717

1818
check-source: check-flake8 check-mypy check-version
1919

20-
# We want to create an env for this directory.
2120
check-version:
22-
poetry env remove -q python3 || true
23-
poetry env use python3
24-
poetry install
25-
[ "`poetry run python3 -c 'from pyln import $(PKG); print($(PKG).__version__)'`" = "$(VERSION)" ] || exit 1
21+
[ "`uv run python3 -c 'from pyln import $(PKG); print($(PKG).__version__)'`" = "$(VERSION)" ] || exit 1
2622

2723
check-flake8:
28-
flake8 --ignore=E501,E731,W503,E741 pyln tests
24+
uv run flake8 --ignore=E501,E731,W503,E741 pyln tests
2925

3026
check-pytest:
31-
pytest tests
27+
uv run pytest tests
3228

3329
check-mypy:
3430
# MYPYPATH=$(PYTHONPATH) mypy --namespace-packages --follow-imports=skip tests pyln
3531

36-
# Having versions in two places sucks, but so does every other option :(
37-
# See https://github.com/python-poetry/poetry/issues/144
38-
upgrade-version:
39-
if [ -z "$(NEW_VERSION)" ]; then echo "Set NEW_VERSION!" >&2; exit 1; fi
40-
poetry version $(NEW_VERSION)
41-
sed 's/^__version__ = .*/__version__ = "$(NEW_VERSION)"/' < pyln/$(PKG)/__init__.py > pyln/$(PKG)/__init__.py.new && mv pyln/$(PKG)/__init__.py.new pyln/$(PKG)/__init__.py
42-
4332
$(SDIST_FILE) $(BDIST_FILE):
44-
poetry build
33+
uv build
4534

4635
prod-release: check-version $(ARTEFACTS)
47-
poetry publish
36+
uv publish

contrib/pyln-grpc-proto/Makefile

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.PHONY: clean protos
33

44
PKG=grpc
5-
VERSION := $(shell poetry version -s)
5+
VERSION := $(shell grep 'version' pyproject.toml | head -n1 | cut -d'"' -f2)
66

77
PROTOS = \
88
pyln/grpc/node_pb2.py \
@@ -16,7 +16,7 @@ PROTOSRC = \
1616
../../cln-grpc/proto/primitives.proto
1717

1818
${PROTOS} &: ${PROTOSRC}
19-
python \
19+
uv run \
2020
-m grpc_tools.protoc \
2121
-I ../../cln-grpc/proto \
2222
../../cln-grpc/proto/node.proto \
@@ -40,13 +40,6 @@ ${PROTOS} &: ${PROTOSRC}
4040
sed -i 's/import primitives_pb2/from pyln.grpc import primitives_pb2/g' pyln/grpc/node_pb2.pyi
4141
sed -i 's/import node_pb2 as node__pb2/from pyln.grpc import node_pb2 as node__pb2/g' pyln/grpc/node_pb2_grpc.py
4242

43-
# Having versions in two places sucks, but so does every other option :(
44-
# See https://github.com/python-poetry/poetry/issues/144
45-
upgrade-version:
46-
if [ -z "$(NEW_VERSION)" ]; then echo "Set NEW_VERSION!" >&2; exit 1; fi
47-
poetry version $(NEW_VERSION)
48-
sed 's/^__version__ = .*/__version__ = "$(NEW_VERSION)"/' < pyln/$(PKG)/__init__.py > pyln/$(PKG)/__init__.py.new && mv pyln/$(PKG)/__init__.py.new pyln/$(PKG)/__init__.py
49-
5043
protos: ${PROTOS}
5144

5245
clean:

contrib/pyln-proto/Makefile

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/make
22

33
PKG=proto
4-
VERSION := $(shell poetry version -s)
4+
VERSION := $(shell grep 'version' pyproject.toml | head -n1 | cut -d'"' -f2)
55

66
# You can set these variables from the command line.
77
SPHINXOPTS =
@@ -19,32 +19,19 @@ check-source: check-flake8 check-mypy check-version
1919

2020
# We want to create an env for this directory.
2121
check-version:
22-
poetry env remove -q python3 || true
23-
poetry env use python3
24-
poetry install
25-
[ "`poetry run python3 -c 'from pyln import $(PKG); print($(PKG).__version__)'`" = "$(VERSION)" ] || exit 1
22+
[ "`uv run python3 -c 'from pyln import $(PKG); print($(PKG).__version__)'`" = "$(VERSION)" ] || exit 1
2623

2724
check-flake8:
28-
flake8 --ignore=E501,E731,W503,E741 pyln tests
25+
uv run flake8 --ignore=E501,E731,W503,E741 pyln tests
2926

3027
check-pytest:
31-
pytest tests
28+
uv run pytest tests
3229

3330
check-mypy:
3431
# MYPYPATH=$(PYTHONPATH) mypy --namespace-packages --follow-imports=skip tests pyln
3532

36-
pyproject.toml: pyln/${PKG}/__init__.py
37-
poetry version ${VERSION}
38-
39-
# Having versions in two places sucks, but so does every other option :(
40-
# See https://github.com/python-poetry/poetry/issues/144
41-
upgrade-version:
42-
if [ -z "$(NEW_VERSION)" ]; then echo "Set NEW_VERSION!" >&2; exit 1; fi
43-
poetry version $(NEW_VERSION)
44-
sed 's/^__version__ = .*/__version__ = "$(NEW_VERSION)"/' < pyln/$(PKG)/__init__.py > pyln/$(PKG)/__init__.py.new && mv pyln/$(PKG)/__init__.py.new pyln/$(PKG)/__init__.py
45-
4633
$(SDIST_FILE) $(BDIST_FILE):
47-
poetry build
34+
uv build
4835

4936
prod-release: check-version $(ARTEFACTS)
50-
poetry publish
37+
uv publish

contrib/pyln-testing/Makefile

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/make
22

33
PKG=testing
4-
VERSION := $(shell poetry version -s)
4+
VERSION := $(shell grep 'version' pyproject.toml | head -n1 | cut -d'"' -f2)
55

66
# You can set these variables from the command line.
77
SPHINXOPTS =
@@ -19,29 +19,19 @@ check-source: check-flake8 check-mypy check-version
1919

2020
# We want to create an env for this directory.
2121
check-version:
22-
poetry env remove -q python3 || true
23-
poetry env use python3
24-
poetry install
25-
[ "`poetry run python3 -c 'from pyln import $(PKG); print($(PKG).__version__)'`" = "$(VERSION)" ] || exit 1
22+
[ "`uv run python3 -c 'from pyln import $(PKG); print($(PKG).__version__)'`" = "$(VERSION)" ] || exit 1
2623

2724
check-flake8:
28-
flake8 --ignore=E501,E731,W503,E741 --exclude '*_pb2*.py,grpc2py.py' pyln tests
25+
uv run flake8 --ignore=E501,E731,W503,E741 --exclude '*_pb2*.py,grpc2py.py' pyln tests
2926

3027
check-pytest:
31-
pytest tests
28+
uv run pytest tests
3229

3330
check-mypy:
3431
# MYPYPATH=$(PYTHONPATH) mypy --namespace-packages --follow-imports=skip tests pyln
3532

36-
# Having versions in two places sucks, but so does every other option :(
37-
# See https://github.com/python-poetry/poetry/issues/144
38-
upgrade-version:
39-
if [ -z "$(NEW_VERSION)" ]; then echo "Set NEW_VERSION!" >&2; exit 1; fi
40-
poetry version $(NEW_VERSION)
41-
sed 's/^__version__ = .*/__version__ = "$(NEW_VERSION)"/' < pyln/$(PKG)/__init__.py > pyln/$(PKG)/__init__.py.new && mv pyln/$(PKG)/__init__.py.new pyln/$(PKG)/__init__.py
42-
4333
$(SDIST_FILE) $(BDIST_FILE):
44-
poetry build
34+
uv build
4535

4636
prod-release: check-version $(ARTEFACTS)
47-
poetry publish
37+
uv publish

doc/developers-guide/app-development/grpc.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,10 @@ The gRPC interface is described in the [protobuf file](https://github.com/Elemen
3535

3636
In this tutorial, we walk through the steps for Python, however they are mostly the same for other languages. For instance, if you're developing in Rust, use [`tonic-build`](https://docs.rs/tonic-build/latest/tonic_build/) to generate the bindings. For other languages, see the official [gRPC docs](https://grpc.io/docs/languages/) on how to generate gRPC client library for your specific language using the protobuf file.
3737

38-
We start by downloading the dependencies and `protoc` compiler:
39-
40-
```shell
41-
pip install grpcio-tools
42-
```
43-
44-
45-
46-
Next we generate the bindings in the current directory:
38+
We generate the bindings in the current directory:
4739

4840
```bash
49-
python -m grpc_tools.protoc \
41+
uv run -m grpc_tools.protoc \
5042
-I path/to/cln-grpc/proto \
5143
path/to/cln-grpc/proto/node.proto \
5244
--python_out=. \

plugins/grpc-plugin/README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if they don't already exist:
2323
- `client.pem` and `client-key.pem`: this is an example identity that
2424
can be used by a client to connect to the plugin, and issue
2525
requests. It is also signed by the CA.
26-
26+
2727
These files are generated with sane defaults, however you can generate
2828
custom certificates should you require some changes (see below for
2929
details).
@@ -39,16 +39,10 @@ bindings.
3939
In this example we walk through the steps for python, however they are
4040
mostly the same for other languages.
4141

42-
We start by downloading the dependencies and `protoc` compiler:
43-
44-
```bash
45-
pip install grpcio-tools
46-
```
47-
48-
Next we generate the bindings in the current directory:
42+
We generate the bindings in the current directory:
4943

5044
```bash
51-
python -m grpc_tools.protoc \
45+
uv run -m grpc_tools.protoc \
5246
-I path/to/cln-grpc/proto \
5347
path/to/cln-grpc/proto/node.proto \
5448
--python_out=. \
@@ -62,7 +56,7 @@ This will generate two files in the current directory:
6256
exchanging with the server.
6357
- `node_pb2_grpc.py`: the service and method stubs representing the
6458
server-side methods as local objects and associated methods.
65-
59+
6660
And finally we can use the generated stubs and mTLS identity to
6761
connect to the node:
6862

plugins/wss-proxy/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
upgrade-version:
2-
if [ -z "$(NEW_VERSION)" ]; then echo "Set NEW_VERSION!" >&2; exit 1; fi
3-
poetry version $(NEW_VERSION)
1+

0 commit comments

Comments
 (0)