-
-
Save ztraboo/d1e9cad3e9a9c03e75f2792922f887f2 to your computer and use it in GitHub Desktop.
direnv – configuration for multidevstack environment for Open edX
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
## ~/.bashrc | |
## Hook in `direnv` for local directory environment overrides. | |
## https://direnv.net/docs/hook.html | |
eval "$(direnv hook bash)" | |
# https://github.com/direnv/direnv/wiki/Python#bash | |
show_virtual_env() { | |
if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then | |
echo "($(basename $VIRTUAL_ENV))" | |
fi | |
} | |
export -f show_virtual_env | |
PS1='$(show_virtual_env)'$PS1 | |
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
## /Users/ztraboo/Dev/EducateWorkforce/Repos/open-edx/devstack.ironwood/.envrc | |
# https://discuss.openedx.org/t/docker-devstack-multiple-releases-one-machine/1902/10 | |
# This is handled when OPENEDX_RELEASE is set. Leaving this in for manual override. | |
# export COMPOSE_PROJECT_NAME=devstack-hawthorn | |
export DEVSTACK_WORKSPACE="$(pwd)" | |
export OPENEDX_RELEASE=hawthorn.master | |
export VIRTUAL_ENV="$(pwd)/devstack/venv" | |
# https://github.com/direnv/direnv/wiki/Python#virtualenv | |
layout python-venv |
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
## /Users/ztraboo/Dev/EducateWorkforce/Repos/open-edx/devstack.ironwood/.envrc | |
# https://discuss.openedx.org/t/docker-devstack-multiple-releases-one-machine/1902/10 | |
# This is handled when OPENEDX_RELEASE is set. Leaving this in for manual override. | |
# export COMPOSE_PROJECT_NAME=devstack-ironwood | |
export DEVSTACK_WORKSPACE="$(pwd)" | |
export OPENEDX_RELEASE=ironwood.master | |
export VIRTUAL_ENV="$(pwd)/devstack/venv" | |
# https://github.com/direnv/direnv/wiki/Python#virtualenv | |
layout python-venv | |
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
## /Users/ztraboo/Dev/EducateWorkforce/Repos/open-edx/devstack.ironwood/.envrc | |
# https://discuss.openedx.org/t/docker-devstack-multiple-releases-one-machine/1902/10 | |
# This is handled when OPENEDX_RELEASE is set. Leaving this in for manual override. | |
# export COMPOSE_PROJECT_NAME=devstack | |
export DEVSTACK_WORKSPACE="$(pwd)" | |
# Don't define OPENEDX_RELEASE for the `master` release. | |
export VIRTUAL_ENV="$(pwd)/devstack/venv" | |
# https://github.com/direnv/direnv/wiki/Python#virtualenv | |
layout python-venv | |
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
## ~/.zshrc | |
## Hook in `direnv` for local directory environment setup. | |
## https://direnv.net/docs/hook.html | |
eval "$(direnv hook zsh)" | |
# https://github.com/direnv/direnv/wiki/Python#zsh | |
setopt PROMPT_SUBST | |
show_virtual_env() { | |
if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then | |
echo "($(basename $VIRTUAL_ENV))" | |
fi | |
} | |
PS1='$(show_virtual_env)'$PS1 |
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
## ~/.config/direnv/direnvrc | |
# https://github.com/direnv/direnv/wiki/Python#venv-stdlib-module | |
realpath() { | |
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" | |
} | |
layout_python-venv() { | |
local python=${1:-python3} | |
[[ $# -gt 0 ]] && shift | |
unset PYTHONHOME | |
if [[ -n $VIRTUAL_ENV ]]; then | |
VIRTUAL_ENV=$(realpath "${VIRTUAL_ENV}") | |
else | |
local python_version | |
python_version=$("$python" -c "import platform; print(platform.python_version())") | |
if [[ -z $python_version ]]; then | |
log_error "Could not detect Python version" | |
return 1 | |
fi | |
VIRTUAL_ENV=$PWD/.direnv/python-venv-$python_version | |
fi | |
export VIRTUAL_ENV | |
if [[ ! -d $VIRTUAL_ENV ]]; then | |
log_status "no venv found; creating $VIRTUAL_ENV" | |
"$python" -m venv "$VIRTUAL_ENV" | |
fi | |
PATH="${VIRTUAL_ENV}/bin:${PATH}" | |
export PATH | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you get this error then you just need to issue a
direnv allow
to make this permission work.