Skip to content

Commit 5f4dba4

Browse files
committed
Add the 'all' keyword for 'erdpy deps install' and add github token support
1 parent 1e04c09 commit 5f4dba4

6 files changed

Lines changed: 30 additions & 10 deletions

File tree

erdpy/cli_deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def setup_parser(subparsers: Any) -> Any:
1111
parser = cli_shared.add_group_subparser(subparsers, "deps", "Manage dependencies or elrond-sdk modules")
1212
subparsers = parser.add_subparsers()
1313

14-
choices = list(get_deps_dict().keys())
14+
choices = ['all'] + list(get_deps_dict().keys())
1515

1616
sub = cli_shared.add_command_subparser(subparsers, "deps", "install", "Install dependencies or elrond-sdk modules.")
1717
sub.add_argument("name", choices=choices, help="the dependency to install")

erdpy/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def get_defaults() -> Dict[str, Any]:
173173
"dependencies.mcl_signer.urlTemplate.linux": "https://github.com/ElrondNetwork/elrond-sdk-go-tools/releases/download/{TAG}/mcl_signer_{TAG}_ubuntu-latest.tar.gz",
174174
"dependencies.mcl_signer.urlTemplate.osx": "https://github.com/ElrondNetwork/elrond-sdk-go-tools/releases/download/{TAG}/mcl_signer_{TAG}_macos-latest.tar.gz",
175175
"testnet.validate_expected_keys": "false",
176+
"github_api_token": "",
176177
}
177178

178179

erdpy/dependencies/install.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111

1212

1313
def install_module(key: str, tag: str = "", overwrite: bool = False):
14-
module = get_module_by_key(key)
15-
module.install(tag, overwrite)
14+
if key == 'all':
15+
modules = get_all_deps()
16+
else:
17+
modules = [get_module_by_key(key)]
18+
for module in modules:
19+
module.install(tag, overwrite)
1620

1721

1822
def get_module_directory(key: str) -> Path:

erdpy/dependencies/modules.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ def get_source_directory(self, tag: str):
109109
# path will contain the tag in two variants: with the 'v' prefix (e.g.
110110
# "v1.1.0"), but also without (e.g. "1.1.0"), hence the need to remove
111111
# the initial 'v'.
112-
if tag.startswith("v"):
113-
tag = tag[1:]
112+
tag_no_v = tag
113+
if tag_no_v.startswith("v"):
114+
tag_no_v = tag_no_v[1:]
114115
assert isinstance(self.repo_name, str)
115-
source_folder = self.get_directory(tag) / (self.repo_name + '-' + tag)
116+
source_folder = self.get_directory(tag) / (self.repo_name + '-' + tag_no_v)
116117
return source_folder
117118

118119
def get_parent_directory(self) -> Path:
@@ -159,6 +160,7 @@ def _post_install(self, tag: str):
159160

160161
self.make_binary_symlink_in_parent_folder(tag, 'arwendebug', 'arwendebug')
161162
self.make_binary_symlink_in_parent_folder(tag, 'test', 'mandos-test')
163+
self.copy_libwasmer_in_parent_directory(tag)
162164

163165
def build_binary(self, tag, binary_name):
164166
source_folder = self.binary_source_folder(tag, binary_name)
@@ -174,12 +176,19 @@ def make_binary_symlink_in_parent_folder(self, tag, binary_name, symlink_name):
174176
source_folder = self.binary_source_folder(tag, binary_name)
175177
binary = source_folder / binary_name
176178

177-
parent = Path(self.get_parent_directory())
179+
parent = self.get_parent_directory()
178180
symlink = parent / symlink_name
179181

180182
symlink.unlink(missing_ok=True)
181183
symlink.symlink_to(binary)
182184

185+
def copy_libwasmer_in_parent_directory(self, tag):
186+
libwasmer_directory = self.get_source_directory(tag) / 'wasmer'
187+
parent_directory = self.get_parent_directory()
188+
for f in libwasmer_directory.iterdir():
189+
if f.suffix in ['.dylib', '.so', '.dll']:
190+
shutil.copy(f, parent_directory)
191+
183192
def get_env(self):
184193
return {
185194
}

erdpy/scope.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ def initialize():
1919
if os.path.exists(testnet_toml):
2020
global chain_id, proxy
2121

22-
testnet_config = TestnetConfiguration.from_file(testnet_toml)
2322
chain_id = CHAIN_ID
24-
proxy = f"http://localhost:{testnet_config.proxy_port()}"
23+
24+
try:
25+
testnet_config = TestnetConfiguration.from_file(testnet_toml)
26+
proxy = f"http://localhost:{testnet_config.proxy_port()}"
27+
except FileNotFoundError:
28+
logger.warn("components of the testnet may be missing")
2529

2630

2731
def get_chain_id():

erdpy/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import toml
1616

17+
import erdpy.config
1718
from erdpy import errors
1819

1920
logger = logging.getLogger("utils")
@@ -232,7 +233,8 @@ def query_latest_release_tag(repo: str) -> str:
232233
repository. The repository must be of the form 'organisation/project'.
233234
"""
234235
url = f'https://api.github.com/repos/{repo}/releases/latest'
235-
response = requests.get(url)
236+
github_api_token = erdpy.config.get_value('github_api_token')
237+
response = requests.get(url, auth=github_api_token)
236238
response.raise_for_status()
237239
latest_release_tag = str(response.json()['tag_name'])
238240
return latest_release_tag

0 commit comments

Comments
 (0)