@@ -18,6 +18,7 @@ ALL_EXECUTABLE_SPEC_NAMES = \
1818
1919# A list of fake targets.
2020.PHONY : \
21+ _sync \
2122 clean \
2223 coverage \
2324 help \
@@ -173,7 +174,7 @@ help-verbose:
173174 @echo " $( BOLD) make clean$( NORM) "
174175 @echo " "
175176 @echo " Removes all untracked files. This includes:"
176- @echo " - Virtual environment (venv/)"
177+ @echo " - Virtual environment (. venv/)"
177178 @echo " - Build artifacts"
178179 @echo " - Cache files"
179180 @echo " "
@@ -187,19 +188,18 @@ help-verbose:
187188# Virtual Environment
188189# ##############################################################################
189190
190- VENV = venv
191- PYTHON_VENV = $(VENV ) /bin/python3
192- PIP_VENV = $(VENV ) /bin/pip3
193- CODESPELL_VENV = $(VENV ) /bin/codespell
194- MDFORMAT_VENV = $(VENV ) /bin/mdformat
195- MKDOCS_VENV = $(VENV ) /bin/mkdocs
191+ VENV = .venv
192+ UV_RUN = uv run
196193
197- # Make a virtual environment.
198- $(VENV ) :
199- @python3 scripts/check_python_version.py
200- @echo " Creating virtual environment"
201- @python3 -m venv $(VENV )
202- @$(PIP_VENV ) install --quiet --upgrade uv
194+ # Sync dependencies using uv.
195+ _sync : MAYBE_VERBOSE := $(if $(filter true,$(verbose ) ) ,--verbose)
196+ _sync : pyproject.toml
197+ @command -v uv > /dev/null 2>&1 || { \
198+ echo " Error: uv is required but not installed." ; \
199+ echo " Install with: curl -LsSf https://astral.sh/uv/install.sh | sh" ; \
200+ exit 1; \
201+ }
202+ @uv sync --all-extras $(MAYBE_VERBOSE )
203203
204204# ##############################################################################
205205# Specification
@@ -210,14 +210,8 @@ PYSPEC_DIR = $(TEST_LIBS_DIR)/pyspec
210210
211211# Create the pyspec for all phases.
212212_pyspec : MAYBE_VERBOSE := $(if $(filter true,$(verbose ) ) ,--verbose)
213- _pyspec : $(VENV ) setup.py pyproject.toml
214- @python3 scripts/check_python_version.py
215- @$(PYTHON_VENV ) -m uv pip install $(MAYBE_VERBOSE ) --reinstall-package=eth2spec .[docs,lint,test,generator]
216- @for dir in $(ALL_EXECUTABLE_SPEC_NAMES ) ; do \
217- mkdir -p " ./tests/core/pyspec/eth2spec/$$ dir" ; \
218- cp " ./build/lib/eth2spec/$$ dir/mainnet.py" " ./tests/core/pyspec/eth2spec/$$ dir/mainnet.py" ; \
219- cp " ./build/lib/eth2spec/$$ dir/minimal.py" " ./tests/core/pyspec/eth2spec/$$ dir/minimal.py" ; \
220- done
213+ _pyspec : _sync
214+ @$(UV_RUN ) python -m pysetup.generate_specs --all-forks $(MAYBE_VERBOSE )
221215
222216# ##############################################################################
223217# Testing
@@ -237,7 +231,7 @@ test: MAYBE_ETH2SPEC := $(if $(filter fw,$(component)),,$(PYSPEC_DIR)/eth2spec)
237231test : MAYBE_INFRA := $(if $(filter pyspec,$(component ) ) ,,$(CURDIR ) /tests/infra)
238232test : _pyspec
239233 @mkdir -p $(TEST_REPORT_DIR )
240- @$(PYTHON_VENV ) -m pytest \
234+ @$(UV_RUN ) pytest \
241235 $(MAYBE_PARALLEL ) \
242236 --capture=no \
243237 $(MAYBE_TEST ) \
@@ -263,7 +257,7 @@ COVERAGE_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), --cov=eth2spec.$S.$(
263257_test_with_coverage : MAYBE_TEST := $(if $(k ) ,-k=$(k ) )
264258_test_with_coverage : MAYBE_FORK := $(if $(fork ) ,--fork=$(fork ) )
265259_test_with_coverage : _pyspec
266- @$(PYTHON_VENV ) -m pytest \
260+ @$(UV_RUN ) pytest \
267261 -n auto \
268262 $(MAYBE_TEST ) \
269263 $(MAYBE_FORK ) \
@@ -300,27 +294,25 @@ _copy_docs:
300294
301295# Start a local documentation server.
302296serve_docs : _pyspec _copy_docs
303- @$(MKDOCS_VENV ) build
304- @$(MKDOCS_VENV ) serve
297+ @$(UV_RUN ) mkdocs build
298+ @$(UV_RUN ) mkdocs serve
305299
306300# ##############################################################################
307301# Checks
308302# ##############################################################################
309303
310- MYPY_CONFIG = $(CURDIR ) /mypy.ini
311- PYLINT_CONFIG = $(CURDIR ) /pylint.ini
312-
313- PYLINT_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES ) , $(PYSPEC_DIR ) /eth2spec/$S)
314- MYPY_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES ) , -p eth2spec.$S)
315304MARKDOWN_FILES := $(shell find $(CURDIR ) -name '* .md')
305+ MYPY_PACKAGE_BASE := $(subst /,.,$(PYSPEC_DIR:$(CURDIR ) /%=% ) )
306+ MYPY_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES ) , -p $(MYPY_PACKAGE_BASE ) .eth2spec.$S)
316307
317308# Check for mistakes.
318309lint : _pyspec
319- @$(MDFORMAT_VENV ) --number --wrap=80 $(MARKDOWN_FILES )
320- @$(CODESPELL_VENV ) . --skip " ./.git,$( VENV) ,$( PYSPEC_DIR) /.mypy_cache" -I .codespell-whitelist
321- @$(PYTHON_VENV ) -m ruff check --fix --quiet $(CURDIR ) /tests $(CURDIR ) /pysetup $(CURDIR ) /setup.py
322- @$(PYTHON_VENV ) -m ruff format --quiet $(CURDIR ) /tests $(CURDIR ) /pysetup $(CURDIR ) /setup.py
323- @$(PYTHON_VENV ) -m mypy --config-file $(MYPY_CONFIG ) $(MYPY_SCOPE )
310+ @uv --quiet lock --check
311+ @$(UV_RUN ) mdformat --number --wrap=80 $(MARKDOWN_FILES )
312+ @$(UV_RUN ) codespell . --skip " ./.git,$( VENV) ,$( PYSPEC_DIR) /.mypy_cache" -I .codespell-whitelist
313+ @$(UV_RUN ) ruff check --fix --quiet $(CURDIR ) /tests $(CURDIR ) /pysetup $(CURDIR ) /setup.py
314+ @$(UV_RUN ) ruff format --quiet $(CURDIR ) /tests $(CURDIR ) /pysetup $(CURDIR ) /setup.py
315+ @$(UV_RUN ) mypy $(MYPY_SCOPE )
324316
325317# ##############################################################################
326318# Generators
@@ -338,7 +330,7 @@ reftests: MAYBE_TESTS := $(if $(k),--cases $(subst ${COMMA}, ,$(k)))
338330reftests : MAYBE_FORKS := $(if $(fork ) ,--forks $(subst ${COMMA}, ,$(fork ) ) )
339331reftests : MAYBE_PRESETS := $(if $(preset ) ,--presets $(subst ${COMMA}, ,$(preset ) ) )
340332reftests : _pyspec
341- @$(PYTHON_VENV ) -m tests.generators.main \
333+ @$(UV_RUN ) python -m tests.generators.main \
342334 --output $(TEST_VECTOR_DIR ) \
343335 $(MAYBE_VERBOSE ) \
344336 $(MAYBE_THREADS ) \
@@ -354,7 +346,7 @@ comptests: MAYBE_FORKS := $(if $(fork),--forks $(subst ${COMMA}, ,$(fork)))
354346comptests : MAYBE_PRESETS := $(if $(preset ) ,--presets $(subst ${COMMA}, ,$(preset ) ) )
355347comptests : MAYBE_SEED := $(if $(seed ) ,--fc-gen-seed $(seed ) )
356348comptests : _pyspec
357- @$(PYTHON_VENV ) -m tests.generators.compliance_runners.fork_choice.test_gen \
349+ @$(UV_RUN ) python -m tests.generators.compliance_runners.fork_choice.test_gen \
358350 --output $(COMP_TEST_VECTOR_DIR ) \
359351 --fc-gen-config $(FC_GEN_CONFIG ) \
360352 $(MAYBE_THREADS ) \
0 commit comments