-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from datastax-labs/gbk-harmonise-build
Adds wrapper scripts for tox and poetry, which create a venv, install the respective tool, and run it. This removes any requirement on the caller to mess around with setting up venvs, while not preventing their usage should developers wish to do so. It also enforces import ordering and removal of redundant imports using autoflake and isort.
- Loading branch information
Showing
28 changed files
with
343 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
# Setting up for development | ||
|
||
* [Install poetry](https://python-poetry.org/docs/#installation) | ||
* Ensure that `python3` points to a version of python >= 3.8 (`python3 --version` will tell you). If it does not, use [pyenv](https://github.com/pyenv/pyenv) to both install a recent python version and make it your current python. | ||
|
||
* If you want to maintain your own virtualenv, install pyenv and use pyenv virtualenv to create and manage one. Poetry will automatically find any active virtualenv and use that. | ||
* There are two wrappers (`poetryw` and `toxw`) that install and run the correct versions of [poetry](https://python-poetry.org) and [tox](https://tox.wiki) for you. | ||
|
||
* Run poetry to install dependencies: | ||
|
||
``` | ||
poetry install | ||
./poetryw install | ||
``` | ||
|
||
* Run the development version of hunter using poetry: | ||
|
||
``` | ||
poetry run hunter ... | ||
./poetryw run hunter ... | ||
``` | ||
|
||
See the [poetry docs](https://python-poetry.org/docs) for more. | ||
|
||
# Running tests | ||
|
||
``` | ||
poetry run pytest tests | ||
./poetryw run pytest | ||
``` | ||
|
||
...or using [tox](https://tox.readthedocs.io/): | ||
|
||
``` | ||
ci-tools/tox-bootstrap | ||
./toxw | ||
``` | ||
|
||
# Linting and formatting | ||
|
||
Code-style is enforced using [black](https://black.readthedocs.io/). Linting is automatically applied when tox runs tests; if linting fails, you can fix it with: | ||
Code-style is enforced using [black](https://black.readthedocs.io/) and [flake8](https://flake8.pycqa.org/); import optimisation is handled by [isort](https://pycqa.github.io/isort/) and [autoflake](https://pypi.org/project/autoflake/). Linting is automatically applied when tox runs tests; if linting fails, you can fix trivial problems with: | ||
|
||
``` | ||
ci-tools/tox-bootstrap -e format | ||
./toxw -e format | ||
``` | ||
|
||
|
||
# Build a docker image | ||
|
||
``` | ||
ci-tools/tox-bootstrap -e docker-build | ||
./toxw -e docker-build | ||
``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Support functions for bootstrapping python tools | ||
|
||
python=${PYTHON:-python3} | ||
|
||
# set -x would generate a lot of noise when we activate the venv, so | ||
# we use this hand-crafted equivalent here: | ||
run() | ||
{ | ||
echo "$@" 1>&2 | ||
"$@" | ||
} | ||
|
||
build_dir="$thisdir/build" | ||
venvs_dir="$build_dir/venvs" | ||
bin_dir="$build_dir/wrappers/bin" | ||
|
||
install_tool() | ||
{ | ||
tool="$1" | ||
shift | ||
|
||
pip_spec="$1" | ||
shift | ||
|
||
test -f "$bin_dir/$tool" && return | ||
|
||
run mkdir -p "$venvs_dir" "$bin_dir" | ||
|
||
venv="$venvs_dir/$tool" | ||
|
||
run "$python" -m venv "$venv" | ||
|
||
# Run in a subshell to prevent the activate/deactivate steps | ||
# interfering with pyenv | ||
( | ||
run source "$venv/bin/activate" | ||
run "$python" -m pip install -qqq --upgrade pip | ||
run "$python" -m pip install -qqq $pip_spec | ||
run ln -fs "../../venvs/$tool/bin/$tool" "$bin_dir/$tool" | ||
run deactivate | ||
) | ||
} | ||
|
||
run_tool() | ||
{ | ||
tool="$1" | ||
shift | ||
|
||
# Ensure that the tool has access to all the bootstrapped tools | ||
PATH="$bin_dir:$PATH" | ||
|
||
exec "$bin_dir/$tool" "$@" | ||
} | ||
|
||
install_and_run_tool() | ||
{ | ||
tool="$1" | ||
shift | ||
|
||
pip_spec="$1" | ||
shift | ||
|
||
install_tool "$tool" "$pip_spec" | ||
run_tool "$tool" "$@" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import enum | ||
|
||
from dataclasses import dataclass | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.