Skip to content

🌱 Substrate is a modern Copier template for scaffolding Python packages and apps

License

Notifications You must be signed in to change notification settings

superlinear-ai/substrate

Repository files navigation

Open in Dev Containers Open in GitHub Codespaces Copier

🌱 Substrate

A modern Copier template for scaffolding Python packages and apps.

demo.mov

🎁 Features

✨ Using

Tip

You should first install uv to be able to run the commands below.

Create a new Python project

To create a new Python project with this template, run:

uvx copier copy gh:superlinear-ai/substrate path/to/local/repository

Update your Python project

To update your Python project to the latest template version, run:

uvx copier update

Release a new version of your Python project

If you have enabled Conventional Commits, you can create a new version tag and update CHANGELOG.md based on your commit messages with:

git checkout main
cz bump
git push origin main --tags

πŸͺ Migrating from Cookiecutter

Important

This project was formerly known as Poetry Cookiecutter and was based on Poetry and Cookiecutter. We will continue to support the original Cookiecutter-based template side by side with the new Copier-based template. However, we do encourage users to upgrade to the new Copier-based template by following the instructions below.

To migrate a project from Cookiecutter to Copier, follow these steps:

  1. In your project repository, run:

    # Create a new branch
    git checkout -b rescaffold
    
    # Remove files specific to Poetry
    rm -f poetry.lock
    
    # Rescaffold the project without changing src/ and tests/
    uvx copier copy --overwrite --exclude src/ --exclude tests/ gh:superlinear-ai/substrate .
  2. Review the changes to pyproject.toml and reinsert your project's dependencies.

  3. Review the changes to README.md and reinsert your project's documentation.

  4. Commit and push all changes with:

    # Stage all changes
    git add .
    
    # Commit the staged changes
    git commit -m "build: upgrade scaffolding"
    
    # Push the committed changes
    git push origin rescaffold
  5. Create a PR from your branch, review it, and merge it!

Contributing

Prerequisites
  1. Generate an SSH key and add the SSH key to your GitHub account.
  2. Configure SSH to automatically load your SSH keys:
    cat << EOF >> ~/.ssh/config
    
    Host *
      AddKeysToAgent yes
      IgnoreUnknown UseKeychain
      UseKeychain yes
      ForwardAgent yes
    EOF
  3. Install Docker Desktop.
  4. Install VS Code and VS Code's Dev Containers extension. Alternatively, install PyCharm.
  5. Optional: install a Nerd Font such as FiraCode Nerd Font and configure VS Code or PyCharm to use it.
Development environments

The following development environments are supported:

  1. ⭐️ GitHub Codespaces: click on Open in GitHub Codespaces to start developing in your browser.
  2. ⭐️ VS Code Dev Container (with container volume): click on Open in Dev Containers to clone this repository in a container volume and create a Dev Container with VS Code.
  3. ⭐️ uv: clone this repository and run the following from root of the repository:
    # Create and install a virtual environment
    uv sync
    
    # Activate the virtual environment
    source .venv/bin/activate
    
    # Install the pre-commit hooks
    pre-commit install --install-hooks
  4. VS Code Dev Container: clone this repository, open it with VS Code, and run Ctrl/⌘ + ⇧ + P β†’ Dev Containers: Reopen in Container.
  5. PyCharm Dev Container: clone this repository, open it with PyCharm, create a Dev Container with Mount Sources, and configure an existing Python interpreter at /opt/venv/bin/python.
Developing