-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
swancustomenvironments: New conda environment option
Conda (mamba) environments can now be built passing the argument `--conda` into the `makenv.sh` script. Some logic and code flow modifications were needed in order to build them sameway as python-venv.
- Loading branch information
1 parent
330e7c9
commit 1792f5b
Showing
6 changed files
with
124 additions
and
62 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
SwanCustomEnvironments/swancustomenvironments/scripts/builders/accpy.sh
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,22 @@ | ||
#!/bin/bash | ||
|
||
# Checks if the provided Acc-Py version is valid | ||
if [ ! -e "$ACCPY_PATH/base/$BUILDER_VERSION" ]; then | ||
_error "Invalid Acc-Py version (${BUILDER_VERSION})." | ||
fi | ||
|
||
# Set up Acc-Py and create the environment | ||
source "${ACCPY_PATH}/base/${BUILDER_VERSION}/setup.sh" | ||
acc-py venv ${ENV_PATH} | tee -a ${LOG_PATH} | ||
|
||
# Activate the environment | ||
_log "Setting up the environment..." | ||
ACTIVATE_ENV_CMD="source ${ENV_PATH}/bin/activate" | ||
eval "${ACTIVATE_ENV_CMD}" | ||
|
||
# Install packages in the environment | ||
_log "Installing packages from ${REQ_PATH}..." | ||
pip install -r "${REQ_PATH}" | tee -a ${LOG_PATH} | ||
|
||
# Install the same ipykernel that the Jupyter server uses | ||
pip install ipykernel==${IPYKERNEL_VERSION} | tee -a ${LOG_FILE} |
23 changes: 23 additions & 0 deletions
23
SwanCustomEnvironments/swancustomenvironments/scripts/builders/mamba.sh
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,23 @@ | ||
#!/bin/bash | ||
|
||
# Create the environment and install packages | ||
mamba create -p ${ENV_PATH} --file ${REQ_PATH} -y | tee -a ${LOG_PATH} | ||
|
||
# Activate the environment | ||
_log "Setting up the environment..." | ||
|
||
# Needed to use mamba activate without creating a new shell process | ||
MAMBADIR=$(mktemp -d) | ||
HOME=${MAMBADIR} mamba init | ||
ACTIVATE_MAMBA_CMD="source ${MAMBADIR}/.bashrc" | ||
eval "${ACTIVATE_MAMBA_CMD}" | ||
|
||
# Then activate the environment using mamba | ||
ACTIVATE_ENV_CMD="mamba activate ${ENV_PATH}" | ||
eval "${ACTIVATE_ENV_CMD}" | ||
|
||
# Install the same ipykernel that the Jupyter server uses | ||
mamba install "ipykernel==${IPYKERNEL_VERSION}" -y | tee -a ${LOG_PATH} | ||
|
||
# Source the mamba init script in the user's bash profile | ||
echo "${ACTIVATE_MAMBA_CMD}" >> /home/$USER/.bash_profile |
16 changes: 16 additions & 0 deletions
16
SwanCustomEnvironments/swancustomenvironments/scripts/builders/venv.sh
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,16 @@ | ||
#!/bin/bash | ||
|
||
# Create the environment | ||
python3 -m venv ${ENV_PATH} | tee -a ${LOG_PATH} | ||
|
||
# Activate the environment | ||
_log "Setting up the environment..." | ||
ACTIVATE_ENV_CMD="source ${ENV_PATH}/bin/activate" | ||
eval "${ACTIVATE_ENV_CMD}" | ||
|
||
# Install packages in the environment | ||
_log "Installing packages from ${REQ_PATH}..." | ||
pip install -r "${REQ_PATH}" | tee -a ${LOG_PATH} | ||
|
||
# Install the same ipykernel that the Jupyter server uses | ||
pip install ipykernel==${IPYKERNEL_VERSION} | tee -a ${LOG_FILE} |
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