CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-py-solc

Python wrapper around the solc Solidity compiler

Pending
Overview
Eval results
Files

installation.mddocs/

Solc Installation

Experimental functionality for installing specific versions of the solc compiler binary across different platforms. This feature allows you to manage multiple solc versions and ensures consistent compilation environments.

Capabilities

Install Solc Binary

Installs a specified version of the solc compiler binary for the current or specified platform.

def install_solc(identifier, platform=None):
    """
    Install specified version of solc compiler.

    Args:
        identifier (str): Version identifier (e.g., 'v0.4.24', 'v0.4.1')
        platform (str): Target platform ('linux', 'darwin', 'win32'). 
                       If None, auto-detected from current system

    Returns:
        None: Installation is performed, binary installed to ~/.py-solc/

    Raises:
        ValueError: When identifier or platform is invalid
        OSError: When installation fails due to system issues

    Note:
        This is experimental functionality. Installed binary location:
        $HOME/.py-solc/solc-{version}/bin/solc
        
        For older Linux installs, may require setting:
        LD_LIBRARY_PATH=$HOME/.py-solc/solc-{version}/bin
    """

Supported Versions and Platforms

Version Constants

# Available version identifiers
V0_4_1 = 'v0.4.1'
V0_4_2 = 'v0.4.2'
V0_4_6 = 'v0.4.6'
V0_4_7 = 'v0.4.7'
V0_4_8 = 'v0.4.8'
V0_4_9 = 'v0.4.9'
V0_4_11 = 'v0.4.11'
V0_4_12 = 'v0.4.12'
V0_4_13 = 'v0.4.13'
V0_4_14 = 'v0.4.14'
V0_4_15 = 'v0.4.15'
V0_4_16 = 'v0.4.16'
V0_4_17 = 'v0.4.17'
V0_4_18 = 'v0.4.18'
V0_4_19 = 'v0.4.19'
V0_4_20 = 'v0.4.20'
V0_4_21 = 'v0.4.21'
V0_4_22 = 'v0.4.22'
V0_4_23 = 'v0.4.23'
V0_4_24 = 'v0.4.24'

Platform Constants

LINUX = 'linux'
OSX = 'darwin'
WINDOWS = 'win32'

Supported Version/Platform Matrix

VersionLinuxmacOS (OSX)Windows
v0.4.1
v0.4.2
v0.4.6
v0.4.7
v0.4.8
v0.4.9
v0.4.11+

Note: Windows support is not available through this installation system.

Usage Examples

Basic Installation

from solc import install_solc

# Install latest supported version
install_solc('v0.4.24')

# Install specific version
install_solc('v0.4.11')

Install for Specific Platform

from solc import install_solc, LINUX, OSX

# Install for Linux (useful when cross-compiling)
install_solc('v0.4.24', platform=LINUX)

# Install for macOS
install_solc('v0.4.24', platform=OSX)

Using Version Constants

from solc import install_solc, V0_4_24, V0_4_11

# Using constants for type safety
install_solc(V0_4_24)
install_solc(V0_4_11)

Command Line Installation

You can also install solc versions from the command line:

# Install using Python module
python -m solc.install v0.4.24

# Or using the main module
python -m solc.install v0.4.11

Error Handling

from solc import install_solc

try:
    install_solc('v0.5.0')  # Unsupported version
except ValueError as e:
    print(f"Installation failed: {e}")
    
try:
    install_solc('v0.4.24', platform='unsupported_platform')
except ValueError as e:
    print(f"Unsupported platform: {e}")
    
try:
    install_solc('v0.4.24')
except OSError as e:
    print(f"System error during installation: {e}")

Installation Process

Linux Installation Methods

Static Binary (v0.4.11+):

  • Downloads pre-compiled static binary from GitHub releases
  • No dependencies required
  • Fastest installation method

Ubuntu Release Package (v0.4.1-v0.4.9):

  • Downloads and extracts Ubuntu release zip
  • May require additional system libraries
  • Requires LD_LIBRARY_PATH environment variable

macOS Installation Method

Source Compilation:

  • Clones Solidity repository from GitHub
  • Compiles from source using cmake and make
  • Requires development tools (Xcode Command Line Tools)
  • Takes longer but ensures compatibility

Post-Installation Configuration

Binary Location

Installed binaries are located at:

$HOME/.py-solc/solc-{version}/bin/solc

Environment Variables

For older Linux installations, you may need to set:

export LD_LIBRARY_PATH=$HOME/.py-solc/solc-v0.4.24/bin:$LD_LIBRARY_PATH

Using Installed Binary

import os
from solc import compile_source

# Set environment variable to use specific installed version
os.environ['SOLC_BINARY'] = os.path.expanduser('~/.py-solc/solc-v0.4.24/bin/solc')

# Now compilation will use the installed version
result = compile_source(source_code)

Verification

After installation, verify the binary works:

from solc import get_solc_version_string
import os

# Point to installed binary
os.environ['SOLC_BINARY'] = os.path.expanduser('~/.py-solc/solc-v0.4.24/bin/solc')

# Check version
version = get_solc_version_string()
print(f"Installed solc version: {version}")

System Requirements

Linux Requirements

  • wget (for downloading releases)
  • git (for source compilation on older versions)
  • Basic system libraries (glibc, etc.)

macOS Requirements

  • Xcode Command Line Tools (xcode-select --install)
  • git (usually included with Command Line Tools)
  • cmake and make (for source compilation)

Disk Space

  • Static binary installations: ~10-20 MB per version
  • Source compilations: ~100-200 MB per version (includes source and build artifacts)

Troubleshooting

Common Issues

Permission Denied:

chmod +x ~/.py-solc/solc-v0.4.24/bin/solc

Library Path Issues (Linux):

export LD_LIBRARY_PATH=~/.py-solc/solc-v0.4.24/bin:$LD_LIBRARY_PATH

Missing Dependencies (macOS):

xcode-select --install
brew install cmake  # if using Homebrew

Manual Verification

Test installed binary manually:

~/.py-solc/solc-v0.4.24/bin/solc --version

Cleanup

Remove installed versions:

rm -rf ~/.py-solc/solc-v0.4.24/

Install with Tessl CLI

npx tessl i tessl/pypi-py-solc

docs

exceptions.md

index.md

installation.md

legacy-compilation.md

standard-json-compilation.md

tile.json