-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Darren Weber
committed
Nov 4, 2020
1 parent
2d49040
commit 3d034ac
Showing
9 changed files
with
860 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.1.0 | ||
hooks: | ||
- id: check-yaml | ||
args: [--unsafe] | ||
exclude: '.*templates.*.yaml' | ||
- id: end-of-file-fixer | ||
exclude: 'CHANGELOG.md' | ||
- id: trailing-whitespace | ||
exclude: 'CHANGELOG.md' | ||
- id: check-ast | ||
- repo: https://github.com/gruntwork-io/pre-commit | ||
rev: v0.1.9 | ||
hooks: | ||
- id: shellcheck | ||
- repo: https://github.com/psf/black | ||
rev: 19.10b0 | ||
hooks: | ||
- id: black |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2019-2020 Darren Weber | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
# https://python-release-cycle.glitch.me/ | ||
|
||
# Source this file from ~/.bashrc or similar shell-init, such | ||
# as copy the file to /etc/profile.d/ | ||
|
||
|
||
# Enable this to create conda env for each python version | ||
if false; then | ||
conda create -y -n py3.6 python=3.6 | ||
conda create -y -n py3.7 python=3.7 | ||
conda create -y -n py3.8 python=3.8 | ||
fi | ||
|
||
# CONDA PYTHON VERSIONS | ||
alias py36='conda deactivate; conda activate py3.6' | ||
alias py37='conda deactivate; conda activate py3.7' | ||
alias py38='conda deactivate; conda activate py3.8' | ||
|
||
conda-project () { | ||
# The project name is defined by CONDA_ENV or the current working directory | ||
project=${CONDA_ENV:-$(pwd)} | ||
basename "${project}" | ||
} | ||
|
||
conda-venv-activate () { | ||
# try to activate a conda environment with the name of | ||
# the current directory (often this is a project name). | ||
wd=$(conda-project) | ||
conda deactivate | ||
conda activate "$wd" | ||
} | ||
|
||
conda-venv-create () { | ||
# create and activate a conda environment with the name | ||
# of the current directory (often this is a project name). | ||
py_ver="${1:-3.6}" | ||
wd=$(conda-project) | ||
conda deactivate | ||
|
||
conda create -n "$wd" python="${py_ver}" \ | ||
--channel conda-forge --override-channels \ | ||
&& conda activate "$wd" \ | ||
&& conda config --env --add channels conda-forge \ | ||
&& conda config --env --set channel_priority strict | ||
} | ||
|
||
conda-venv-remove () { | ||
# try to activate a conda environment with the name of | ||
# the current directory (often this is a project name). | ||
wd=$(conda-project) | ||
conda deactivate | ||
conda env remove -n "$wd" | ||
} | ||
|
||
conda-venv () { | ||
# create and activate a conda environment with the name | ||
# of the current directory (often this is a project name). | ||
py_ver="${1:-3.6}" | ||
wd=$(conda-project) | ||
|
||
if conda env list | grep -E "^${wd}\s+" > /dev/null; then | ||
conda-venv-activate | ||
else | ||
conda-venv-create "${py_ver}" | ||
fi | ||
command -v poetry > /dev/null | ||
python --version | ||
} | ||
|
||
conda-pipenv () { | ||
conda-venv "$1" | ||
command -v pipenv > /dev/null | python -m pip install -U pipenv | ||
pipenv --python="$(conda run which python)" --site-packages | ||
} | ||
|
||
conda-install () { | ||
if ! command -v conda > /dev/null; then | ||
# Support OSX and Linux - a Windows user can add support for it later | ||
OS=$(uname) | ||
if [ "$OS" == "Darwin" ]; then | ||
installer='https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh' | ||
elif [ "$OS" == "Linux" ]; then | ||
installer='https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh' | ||
fi | ||
install_script="/tmp/$(basename $installer)" | ||
wget --quiet $installer -O "$install_script" | ||
/bin/bash "$install_script" | ||
fi | ||
} |
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,43 @@ | ||
#!/bin/bash | ||
|
||
export CONDA_ENV="aiobotocore" | ||
|
||
# shellcheck disable=SC1091 | ||
source ./conda_venv.sh | ||
|
||
if ! command -v conda > /dev/null; then | ||
conda-install | ||
fi | ||
|
||
# Assume conda is already installed correctly and | ||
# source the conda config file from the usual paths | ||
# shellcheck disable=SC1091,SC1090 | ||
source /etc/profile.d/conda.sh || \ | ||
source /opt/conda/etc/profile.d/conda.sh || \ | ||
source ~/miniconda3/etc/profile.d/conda.sh || \ | ||
source ~/opt/anaconda3/etc/profile.d/conda.sh | ||
|
||
conda-venv 3.6 | ||
command -v python | ||
python --version | ||
python -m pip install --upgrade pip | ||
|
||
if ! command -v poetry > /dev/null; then | ||
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python | ||
fi | ||
|
||
# install dev-deps before the poetry project installation, so | ||
# that the project dependencies can override the dev-deps. | ||
if [ -f requirements.dev ]; then | ||
poetry run python -m pip install -r requirements.dev | ||
poetry run pre-commit install | ||
# pip does not fully resolve conflicts, it just warns about them; | ||
# use pip check to identify conflicts; some of them may not be | ||
# important but others may need to be fixed somehow | ||
poetry run python -m pip check | ||
fi | ||
|
||
# for development, install all the extras | ||
poetry install -v --no-interaction --extras all | ||
|
||
echo "To activate environment, execute 'conda activate ${CONDA_ENV}'" |
Oops, something went wrong.