Last active
December 16, 2025 09:17
-
-
Save sglbl/27d51879413b86a962455fb37594e2d3 to your computer and use it in GitHub Desktop.
Add project dir for uv
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 | |
| set -e | |
| # Step 0: Check if main.py exists before uv init | |
| MAIN_EXISTS=false | |
| [ -f main.py ] && MAIN_EXISTS=true | |
| # Step 0: Run uv init (it will generate default files) | |
| uv init | |
| # Step 1: Remove only files that can be safely deleted (like .python-version) | |
| rm -f .python-version | |
| # Step 1.5: Remove main.py if it was created by uv init | |
| if [ "$MAIN_EXISTS" = false ] && [ -f main.py ]; then | |
| rm -f main.py | |
| echo "Removed uv init generated main.py" | |
| fi | |
| # Step 2: Pull the template project structure | |
| git clone --depth=1 https://github.com/sglbl/sg_project_template.git temp_template | |
| # Step 3: Copy directories safely (only if they don't exist) | |
| for dir in data src tests docker; do | |
| [ ! -d "$dir" ] && cp -r "temp_template/$dir" "$dir" | |
| done | |
| # Step 4: Copy specific root files safely | |
| # If README.md doesn't exist OR is empty, use the one from the template | |
| if [ ! -s README.md ]; then | |
| cp temp_template/README.md README.md | |
| fi | |
| # Copy .gitignore only if it does not exist | |
| [ ! -f .gitignore ] && cp temp_template/.gitignore .gitignore | |
| # Copy compose.yaml only if it doesn't exist | |
| [ ! -f compose.yaml ] && cp temp_template/compose.yaml compose.yaml | |
| # Step 5: Clean up | |
| rm -rf temp_template | |
| rm -rf data/example_inputs/ | |
| # Step 6: Inform the user | |
| echo "UV project initialized safely with sg template content (existing .gitignore preserved)!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment