Skip to content

Commit ad60cd3

Browse files
committed
Ensure that non-C cbor2 still works
1 parent 8b01cdc commit ad60cd3

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ jobs:
6565
uses: astral-sh/setup-uv@v6
6666

6767
- name: Install project
68-
run: uv sync --dev
68+
run: |
69+
uv sync --dev
70+
uv run python -c "from importlib.metadata import version; print(version('cbor2'))" > .cbor2_version
71+
CBOR2_VERSION=$(cat .cbor2_version)
72+
CBOR2_BUILD_C_EXTENSION=0 uv pip install --no-binary cbor2 "cbor2==$CBOR2_VERSION" --force-reinstall
6973
7074
- name: Install secp256k1-py
7175
run: uv pip install python-secp256k1-cardano

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ test.uplc
33
venv
44
.vscode
55
.DS_Store
6+
.cbor2_version
67
# Created by https://www.toptal.com/developers/gitignore/api/python,pycharm+all
78
# Edit at https://www.toptal.com/developers/gitignore?templates=python,pycharm+all
89

uplc/ast.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import functools
44
import json
55
import logging
6-
import math
76
import sys
87
import typing
98
from collections import defaultdict
@@ -19,7 +18,6 @@
1918
from bitstring import BitArray
2019
from frozenlist2 import frozenlist
2120
import nacl.exceptions
22-
from _cbor2 import CBOREncoder
2321
from pycardano.crypto.bip32 import BIP32ED25519PublicKey
2422
from pycardano.serialization import IndefiniteFrozenList, IndefiniteList
2523
from Crypto.Hash import keccak
@@ -629,7 +627,9 @@ def _int_to_bytes(x: int):
629627
return x.to_bytes((x.bit_length() + 7) // 8, byteorder="big")
630628

631629

632-
def default_encoder(encoder: CBOREncoder, value: Union[PlutusData, IndefiniteList]):
630+
def default_encoder(
631+
encoder: cbor2.CBOREncoder, value: Union[PlutusData, IndefiniteList]
632+
):
633633
"""A fallback function that encodes PlutusData objects"""
634634
if isinstance(value, IndefiniteList):
635635
# Currently, cbor2 doesn't support indefinite list, therefore we need special

0 commit comments

Comments
 (0)