Skip to content

Commit 8ed0b7f

Browse files
committed
Add MANIFEST file to install package data with lib
1 parent a30658a commit 8ed0b7f

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include celo_sdk/registry_contracts.json

celo_sdk/registry.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
from typing import List
3+
from pkg_resources import resource_filename
34

45

56
class Registry:
@@ -19,7 +20,7 @@ def load_all_contracts(self) -> List[dict]:
1920
Return addresses and ABIs of all the known contracts
2021
"""
2122
try:
22-
with open('celo_sdk/registry_contracts.json') as json_file:
23+
with open(resource_filename('celo_sdk', 'registry_contracts.json')) as json_file:
2324
contracts_data = json.load(json_file)
2425
result = []
2526
for k, v in contracts_data.items():
@@ -48,7 +49,7 @@ def load_contract_by_name(self, contract_name: str, contract_address: str = None
4849
try:
4950
account_contract_address = self.registry.functions.getAddressForString(
5051
contract_name).call() if contract_address == None else contract_address
51-
with open('celo_sdk/registry_contracts.json') as json_file:
52+
with open(resource_filename('celo_sdk', 'registry_contracts.json')) as json_file:
5253
contracts_data = json.load(json_file)
5354
return {"address": account_contract_address, "abi": contracts_data[contract_name]["ABI"]}
5455
except KeyError:
@@ -63,7 +64,7 @@ def set_registry(self):
6364
Set Registry contract object
6465
"""
6566
try:
66-
with open('celo_sdk/registry_contracts.json') as json_file:
67+
with open(resource_filename('celo_sdk', 'registry_contracts.json')) as json_file:
6768
contracts_data = json.load(json_file)
6869
registry = self.web3.eth.contract(
6970
contracts_data["Registry"]["Address"], abi=contracts_data["Registry"]["ABI"])

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
author="BlaizeTech",
1313
author_email="[email protected]",
1414
description="Celo Python SDK to work with smart contracts",
15-
data_files=[("registry_contracts", ["celo_sdk/registry_contracts.json"])],
15+
include_package_data=True,
1616
long_description=long_description,
1717
long_description_content_type="text/markdown",
1818
url="",

0 commit comments

Comments
 (0)