Skip to content

Commit 22ebd67

Browse files
committed
Update README
1 parent a1e3dda commit 22ebd67

File tree

2 files changed

+53
-9
lines changed

2 files changed

+53
-9
lines changed

README.md

+15-9
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ could be beneficial for faster R&D iterations.
4545
- [X] Reward withdraw
4646
- [X] Mnemonic
4747
- [X] HD Wallet
48+
- [x] Pool certificate
49+
- [x] Protocol proposal update
50+
- [x] Governance actions
4851
- [ ] Byron Address
49-
- [ ] Pool certificate
50-
- [ ] Protocol proposal update
5152

5253

5354
### Installation
@@ -56,17 +57,21 @@ Install the library using [pip](https://pip.pypa.io/en/stable/):
5657

5758
`pip install pycardano`
5859

59-
### Documentation
60+
#### Install cbor2 pure python implementation (Optional)
61+
[cbor2](https://github.com/agronholm/cbor2/tree/master) is a dependency of pycardano. It is used to encode and decode CBOR data.
62+
It has two implementations: one is pure Python and the other is C, which is installed by default. The C implementation is faster, but it is less flexible than the pure Python implementation.
6063

61-
https://pycardano.readthedocs.io/en/latest/
64+
For some users, the C implementation may not work properly when deserializing cbor data. For example, the order of inputs of a transaction isn't guaranteed to be the same as the order of inputs in the original transaction (details could be found in [this issue](https://github.com/Python-Cardano/pycardano/issues/311)). This would result in a different transaction hash when the transaction is serialized again. For users who encounter this issue, we recommend to use the pure Python implementation of cbor2. You can do so by running [ensure_pure_cbor2.sh](./ensure_pure_cbor2.sh), which inspect the cbor2 installed in the running environment and force install pure python implementation if necessary.
6265

63-
### Examples
66+
```bash
67+
ensure_pure_cbor2.sh
68+
```
6469

65-
#### Full stack DApp
70+
### Documentation
6671

67-
A full stack testnet DApp is hosted on replit: https://pycardano.cffls.repl.co/
72+
https://pycardano.readthedocs.io/en/latest/
6873

69-
To learn more details, go to the [DApp page](https://github.com/Python-Cardano/pycardano/tree/main/examples/full_stack).
74+
### Examples
7075

7176
#### Transaction creation and signing
7277

@@ -161,8 +166,9 @@ context.submit_tx(signed_tx)
161166
```
162167
</details>
163168

164-
See more usages under [examples](https://github.com/Python-Cardano/pycardano/tree/main/examples).
169+
See more usages under project [examples](https://github.com/Python-Cardano/pycardano/tree/main/examples).
165170

171+
There is also a collection of examples under [awesome-pycardano](https://github.com/B3nac/awesome-pycardano).
166172

167173
### Development
168174

ensure_pure_cbor2.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
# Script to ensure cbor2 is installed with pure Python implementation
3+
4+
set -e
5+
6+
# Check if poetry is available, otherwise use python directly
7+
if command -v poetry &> /dev/null; then
8+
PYTHON="poetry run python"
9+
else
10+
PYTHON="python"
11+
fi
12+
13+
echo "Checking cbor2 version..."
14+
$PYTHON -c "from importlib.metadata import version; print(version('cbor2'))" > .cbor2_version
15+
CBOR2_VERSION=$(cat .cbor2_version)
16+
echo "Found cbor2 version: $CBOR2_VERSION"
17+
18+
echo "Checking cbor2 implementation..."
19+
$PYTHON -c "
20+
import cbor2, inspect, sys
21+
decoder_path = inspect.getfile(cbor2.CBORDecoder)
22+
using_c_ext = decoder_path.endswith('.so')
23+
print(f'Implementation path: {decoder_path}')
24+
print(f'Using C extension: {using_c_ext}')
25+
sys.exit(1 if using_c_ext else 0)
26+
"
27+
28+
if [ $? -ne 0 ]; then
29+
echo "Reinstalling cbor2 with pure Python implementation..."
30+
$PYTHON -m pip uninstall -y cbor2
31+
CBOR2_BUILD_C_EXTENSION=0 $PYTHON -m pip install --no-binary cbor2 "cbor2==$CBOR2_VERSION" --force-reinstall
32+
echo "Successfully reinstalled cbor2 with pure Python implementation"
33+
else
34+
echo "Already using pure Python implementation of cbor2"
35+
fi
36+
37+
# Clean up
38+
rm -f .cbor2_version

0 commit comments

Comments
 (0)