@@ -23,10 +23,24 @@ export PRINT_HELP_PYSCRIPT
23
23
24
24
BROWSER := poetry run python -c "$$BROWSER_PYSCRIPT"
25
25
26
+ ensure-pure-cbor2 : # # ensures cbor2 is installed with pure Python implementation
27
+ @poetry run python -c " from importlib.metadata import version; \
28
+ print(version(' cbor2' ))" > .cbor2_version
29
+ @poetry run python -c " import cbor2, inspect; \
30
+ print(' Checking cbor2 implementation...' ); \
31
+ decoder_path = inspect.getfile(cbor2.CBORDecoder); \
32
+ using_c_ext = decoder_path.endswith(' .so' ); \
33
+ print(f' Implementation path: {decoder_path}' ); \
34
+ print(f' Using C extension: {using_c_ext}' ); \
35
+ exit(1 if using_c_ext else 0)" || \
36
+ (echo " Reinstalling cbor2 with pure Python implementation..." && \
37
+ poetry run pip install --no-binary cbor2 " cbor2==$$ (cat .cbor2_version)" --force-reinstall && \
38
+ rm .cbor2_version)
39
+
26
40
help :
27
41
@python -c " $$ PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST )
28
42
29
- cov : # # check code coverage
43
+ cov : ensure-pure-cbor2 # # check code coverage
30
44
poetry run pytest -n 4 --cov pycardano
31
45
32
46
cov-html : cov # # check code coverage and generate an html report
@@ -54,7 +68,7 @@ clean-test: ## remove test and coverage artifacts
54
68
rm -fr cov_html/
55
69
rm -fr .pytest_cache
56
70
57
- test : # # runs tests
71
+ test : ensure-pure-cbor2 # # runs tests
58
72
poetry run pytest -vv -n 4
59
73
60
74
test-integration : # # runs integration tests
@@ -63,7 +77,7 @@ test-integration: ## runs integration tests
63
77
test-single : # # runs tests with "single" markers
64
78
poetry run pytest -s -vv -m single
65
79
66
- qa : # # runs static analyses
80
+ qa : ensure-pure-cbor2 # # runs static analyses
67
81
poetry run flake8 pycardano
68
82
poetry run mypy --install-types --non-interactive pycardano
69
83
poetry run black --check .
@@ -78,6 +92,6 @@ docs: ## build the documentation
78
92
poetry run sphinx-build docs/source docs/build/html
79
93
$(BROWSER ) docs/build/html/index.html
80
94
81
- release : clean qa test format # # build dist version and release to pypi
95
+ release : clean qa test format ensure-pure-cbor2 # # build dist version and release to pypi
82
96
poetry build
83
97
poetry publish
0 commit comments