Skip to content

Commit

Permalink
add template readme and make the setup.sh script insanely cool
Browse files Browse the repository at this point in the history
  • Loading branch information
ulfaslak committed Oct 8, 2024
1 parent 6d735c8 commit 15bbd23
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 19 deletions.
37 changes: 37 additions & 0 deletions .README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# package_name

*Description of the project/package. Make it super easy for people to understand what it does. Add links to external resources like Notion, SOWs, etc.if needed.*

## Features

*Bullet form list of the most important features of the project/package.*

## Usage

*How to use `package_name`. Include examples and code snippets.*

## Project Structure

- `package_name/`: Contains the package logic
- `tests/`: Contains tests for the package
- `exploration/`: Contains exploratory code for testing new features

## Development

This package has been created with [pymc-labs/project-starter](https://github.com/pymc-labs/project-starter). It features:

- 📦 **`pixi`** for dependency and environment management.
- 🧹 **`pre-commit`** for formatting, spellcheck, etc. If everyone uses the same standard formatting, then PRs won't have flaky formatting updates that distract from the actual contribution. Reviewing code will be much easier.
- 🏷️ **`beartype`** for runtime type checking. If you know what's going in and out of functions just by reading the code, then it's easier to debug. And if these types are even enforced at runtime with tools like `beartype`, then there's a whole class of bugs that can never enter your code.
- 🧪 **`pytest`** for testing. Meanwhile, with `beartype` handling type checks, tests do not have to assert types, and can merely focus on whether the actual logic works.
- 🔄 **Github Actions** for running the pre-commit checks on each PR, automated testing and dependency management (dependabot).

### Prerequisites

- Python 3.11 or higher
- [Pixi package manager](https://pixi.sh/latest/)

### Get started

1. Run `pixi install` to install the dependencies.
2. Run `pixi r test` to run the tests.
40 changes: 21 additions & 19 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

echo "Please enter the new package name:"
echo -e "\033[1mPlease enter the new package name:\033[0m"
read name

# Validate the package name
Expand All @@ -16,7 +16,9 @@ fi

# Rename the package
current_name="package_name"
echo "Renaming package from $current_name to $name..."
echo -e "\n\033[1m== Renaming Package ==\033[0m"
echo -e " From: \033[36m$current_name\033[0m"
echo -e " To: \033[36m$name\033[0m\n"

find . -type f -not -path '*/\.*' -exec sh -c '
if file -b --mime-type "$1" | grep -q "^text/"; then
Expand All @@ -26,50 +28,50 @@ find . -type f -not -path '*/\.*' -exec sh -c '

if [ -d "$current_name" ]; then
mv "$current_name" "$name"
echo -e " \033[32m✔ Directory renamed successfully\033[0m"
else
echo "Warning: Directory '$current_name' not found. Skipping directory rename."
echo -e " \033[33m⚠ Warning: Directory '$current_name' not found. Skipping directory rename.\033[0m"
fi

echo "Package renamed successfully."
echo -e " \033[32m✔ Package renamed successfully.\033[0m"

# Ask if the user wants to run "pixi install"
echo "Do you want to run 'pixi install'? (y/n)"
read run_pixi
echo -e "\n\033[1m== Additional Setup ==\033[0m"
read -p "Do you want to run 'pixi install'? (y/n): " run_pixi

if [ "$run_pixi" = "y" ] || [ "$run_pixi" = "Y" ]; then
echo "Running 'pixi install'..."
echo -e "\n Running 'pixi install'..."
pixi install
echo "'pixi install' completed."
echo -e " \033[32m✔ 'pixi install' completed.\033[0m"

# Ask if the user wants to install pre-commit hooks
echo "Do you want to install pre-commit hooks? (y/n)"
read install_hooks
read -p "Do you want to install pre-commit hooks? (y/n): " install_hooks

if [ "$install_hooks" = "y" ] || [ "$install_hooks" = "Y" ]; then
echo "Installing pre-commit hooks..."
echo -e "\n Installing pre-commit hooks..."
pixi r pre-commit install
echo "Pre-commit hooks installed successfully."
echo -e " \033[32m✔ Pre-commit hooks installed successfully.\033[0m"
fi
fi



# Delete existing README.md and rename .README.md
echo "Updating README files..."
echo -e "\n\033[1m== Updating README ==\033[0m"
if [ -f "README.md" ]; then
rm README.md
echo "Existing README.md deleted."
echo -e " \033[32m✔ Existing README.md deleted.\033[0m"
fi

if [ -f ".README.md" ]; then
mv .README.md README.md
echo ".README.md renamed to README.md."
echo -e " \033[32m✔ .README.md renamed to README.md.\033[0m"
else
echo "Warning: .README.md not found. No changes made to README files."
echo -e " \033[33m⚠ Warning: .README.md not found. No changes made to README files.\033[0m"
fi

echo -e "\n\033[1m== Setup Complete ==\033[0m"

# Remove this setup script
script_path=$(realpath "$0")
rm "$script_path"

echo "Setup script removed."
echo -e " \033[32m🚀 Setup script launched into oblivion.\033[0m"

0 comments on commit 15bbd23

Please sign in to comment.