Visitar URL original
Transform solc-select into a Python package by arcz · Pull Request #40 · crytic/solc-select · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [published]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
51 changes: 0 additions & 51 deletions Dockerfile

This file was deleted.

28 changes: 1 addition & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,7 @@ by setting an environment variable.

## Quickstart

### OS X:
```
docker pull trailofbits/solc-select
docker run --read-only -i --rm --entrypoint='/bin/sh' trailofbits/solc-select:latest -c 'cat /usr/bin/install.sh' | bash -e
```

This will install `solc` globally. If `solc` is already installed, you
will be prompted to overwrite it.

To install `solc` to a different directory, run the `docker` command or
the install script, with the environment variable `PREFIX` set; `solc`
will be installed to `${PREFIX}/bin/solc`.

Alternatively, manually copy [the special solc script](bin/solc) to your desired location.

### Linux
```
git clone https://github.com/crytic/solc-select.git
./solc-select/scripts/install.sh
```

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:

```
export PATH=/home/USERNAME/.solc-select:$PATH
```

```pip3 install solc-select```

## Usage

Expand Down
76 changes: 7 additions & 69 deletions bin/solc
Original file line number Diff line number Diff line change
@@ -1,72 +1,10 @@
#!/bin/bash
#!/usr/bin/env python3
import os
import sys
from pathlib import Path

function run_linux() {
export SSELECT_INSTALL_DIR="$HOME/.solc-select"
sys.path.append(str(Path(os.path.dirname(os.path.realpath(__file__))).parent))
Comment thread
arcz marked this conversation as resolved.
Resolved

if [ ! -e "$SSELECT_INSTALL_DIR" ]; then
echo 'It appears you do not have solc-select installed, run `solc --install` to install it.'
exit 1
fi
from solc_select.__main__ import solc

if [[ "$1" == "--upgrade" ]] || [[ "$1" == "--install" ]]; then
if [[ "$1" == "--upgrade" ]]; then
echo "Upgrading solc-select..."
else
echo "Installing solc-select..."
fi

TMP_CLONE_DIR=/tmp/solc-select
rm -rf $TMP_CLONE_DIR
git clone "https://github.com/crytic/solc-select.git" $TMP_CLONE_DIR

$TMP_CLONE_DIR/scripts/install.sh

rm -rf $TMP_CLONE_DIR
else
$SSELECT_INSTALL_DIR/usr/bin/solc-runner $@
fi
}

function run_docker() {
if [[ "$1" == "--upgrade" ]] || [[ "$1" == "--install" ]]; then
if [[ "$1" == "--upgrade" ]]; then
echo "Upgrading solc-select..."
docker pull trailofbits/solc-select:latest
else
echo "Installing solc-select..."
fi
if [[ ! -z "$2" ]]; then
mkdir -p $2/bin
fi
export PREFIX="$2"
docker run --read-only -i --rm --entrypoint='/bin/sh' trailofbits/solc-select:latest -c 'cat /usr/bin/install.sh' | bash
else
docker run --read-only -i --rm --cap-add=SYS_ADMIN -e SOLC_VERSION="$SOLC_VERSION" -e HOST_PWD="$PWD" --mount type=bind,source=/,target=/workdir trailofbits/solc-select:latest $@
fi
}

OS=$(uname)

# use command
if [ "$1" == "use" ]; then
if [[ -z "$2" ]]; then
echo "Need to provide a version to use. To list all available versions use 'solc --versions'"
# The next line will check that the provided version exists in the list of available versions
elif printf '%s\n' $(solc --versions) | grep -q -E "^$2$"; then
echo "export SOLC_VERSION=$2" >$HOME/.solcv
echo "Now using version $2"
else
echo "Version $2 not supported. List all available versions with 'solc --versions'"
fi
else
# Check that a solcv file exists in the home directory, and that the Version was not manually set by a user
if [ -f $HOME/.solcv ] && [[ -z $SOLC_VERSION ]]; then
source $HOME/.solcv
fi

if [ $OS = "Linux" ]; then
run_linux $@
else
run_docker $@
fi
fi
solc()
10 changes: 10 additions & 0 deletions bin/solc-select
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python3
import os
import sys
from pathlib import Path

sys.path.append(str(Path(os.path.dirname(os.path.realpath(__file__))).parent))

from solc_select.__main__ import solc_select

solc_select()
12 changes: 0 additions & 12 deletions experimental/bin/solc

This file was deleted.

27 changes: 0 additions & 27 deletions experimental/bin/solc_select.py

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/chroot.sh

This file was deleted.

90 changes: 0 additions & 90 deletions scripts/install.sh

This file was deleted.

35 changes: 0 additions & 35 deletions scripts/install_linux.sh

This file was deleted.

Loading