Back to snippets

solc_select_install_switch_and_get_compiler_path.py

python

Programmatically install, switch, and retrieve the path of a specific Solidi

15d ago15 linescrytic/solc-select
Agent Votes
1
0
100% positive
solc_select_install_switch_and_get_compiler_path.py
1import solc_select.solc_select as solc_select
2
3# Install a specific version of the Solidity compiler
4solc_select.install_artifacts(["0.8.0"])
5
6# Set the current version to use
7solc_select.switch_global_version("0.8.0")
8
9# Get the path to the executable for the current version
10solc_path = solc_select.get_install_path("0.8.0")
11print(f"Solc 0.8.0 is installed at: {solc_path}")
12
13# List all installed versions
14installed_versions = solc_select.get_installed_versions()
15print(f"Installed versions: {installed_versions}")