Metadata-Version: 2.1
Name: solcix
Version: 0.1.4
Summary: A Python wrapper for the Solidity compiler. Switch between versions, compile, and manage artifacts.
Author: alan890104
Author-email: alan890104@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: cfgv (==3.3.1)
Requires-Dist: click (==8.1.3)
Requires-Dist: colorama (>=0.4.6,<0.5.0)
Requires-Dist: distlib (==0.3.6)
Requires-Dist: filelock (==3.10.7)
Requires-Dist: identify (==2.5.22)
Requires-Dist: joblib (==1.2.0)
Requires-Dist: mypy-extensions (==1.0.0)
Requires-Dist: nodeenv (==1.7.0)
Requires-Dist: packaging (==23.0)
Requires-Dist: pathspec (==0.11.1)
Requires-Dist: platformdirs (==3.2.0)
Requires-Dist: pycryptodome (==3.17)
Requires-Dist: pyfiglet (>=0.8.post1,<0.9)
Requires-Dist: pytest-mock (>=3.10.0,<4.0.0)
Requires-Dist: pyyaml (==6.0)
Requires-Dist: tomli (==2.0.1)
Requires-Dist: tqdm (==4.65.0)
Requires-Dist: virtualenv (==20.21.0)
Description-Content-Type: text/markdown

# Solcix

Solcix is a Solidity compiler manager for Python. You can switch between versions, compile, and manage artifacts easily.

## Installation

To install Solcix, you can use pip, the Python package manager:

### With pip For Windows

```bash
pip install solcix
```

### With pip3 For Linux / Mac

```bash
pip3 install solcix
```

### With pipx

[pipx](https://github.com/pypa/pipx) installs packages in their own virtual environment, so there's less chance of conflicting dependencies. You can run the following command in your terminal to install:

```bash
pipx install solcix
```

### With poetry

Uses the [poetry](https://github.com/python-poetry/poetry) package manager to install solcix in a project-specific virtual environment. poetry manages dependencies for you and allows you to isolate your project from the global environment. You can run the following command in your terminal to add solcix to your poetry project, and use our wrapped solc api in your code:

```bash
poetry add solcix
```

### With pipenv

Uses the [pipenv](https://pipenv.pypa.io/en/latest/) package manager to install solcix in a project-specific virtual environment. pipenv also manages dependencies and isolates your project from the global environment, and use our wrapped solc api in your code. You can run the following command in your terminal to install:

```bash
pipenv install solcix
```

## Usage - CLI

Solcix can be used as a library or as a command line tool. Here are the available commands:

### Installing Solidity compilers

The `install` command can be used to install one or more versions of the Solidity compiler:

Example usage:

```bash
solcix install 0.8.4 0.7.6
```

### Listing available Solidity compilers

The `versions` command can be used to list all available versions of the Solidity compiler:

Example usage:

```bash
solcix versions
```

### Listing installed Solidity compilers

The `ls` command can be used to list all available versions of the Solidity compiler:

Example usage:

```bash
solcix ls
```

If global / local version is set, it will be displayed as below:

```bash
0.8.19
0.5.2
0.5.1
0.5.0
0.8.0 <- current
0.8.0
0.8.16
```

### Switching between Solidity compilers

The `use` command can be used to switch between installed versions of the Solidity compiler, either globally or locally.

- If the specified version is not installed, it will be installed automatically.

- If you use the `local` option, it will create a `.solcix` file in the current directory.

Example usage:

```bash
# Setting global version to 0.8.16
solcix use global 0.8.16
```

```bash
# Setting local version to 0.8.16, it will create a .solcix file in the current directory
solcix use local 0.8.16
```

Simply run the command will see the changes:

```bash
solc --version
```

### Uninstalling Solidity compilers

The `uninstall` command can be used to uninstall one or more versions of the Solidity compiler:

```bash
solcix uninstall 0.8.4 0.7.6
```

### Uninstall all Solidity compilers

To uninstall all versions of Solidity compiler that have been installed using solcix, you can use the following command:

```bash
solcix prune
```

This will remove all versions of the Solidity compilers that have been installed by solcix, all cached files, and the solcix configuration file (local config takes precedence over global config).

### Verify Solidity compilers

The `verify` command is used to verify the checksums of installed solc binaries and to reinstall any that are malformed.

Example usage:

```bash
solcix verify 0.8.0 0.8.1
```

### Clear cache of Solidity compilers

The `clear` command is used to remove all cached files. The cache is used to store the downloaded file list. The binary will not be deleted.

Example usage:

```bash
solcix clear
```

### Compile Solidity files

The `compile` command is used to compile Solidity files and print the result. If the output is a TTY, the result will be formatted. Otherwise, the result will be printed as a JSON string.

Example usage:

```bash
solcix compile <file.sol>
```

The command also supports the `-o` or `--output` option to specify an output directory for the compilation result.

Example usage:

```bash
solcix compile <filename>.sol -o <output_dir>
```

Additional optional arguments can be passed to the command using the kwargs argument, it will be taken by the [solc command](https://docs.soliditylang.org/en/v0.8.19/using-the-compiler.html#basic-usage).

Example usage:

```bash
solcix compile <file.sol> --optimize
```

### Resolve compatible versions from solidity file

The `resolve` command is used to determine the recommended solc version for a Solidity file based on its pragma statement. It can also be used to list all versions that are compatible with the Solidity file.

Example usage:

```bash
solcix resolve <file.sol>
```

By default, the command prints the recommended solc version for the Solidity file.

Solidity Example:

```solidity
// SPDX-License-Identifier: MIT
// compiler version must be `0.8.5`, `0.8.6` or `0.8.7`
pragma solidity >=0.8.5 <=0.8.7;
contract HelloWorld {
    string public greet = "Hello World!";
}
```

Example output:

```bash
The recommended version is 0.8.5, use `solcix resolve --no-recommand` to see all compatible versions.
```

If the `--no-recommand` option is used, the command will print all compatible versions for the Solidity file.

Example output:

```bash
These versions are compatible with the pragma.
0.8.5
0.8.6
0.8.7
```

### Upgrade Solcix

The `upgrade` command is used to upgrade the architecture of the installed solc binaries, it will remove all old binaries and download the new ones.

Example usage:

```bash
pip3 install -U

# Migrate to the new architecture and Reinstall all binaries
solcix upgrade
```

### Project Acknowledgements

We would like to thank the original projects [solc-select](https://github.com/crytic/solc-select) and [py-solc-x](https://github.com/ApeWorX/py-solc-x) for providing excellent code base, upon which we have optimized and improved to make the project more robust and user-friendly.

Our project is an improved and optimized version of solc-select and py-solc-x, with more features and excellent performance.

If you enjoyed the original projects, we strongly recommend trying out our project to enjoy a better user experience and more efficient code execution.

