Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
key: ${{ runner.os }}-pre-commit-${{ matrix.python-version }}
- name: Install dependencies
run: |
uv pip install --system cookiecutter build
uv sync --frozen
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git config --global init.defaultBranch main
Expand All @@ -36,25 +37,22 @@ jobs:
GIT=$(which git)
sudo chmod -x ${GIT}
cookiecutter -v --no-input -f -o /tmp/cookie_python . project_slug=foo1-bar minimum_python_version=${{ matrix.python-version }}
uv pip install --system /tmp/cookie_python/foo1-bar
python -c "import foo1_bar; print(foo1_bar.__version__)"
uv pip uninstall --system foo1-bar
cd /tmp/cookie_python/foo1-bar
uv sync --frozen
uv run python -c "import foo1_bar; print(foo1_bar.__version__)"
sudo chmod +x ${GIT}
- name: with git only
run: |
cookiecutter -v --no-input -f -o /tmp/cookie_python . project_slug=foo2 minimum_python_version=${{ matrix.python-version }}
uv pip install --system /tmp/cookie_python/foo2
uv pip uninstall --system foo2
cd /tmp/cookie_python/foo2
uv sync --frozen
- name: with git and pre-commit
run: |
uv pip install --system pre-commit
cookiecutter -v --no-input -f -o /tmp/cookie_python . project_slug=foo3 minimum_python_version=${{ matrix.python-version }}
uv pip install --system /tmp/cookie_python/foo3
uv pip uninstall --system foo3
cd /tmp/cookie_python/foo3
python -c "import tests"
uv pip install --system .[dev]
make -C docs html
uv sync --frozen --extra dev
uv run python -c "import tests"
uv run make -C docs html
- name: upload generated projects
uses: actions/upload-artifact@v4
with:
Expand Down
11 changes: 11 additions & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
import subprocess


def _uv_lock():
try:
subprocess.check_output(["uv", "lock"], stderr=subprocess.STDOUT)
except (PermissionError, FileNotFoundError) as e:
print(f"uv not found, skipping lock file generation: {e}")
except subprocess.CalledProcessError as e:
print(f"uv lock failed: {e.output.decode()}")


def _precommit():
def _error(e):
print(e.output)
Expand Down Expand Up @@ -51,6 +60,8 @@ def _git_init():


if __name__ == "__main__":
_uv_lock()

if "{{ cookiecutter.create_git_repository|lower }}" != "yes":
sys.exit(0)

Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[project]
name = "python-cookiecutter"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = [
"cookiecutter",
"pre-commit",
]

[tool.uv]
package = false
Loading
Loading