mirror of
https://gitea.psi.ch/APOG/acsmnode.git
synced 2025-06-27 20:11:09 +02:00
Fix bash script, previous version created an env with incopatible binaries.
This commit is contained in:
45
env_setup.sh
45
env_setup.sh
@ -1,8 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Define the name and location of the environment
|
# Define the name of the environment
|
||||||
ENV_NAME="multiphase_chem_env"
|
ENV_NAME="multiphase_chemistry_env"
|
||||||
ENV_PATH="./envs/$ENV_NAME" # Define a custom output folder
|
|
||||||
|
|
||||||
# Check if mamba is available and use it instead of conda for faster installation
|
# Check if mamba is available and use it instead of conda for faster installation
|
||||||
if command -v mamba &> /dev/null; then
|
if command -v mamba &> /dev/null; then
|
||||||
@ -11,19 +10,39 @@ else
|
|||||||
CONDA_COMMAND="conda"
|
CONDA_COMMAND="conda"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create the conda environment with all dependencies
|
# Create the conda environment with all dependencies, resolving from conda-forge and defaults
|
||||||
$CONDA_COMMAND create -y -p "$ENV_PATH" python=3.11 \
|
$CONDA_COMMAND create -y -n "$ENV_NAME" -c conda-forge -c defaults python=3.11 \
|
||||||
jupyter numpy pandas matplotlib plotly=5.24 scipy pip
|
jupyter numpy h5py pandas matplotlib plotly=5.24 scipy pip
|
||||||
|
|
||||||
|
# Check if the environment was successfully created
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to create the environment '$ENV_NAME'. Please check the logs above for details."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Activate the new environment
|
# Activate the new environment
|
||||||
source activate "$ENV_PATH" || conda activate "$ENV_PATH"
|
if source activate "$ENV_NAME" 2>/dev/null || conda activate "$ENV_NAME" 2>/dev/null; then
|
||||||
|
echo "Environment '$ENV_NAME' activated successfully."
|
||||||
|
else
|
||||||
|
echo "Failed to activate the environment '$ENV_NAME'. Please check your conda setup."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Install pip packages in one go to avoid repeated initializations
|
# Install additional pip packages only if the environment is activated
|
||||||
pip install h5py==3.10 pybis==1.35 igor2 ipykernel dash dash-bootstrap-components
|
echo "Installing additional pip packages..."
|
||||||
|
pip install pybis==1.35 igor2 ipykernel sphinx
|
||||||
|
pip install dash dash-bootstrap-components
|
||||||
|
|
||||||
# Export the environment to a YAML file
|
# Check if pip installations were successful
|
||||||
$CONDA_COMMAND env export --prefix "$ENV_PATH" > "$ENV_PATH/environment.yaml"
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to install pip packages. Please check the logs above for details."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Optional: Export the environment to a YAML file (commented out)
|
||||||
|
# $CONDA_COMMAND env export -n "$ENV_NAME" > "$ENV_NAME-environment.yaml"
|
||||||
|
|
||||||
# Print success message
|
# Print success message
|
||||||
echo "Environment '$ENV_NAME' created successfully at '$ENV_PATH'."
|
echo "Environment '$ENV_NAME' created and configured successfully."
|
||||||
echo "Environment configuration saved to '$ENV_PATH/environment.yaml'."
|
# echo "Environment configuration saved to '$ENV_NAME-environment.yaml'."
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user