Created
September 11, 2024 15:26
-
-
Save kipavy/f0d73807dfa22ee8ab9f312b3447eebe to your computer and use it in GitHub Desktop.
This script automates the process of setting up a Conda environment, installing a Python package using Poetry, and running tests. It creates a Conda environment with the specified Python version, installs the package and its dependencies, runs the tests, and then cleans up by deactivating and removing the Conda environment. Usage: ./core.sh <pyt…
This file contains hidden or 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
| #!/bin/bash | |
| # Check if the Python version argument is provided | |
| if [ -z "$1" ]; then | |
| echo "Usage: $0 <python-version>" | |
| exit 1 | |
| fi | |
| PYTHON_VERSION=$1 | |
| ENV_NAME="test_env_$PYTHON_VERSION" | |
| # Create a new conda environment with the specified Python version | |
| conda create -y -n $ENV_NAME python=$PYTHON_VERSION | |
| # Activate the conda environment | |
| conda activate $ENV_NAME | |
| # Upgrade pip and install Poetry | |
| pip install --upgrade pip | |
| pip install poetry | |
| # Install the package using Poetry | |
| poetry install | |
| # Run the specified test file | |
| poetry run pytest tests/test_core.py | |
| # "poetry run pytest" to run all tests | |
| # Deactivate the conda environment | |
| conda deactivate | |
| # Remove the conda environment | |
| conda env remove -n $ENV_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment