Skip to content

Commit d866c55

Browse files
authored
Merge pull request #40 from crytic/python-package
Transform solc-select into a Python package
2 parents add3f08 + d8d0cce commit d866c55

21 files changed

+156
-689
lines changed

Diff for: .github/workflows/pythonpublish.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Upload Python Package
5+
6+
on:
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
deploy:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel twine
25+
- name: Build and publish
26+
env:
27+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
28+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
29+
run: |
30+
python setup.py sdist bdist_wheel
31+
twine upload dist/*

Diff for: Dockerfile

-51
This file was deleted.

Diff for: README.md

+30-88
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,36 @@
11
# solc-select
2-
A script to quickly switch between Solidity compiler versions.
2+
A tool to quickly switch between Solidity compiler versions.
33

4-
It is becoming increasingly hard to run older versions of `solc`,
5-
particularly on macOS since there are no official binary releases.
6-
Versions prior to 0.5.0 no longer compile on macOS and are not
7-
maintained. This is a problem because older Ethereum contracts no
8-
longer compile on modern versions of Solidity. `solc-select` is a
9-
utility that allows one to run _any_ legacy version of Solidity simply
10-
by setting an environment variable.
4+
The tool is split into two CLI utilities:
5+
- `solc-select`: manages installing and setting different `solc` compiler versions
6+
- `solc`: wrapper around `solc` which picks the right version according to what was set via `solc-select`
117

12-
## Quickstart
13-
14-
### OS X:
15-
```
16-
docker pull trailofbits/solc-select
17-
docker run --read-only -i --rm --entrypoint='/bin/sh' trailofbits/solc-select:latest -c 'cat /usr/bin/install.sh' | bash -e
18-
```
19-
20-
This will install `solc` globally. If `solc` is already installed, you
21-
will be prompted to overwrite it.
22-
23-
To install `solc` to a different directory, run the `docker` command or
24-
the install script, with the environment variable `PREFIX` set; `solc`
25-
will be installed to `${PREFIX}/bin/solc`.
8+
The `solc` binaries are downloaded from https://binaries.soliditylang.org/ which contains
9+
official artifacts for many historial and modern `solc` versions for Linux and macOS.
2610

27-
Alternatively, manually copy [the special solc script](bin/solc) to your desired location.
11+
The downloaded binaries are stored in `~/.solc-select/artifacts/`.
2812

29-
### Linux
30-
```
31-
git clone https://github.com/crytic/solc-select.git
32-
./solc-select/scripts/install.sh
33-
```
34-
35-
This will install `solc` into ~/.solc-select/, so you have to add it to the PATH variable. Add this line, replacing USERNAME with your username, to your `.bashrc` or equivalent:
13+
## Quickstart
3614

3715
```
38-
export PATH=/home/USERNAME/.solc-select:$PATH
16+
pip3 install solc-select
3917
```
4018

41-
4219
## Usage
4320

44-
The desired version of `solc` can be set with the `use` command. By default, the latest version is used.
45-
21+
The global version of `solc` can be set with the `solc-select use <version>` command:
4622
```
4723
$ solc --version
4824
solc, the solidity compiler commandline interface
4925
Version: 0.5.2+commit.1df8f40c.Linux.g++
50-
$ solc use 0.4.24
26+
$ solc-select use 0.4.24
27+
Switched global version to 0.4.24
28+
$ solc --version
5129
solc, the solidity compiler commandline interface
5230
Version: 0.4.24+commit.e67f0147.Linux.g++
5331
```
5432

55-
56-
In special scenarios the current version can also be overwritten with the `SOLC_VERSION` environment variable.
57-
33+
Use `SOLC_VERSION` environment variable to override the global version:
5834
```
5935
$ solc --version
6036
solc, the solidity compiler commandline interface
@@ -64,63 +40,29 @@ solc, the solidity compiler commandline interface
6440
Version: 0.5.2+commit.1df8f40c.Linux.g++
6541
```
6642

67-
68-
You can list all available versions with the special `--versions` argument:
43+
You can list all available versions with `solc-select install`:
6944
```
70-
$ solc --versions
71-
0.4.11
72-
0.4.12
73-
0.4.13
74-
0.4.14
75-
0.4.15
76-
0.4.16
77-
0.4.17
78-
0.4.18
79-
0.4.19
80-
0.4.20
81-
0.4.21
82-
0.4.22
83-
0.4.23
84-
0.4.24
85-
0.4.25
86-
0.5.0
87-
0.5.1
88-
0.5.2
89-
0.5.3
90-
0.5.4
91-
0.5.5
92-
nightly
45+
$ solc-select install
46+
Available versions to install:
47+
0.3.6
48+
0.4.0
49+
...
50+
0.8.0
51+
0.8.1
9352
```
9453

95-
## Upgrading
96-
97-
Once installed, simply run
54+
And install the one you need with with `solc-select install <version>`:
9855
```
99-
solc --upgrade
56+
$ solc-select install 0.8.1
57+
Installing '0.8.1'...
58+
Version '0.8.1' installed.
10059
```
101-
to automatically upgrade `solc-select`. This will automatically pull the latest Docker image (or repo source, depending on your OS) and upgrade the local `solc` script, if necessary. The [DockerHub image for `solc-select`](https://hub.docker.com/r/trailofbits/solc-select) will automatically update every time Solidity is updated, which will typically be nightly.
102-
103-
## Installation from Source on OS X
104-
105-
```
106-
$ git clone https://github.com/trailofbits/solc-select.git
107-
$ cd solc-select
108-
$ docker build -t trailofbits/solc-select:latest .
109-
$ bin/solc --install
110-
```
111-
112-
## Experimental solc-select
113-
114-
The experimental version of `solc-select` is a Python-based script without any
115-
additional dependencies. Both macOS and Linux solc binaries are downloaded from
116-
https://binaries.soliditylang.org/ and macOS binaries run natively. Some
117-
features are still missing, like version range installation or nightly builds.
11860

119-
Try it out:
61+
Display the currently installed versions:
12062
```
121-
git clone https://github.com/crytic/solc-select ~/.solc-select
122-
export PATH=~/.solc-select/experimental/bin:$PATH
123-
solc-select --help
63+
$ solc-select versions
64+
0.8.0
65+
0.4.2 (current, set by /Users/artur/.solc-select/global-version)
12466
```
12567

12668
## Getting Help

Diff for: bin/solc

-72
This file was deleted.

Diff for: experimental/bin/solc

-12
This file was deleted.

Diff for: experimental/bin/solc_select.py

-27
This file was deleted.

Diff for: scripts/chroot.sh

-3
This file was deleted.

0 commit comments

Comments
 (0)