Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(copier): enhance copier.yml #681

Open
wants to merge 75 commits into
base: main
Choose a base branch
from
Open

Conversation

34j
Copy link
Contributor

@34j 34j commented Mar 4, 2024

Closes #497

Environmental variables

The following environment variables can be optionally set to save some time and effort:

  • copier.yml
    • PYPACKAGE_TEMPLATE_GITHUB_TOKEN or GITHUB_TOKEN
    • PYPACKAGE_TEMPLATE_GITHUB_USER†
    • PYPACKAGE_TEMPLATE_EMAIL†
    • PYPACKAGE_TEMPLATE_NAME†
  • source/.github/setup-github.bash
    • PYPACKAGE_TEMPLATE_INSTALLATION_IDS (can be empty)

†: If not specified, gets values using github cli.
cli/cli#6096 (comment)

Requires jinja2-env to get enviromental variables.

New Features

  • Create venv and activate it, then install packages
  • Automatically set workflow permissions, branch protection rules and install applications for the repo.
  • Run pre-commit autoupdate
  • Avoid running unnecessary setup commands when running copier update
  • Assume project name from copier command arguments using jinja2-eval
  • Get copyright year using jinja2-time (which depends on arrow)
  • Enable Windows test

Many features depend on each other and are difficult to separate PRs.

Todo

  • update README.md
  • fix sed command error in MacOS
  • test manually
  • understand why only some CI's are git config'd. (because --global flag was not set)
copier copy --trust --vcs-ref refine-copier "gh:34j/pypackage-template"

@34j 34j changed the title feat: enhance copier.yml feat(copier): enhance copier.yml Mar 4, 2024
@34j 34j marked this pull request as ready for review March 5, 2024 06:53
@34j 34j marked this pull request as draft October 22, 2024 08:13
@34j 34j marked this pull request as ready for review October 23, 2024 04:50
@34j
Copy link
Contributor Author

34j commented Oct 23, 2024

@browniebroke Would you please review this if you don't mind? (especially before moving to uv if you are planning to do so)
With this change, most of the steps described in the README will be automated, mainly through the use of the GitHub CLI.

Sample: https://github.com/34j/shift-nth-row-n-steps

$ copier copy --trust --vcs-ref refine-copier "gh:34j/pypackage-template" shift-nth-row-n-steps
🎤 A short description of the project
   Shift Nth row N steps in NumPy / PyTorch / TensorFlow / JAX
🎤 Does the project have a CLI?
   Yes
🎤 Is the project a Django package?
   No
🎤 What's your name?
   34j
🎤 Email address
   [email protected]
🎤 GitHub Username
   34j
🎤 Project Name (human readable version).
   Shift Nth Row N Steps
🎤 Project slug (used for GitHub, PyPI, etc.).
   shift-nth-row-n-steps
🎤 The name of the main Python package (should be a valid Python identifier)
   shift_nth_row_n_steps
🎤 The name of the CLI
   shift-nth-row-n-steps
🎤 The open source license to use
   MIT
🎤 Copyright year(s)
   2024
🎤 Generate documentation?
   Yes
🎤 Setup a virtual environment?
   Yes
🎤 Python version for the virtual environment
   3.11
🎤 Run poetry install after shift_nth_row_n_steps generation?
   Yes
🎤 Create an initial commit with the generated shift_nth_row_n_steps?
   Yes
🎤 Setup GitHub repository (requires gh CLI)?
   Yes
🎤 Setup pre-commit hooks (requires pre-commit)?
   Yes
🎤 Add me as a contributor?
   Yes
🎤 Open with VSCode?
   Yes

Copying from template version 0.0.0.post1042.dev0+83fd54b
    create  .all-contributorsrc
    create  .codespellrc
    create  .editorconfig
    create  .github
    create  .github/CODE_OF_CONDUCT.md
    create  .github/FUNDING.yml
    create  .github/ISSUE_TEMPLATE
    create  .github/ISSUE_TEMPLATE/1-bug-report.yml
    create  .github/ISSUE_TEMPLATE/2-feature-request.yml
    create  .github/ISSUE_TEMPLATE/config.yml
    create  .github/PULL_REQUEST_TEMPLATE.md
    create  .github/labels.toml
    create  .github/setup-github.bash
    create  .github/workflows
    create  .github/workflows/ci.yml
    create  .github/workflows/issue-manager.yml
    create  .github/workflows/labels.yml
    create  .github/workflows/poetry-upgrade.yml
    create  .gitignore
    create  .gitpod.yml
    create  .idea
    create  .idea/watcherTasks.xml
    create  .idea/workspace.xml
    create  .idea/shift-nth-row-n-steps.iml
    create  .pre-commit-config.yaml
    create  .readthedocs.yml
    create  CHANGELOG.md
    create  CONTRIBUTING.md
    create  LICENSE
    create  README.md
    create  commitlint.config.mjs
    create  docs
    create  docs/Makefile
    create  docs/_static
    create  docs/_static/.gitkeep
    create  docs/changelog.md
    create  docs/conf.py
    create  docs/contributing.md
    create  docs/index.md
    create  docs/installation.md
    create  docs/make.bat
    create  docs/usage.md
    create  pyproject.toml
    create  renovate.json
    create  setup.py
    create  src
    create  src/shift_nth_row_n_steps
    create  src/shift_nth_row_n_steps/__init__.py
    create  src/shift_nth_row_n_steps/main.py
    create  src/shift_nth_row_n_steps/py.typed
    create  src/shift_nth_row_n_steps/__main__.py
    create  src/shift_nth_row_n_steps/cli.py
    create  templates
    create  templates/CHANGELOG.md.j2
    create  tests
    create  tests/__init__.py
    create  tests/test_main.py
    create  tests/test_cli.py
    create  tests/test_dunder_main.py
    create  .copier-answers.yml

 > Running task 1 of 12: 
 > Running task 2 of 12: 
 > Running task 3 of 12: python3.11 -m venv venv
 > Running task 4 of 12:  venv/bin/python -m pip install -U pip setuptools wheel && venv/bin/pip install -U poetry pre-commit && venv/bin/python -m poetry install --with dev
Requirement already satisfied: pip in ./venv/lib/python3.11/site-packages (24.0)
Collecting pip
  Using cached pip-24.2-py3-none-any.whl.metadata (3.6 kB)
Requirement already satisfied: setuptools in ./venv/lib/python3.11/site-packages (65.5.0)
Collecting setuptools
  Using cached setuptools-75.2.0-py3-none-any.whl.metadata (6.9 kB)
Collecting wheel
  Using cached wheel-0.44.0-py3-none-any.whl.metadata (2.3 kB)
Using cached pip-24.2-py3-none-any.whl (1.8 MB)
Using cached setuptools-75.2.0-py3-none-any.whl (1.2 MB)
Using cached wheel-0.44.0-py3-none-any.whl (67 kB)
Installing collected packages: wheel, setuptools, pip
  Attempting uninstall: setuptools
    Found existing installation: setuptools 65.5.0
    Uninstalling setuptools-65.5.0:
      Successfully uninstalled setuptools-65.5.0
  Attempting uninstall: pip
    Found existing installation: pip 24.0
    Uninstalling pip-24.0:
      Successfully uninstalled pip-24.0
Successfully installed pip-24.2 setuptools-75.2.0 wheel-0.44.0
Collecting poetry
  Using cached poetry-1.8.4-py3-none-any.whl.metadata (6.9 kB)
Collecting pre-commit
  Using cached pre_commit-4.0.1-py2.py3-none-any.whl.metadata (1.3 kB)
Collecting build<2.0.0,>=1.0.3 (from poetry)
  Using cached build-1.2.2.post1-py3-none-any.whl.metadata (6.5 kB)
Collecting cachecontrol<0.15.0,>=0.14.0 (from cachecontrol[filecache]<0.15.0,>=0.14.0->poetry)
  Using cached cachecontrol-0.14.0-py3-none-any.whl.metadata (3.1 kB)
Collecting cleo<3.0.0,>=2.1.0 (from poetry)
  Using cached cleo-2.1.0-py3-none-any.whl.metadata (12 kB)
Collecting crashtest<0.5.0,>=0.4.1 (from poetry)
  Using cached crashtest-0.4.1-py3-none-any.whl.metadata (1.1 kB)
Collecting dulwich<0.22.0,>=0.21.2 (from poetry)
  Using cached dulwich-0.21.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.3 kB)
Collecting fastjsonschema<3.0.0,>=2.18.0 (from poetry)
  Using cached fastjsonschema-2.20.0-py3-none-any.whl.metadata (2.1 kB)
Collecting installer<0.8.0,>=0.7.0 (from poetry)
  Using cached installer-0.7.0-py3-none-any.whl.metadata (936 bytes)
Collecting keyring<25.0.0,>=24.0.0 (from poetry)
  Using cached keyring-24.3.1-py3-none-any.whl.metadata (20 kB)
Collecting packaging>=23.1 (from poetry)
  Using cached packaging-24.1-py3-none-any.whl.metadata (3.2 kB)
Collecting pexpect<5.0.0,>=4.7.0 (from poetry)
  Using cached pexpect-4.9.0-py2.py3-none-any.whl.metadata (2.5 kB)
Collecting pkginfo<2.0,>=1.10 (from poetry)
  Using cached pkginfo-1.11.2-py3-none-any.whl.metadata (11 kB)
Collecting platformdirs<5,>=3.0.0 (from poetry)
  Using cached platformdirs-4.3.6-py3-none-any.whl.metadata (11 kB)
Collecting poetry-core==1.9.1 (from poetry)
  Using cached poetry_core-1.9.1-py3-none-any.whl.metadata (3.5 kB)
Collecting poetry-plugin-export<2.0.0,>=1.6.0 (from poetry)
  Using cached poetry_plugin_export-1.8.0-py3-none-any.whl.metadata (2.8 kB)
Collecting pyproject-hooks<2.0.0,>=1.0.0 (from poetry)
  Using cached pyproject_hooks-1.2.0-py3-none-any.whl.metadata (1.3 kB)
Collecting requests<3.0,>=2.26 (from poetry)
  Using cached requests-2.32.3-py3-none-any.whl.metadata (4.6 kB)
Collecting requests-toolbelt<2.0.0,>=1.0.0 (from poetry)
  Using cached requests_toolbelt-1.0.0-py2.py3-none-any.whl.metadata (14 kB)
Collecting shellingham<2.0,>=1.5 (from poetry)
  Using cached shellingham-1.5.4-py2.py3-none-any.whl.metadata (3.5 kB)
Collecting tomlkit<1.0.0,>=0.11.4 (from poetry)
  Using cached tomlkit-0.13.2-py3-none-any.whl.metadata (2.7 kB)
Collecting trove-classifiers>=2022.5.19 (from poetry)
  Using cached trove_classifiers-2024.10.21.16-py3-none-any.whl.metadata (2.2 kB)
Collecting virtualenv<21.0.0,>=20.26.6 (from poetry)
  Using cached virtualenv-20.27.0-py3-none-any.whl.metadata (4.5 kB)
Collecting cfgv>=2.0.0 (from pre-commit)
  Using cached cfgv-3.4.0-py2.py3-none-any.whl.metadata (8.5 kB)
Collecting identify>=1.0.0 (from pre-commit)
  Using cached identify-2.6.1-py2.py3-none-any.whl.metadata (4.4 kB)
Collecting nodeenv>=0.11.1 (from pre-commit)
  Using cached nodeenv-1.9.1-py2.py3-none-any.whl.metadata (21 kB)
Collecting pyyaml>=5.1 (from pre-commit)
  Using cached PyYAML-6.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.1 kB)
Collecting msgpack<2.0.0,>=0.5.2 (from cachecontrol<0.15.0,>=0.14.0->cachecontrol[filecache]<0.15.0,>=0.14.0->poetry)
  Using cached msgpack-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (8.4 kB)
Collecting filelock>=3.8.0 (from cachecontrol[filecache]<0.15.0,>=0.14.0->poetry)
  Using cached filelock-3.16.1-py3-none-any.whl.metadata (2.9 kB)
Collecting rapidfuzz<4.0.0,>=3.0.0 (from cleo<3.0.0,>=2.1.0->poetry)
  Using cached rapidfuzz-3.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (11 kB)
Collecting urllib3>=1.25 (from dulwich<0.22.0,>=0.21.2->poetry)
  Using cached urllib3-2.2.3-py3-none-any.whl.metadata (6.5 kB)
Collecting jaraco.classes (from keyring<25.0.0,>=24.0.0->poetry)
  Using cached jaraco.classes-3.4.0-py3-none-any.whl.metadata (2.6 kB)
Collecting importlib-metadata>=4.11.4 (from keyring<25.0.0,>=24.0.0->poetry)
  Using cached importlib_metadata-8.5.0-py3-none-any.whl.metadata (4.8 kB)
Collecting SecretStorage>=3.2 (from keyring<25.0.0,>=24.0.0->poetry)
  Using cached SecretStorage-3.3.3-py3-none-any.whl.metadata (4.0 kB)
Collecting jeepney>=0.4.2 (from keyring<25.0.0,>=24.0.0->poetry)
  Using cached jeepney-0.8.0-py3-none-any.whl.metadata (1.3 kB)
Collecting ptyprocess>=0.5 (from pexpect<5.0.0,>=4.7.0->poetry)
  Using cached ptyprocess-0.7.0-py2.py3-none-any.whl.metadata (1.3 kB)
Collecting charset-normalizer<4,>=2 (from requests<3.0,>=2.26->poetry)
  Using cached charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (34 kB)
Collecting idna<4,>=2.5 (from requests<3.0,>=2.26->poetry)
  Using cached idna-3.10-py3-none-any.whl.metadata (10 kB)
Collecting certifi>=2017.4.17 (from requests<3.0,>=2.26->poetry)
  Using cached certifi-2024.8.30-py3-none-any.whl.metadata (2.2 kB)
Collecting distlib<1,>=0.3.7 (from virtualenv<21.0.0,>=20.26.6->poetry)
  Using cached distlib-0.3.9-py2.py3-none-any.whl.metadata (5.2 kB)
Collecting zipp>=3.20 (from importlib-metadata>=4.11.4->keyring<25.0.0,>=24.0.0->poetry)
  Using cached zipp-3.20.2-py3-none-any.whl.metadata (3.7 kB)
Collecting cryptography>=2.0 (from SecretStorage>=3.2->keyring<25.0.0,>=24.0.0->poetry)
  Using cached cryptography-43.0.3-cp39-abi3-manylinux_2_28_x86_64.whl.metadata (5.4 kB)
Collecting more-itertools (from jaraco.classes->keyring<25.0.0,>=24.0.0->poetry)
  Using cached more_itertools-10.5.0-py3-none-any.whl.metadata (36 kB)
Collecting cffi>=1.12 (from cryptography>=2.0->SecretStorage>=3.2->keyring<25.0.0,>=24.0.0->poetry)
  Using cached cffi-1.17.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.5 kB)
Collecting pycparser (from cffi>=1.12->cryptography>=2.0->SecretStorage>=3.2->keyring<25.0.0,>=24.0.0->poetry)
  Using cached pycparser-2.22-py3-none-any.whl.metadata (943 bytes)
Using cached poetry-1.8.4-py3-none-any.whl (249 kB)
Using cached poetry_core-1.9.1-py3-none-any.whl (309 kB)
Using cached pre_commit-4.0.1-py2.py3-none-any.whl (218 kB)
Using cached build-1.2.2.post1-py3-none-any.whl (22 kB)
Using cached cachecontrol-0.14.0-py3-none-any.whl (22 kB)
Using cached cfgv-3.4.0-py2.py3-none-any.whl (7.2 kB)
Using cached cleo-2.1.0-py3-none-any.whl (78 kB)
Using cached crashtest-0.4.1-py3-none-any.whl (7.6 kB)
Using cached dulwich-0.21.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (516 kB)
Using cached fastjsonschema-2.20.0-py3-none-any.whl (23 kB)
Using cached identify-2.6.1-py2.py3-none-any.whl (98 kB)
Using cached installer-0.7.0-py3-none-any.whl (453 kB)
Using cached keyring-24.3.1-py3-none-any.whl (38 kB)
Using cached nodeenv-1.9.1-py2.py3-none-any.whl (22 kB)
Using cached packaging-24.1-py3-none-any.whl (53 kB)
Using cached pexpect-4.9.0-py2.py3-none-any.whl (63 kB)
Using cached pkginfo-1.11.2-py3-none-any.whl (31 kB)
Using cached platformdirs-4.3.6-py3-none-any.whl (18 kB)
Using cached poetry_plugin_export-1.8.0-py3-none-any.whl (10 kB)
Using cached pyproject_hooks-1.2.0-py3-none-any.whl (10 kB)
Using cached PyYAML-6.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (762 kB)
Using cached requests-2.32.3-py3-none-any.whl (64 kB)
Using cached requests_toolbelt-1.0.0-py2.py3-none-any.whl (54 kB)
Using cached shellingham-1.5.4-py2.py3-none-any.whl (9.8 kB)
Using cached tomlkit-0.13.2-py3-none-any.whl (37 kB)
Using cached trove_classifiers-2024.10.21.16-py3-none-any.whl (13 kB)
Using cached virtualenv-20.27.0-py3-none-any.whl (3.1 MB)
Using cached certifi-2024.8.30-py3-none-any.whl (167 kB)
Using cached charset_normalizer-3.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)
Using cached distlib-0.3.9-py2.py3-none-any.whl (468 kB)
Using cached filelock-3.16.1-py3-none-any.whl (16 kB)
Using cached idna-3.10-py3-none-any.whl (70 kB)
Using cached importlib_metadata-8.5.0-py3-none-any.whl (26 kB)
Using cached jeepney-0.8.0-py3-none-any.whl (48 kB)
Using cached msgpack-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (403 kB)
Using cached ptyprocess-0.7.0-py2.py3-none-any.whl (13 kB)
Using cached rapidfuzz-3.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB)
Using cached SecretStorage-3.3.3-py3-none-any.whl (15 kB)
Using cached urllib3-2.2.3-py3-none-any.whl (126 kB)
Using cached jaraco.classes-3.4.0-py3-none-any.whl (6.8 kB)
Using cached cryptography-43.0.3-cp39-abi3-manylinux_2_28_x86_64.whl (4.0 MB)
Using cached zipp-3.20.2-py3-none-any.whl (9.2 kB)
Using cached more_itertools-10.5.0-py3-none-any.whl (60 kB)
Using cached cffi-1.17.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (467 kB)
Using cached pycparser-2.22-py3-none-any.whl (117 kB)
Installing collected packages: trove-classifiers, ptyprocess, fastjsonschema, distlib, zipp, urllib3, tomlkit, shellingham, rapidfuzz, pyyaml, pyproject-hooks, pycparser, poetry-core, platformdirs, pkginfo, pexpect, packaging, nodeenv, msgpack, more-itertools, jeepney, installer, idna, identify, filelock, crashtest, charset-normalizer, cfgv, certifi, virtualenv, requests, jaraco.classes, importlib-metadata, dulwich, cleo, cffi, build, requests-toolbelt, pre-commit, cryptography, cachecontrol, SecretStorage, keyring, poetry-plugin-export, poetry
Successfully installed SecretStorage-3.3.3 build-1.2.2.post1 cachecontrol-0.14.0 certifi-2024.8.30 cffi-1.17.1 cfgv-3.4.0 charset-normalizer-3.4.0 cleo-2.1.0 crashtest-0.4.1 cryptography-43.0.3 distlib-0.3.9 dulwich-0.21.7 fastjsonschema-2.20.0 filelock-3.16.1 identify-2.6.1 idna-3.10 importlib-metadata-8.5.0 installer-0.7.0 jaraco.classes-3.4.0 jeepney-0.8.0 keyring-24.3.1 more-itertools-10.5.0 msgpack-1.1.0 nodeenv-1.9.1 packaging-24.1 pexpect-4.9.0 pkginfo-1.11.2 platformdirs-4.3.6 poetry-1.8.4 poetry-core-1.9.1 poetry-plugin-export-1.8.0 pre-commit-4.0.1 ptyprocess-0.7.0 pycparser-2.22 pyproject-hooks-1.2.0 pyyaml-6.0.2 rapidfuzz-3.10.0 requests-2.32.3 requests-toolbelt-1.0.0 shellingham-1.5.4 tomlkit-0.13.2 trove-classifiers-2024.10.21.16 urllib3-2.2.3 virtualenv-20.27.0 zipp-3.20.2
Updating dependencies
Resolving dependencies... (0.8s)

No dependencies to install or update

Writing lock file

Installing the current project: shift-nth-row-n-steps (0.0.0)
 > Running task 5 of 12: git init && git add --all
Initialized empty Git repository in /home/z/shift-nth-row-n-steps/.git/
 > Running task 6 of 12:  venv/bin/pre-commit autoupdate && venv/bin/pre-commit install && venv/bin/pre-commit run -a || true
Configuration has been migrated.
[https://github.com/commitizen-tools/commitizen] already up to date!
[https://github.com/pre-commit/pre-commit-hooks] already up to date!
[https://github.com/tox-dev/pyproject-fmt] already up to date!
[https://github.com/python-poetry/poetry] updating 1.8.4 -> 1.8.0
[https://github.com/pre-commit/mirrors-prettier] updating v3.1.0 -> v4.0.0-alpha.8
[https://github.com/astral-sh/ruff-pre-commit] already up to date!
[https://github.com/codespell-project/codespell] already up to date!
[https://github.com/pre-commit/mirrors-mypy] already up to date!
pre-commit installed at .git/hooks/pre-commit
debug statements (python)................................................Passed
check builtin type constructor use.......................................Passed
check for case conflicts.................................................Passed
check docstring is first.................................................Passed
check json...............................................................Passed
check toml...............................................................Passed
check xml................................................................Passed
check yaml...............................................................Passed
detect private key.......................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
pyproject-fmt........................................(no files to check)Skipped
poetry-check.........................................(no files to check)Skipped
prettier.................................................................Passed
ruff.....................................................................Passed
ruff-format..............................................................Passed
codespell................................................................Passed
mypy.....................................................................Passed
 > Running task 7 of 12: git add --all && git commit -m "chore: initial commit"
debug statements (python)................................................Passed
check builtin type constructor use.......................................Passed
check for case conflicts.................................................Passed
check docstring is first.................................................Passed
check json...............................................................Passed
check toml...............................................................Passed
check xml................................................................Passed
check yaml...............................................................Passed
detect private key.......................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
pyproject-fmt........................................(no files to check)Skipped
poetry-check.........................................(no files to check)Skipped
prettier.................................................................@browniebroke Passed
ruff.....................................................................Passed
ruff-format..............................................................Passed
codespell................................................................Passed
mypy.....................................................................Passed
[main (root-commit) a7bc171] chore: initial commit
 51 files changed, 2882 insertions(+)
 create mode 100644 .all-contributorsrc
 create mode 100644 .codespellrc
 create mode 100644 .copier-answers.yml
 create mode 100644 .editorconfig
 create mode 100644 .github/CODE_OF_CONDUCT.md
 create mode 100644 .github/FUNDING.yml
 create mode 100644 .github/ISSUE_TEMPLATE/1-bug-report.yml
 create mode 100644 .github/ISSUE_TEMPLATE/2-feature-request.yml
 create mode 100644 .github/ISSUE_TEMPLATE/config.yml
 create mode 100644 .github/PULL_REQUEST_TEMPLATE.md
 create mode 100644 .github/labels.toml
 create mode 100644 .github/setup-github.bash
 create mode 100644 .github/workflows/ci.yml
 create mode 100644 .github/workflows/issue-manager.yml
 create mode 100644 .github/workflows/labels.yml
 create mode 100644 .github/workflows/poetry-upgrade.yml
 create mode 100644 .gitignore
 create mode 100644 .gitpod.yml
 create mode 100644 .idea/shift-nth-row-n-steps.iml
 create mode 100644 .idea/watcherTasks.xml
 create mode 100644 .idea/workspace.xml
 create mode 100644 .pre-commit-config.yaml
 create mode 100644 .readthedocs.yml
 create mode 100644 CHANGELOG.md
 create mode 100644 CONTRIBUTING.md
 create mode 100644 LICENSE
 create mode 100644 README.md
 create mode 100644 commitlint.config.mjs
 create mode 100644 docs/Makefile
 create mode 100644 docs/_static/.gitkeep
 create mode 100644 docs/changelog.md
 create mode 100644 docs/conf.py
 create mode 100644 docs/contributing.md
 create mode 100644 docs/index.md
 create mode 100644 docs/installation.md
 create mode 100644 docs/make.bat
 create mode 100644 docs/usage.md
 create mode 100644 poetry.lock
 create mode 100644 pyproject.toml
 create mode 100644 renovate.json
 create mode 100644 setup.py
 create mode 100644 src/shift_nth_row_n_steps/__init__.py
 create mode 100644 src/shift_nth_row_n_steps/__main__.py
 create mode 100644 src/shift_nth_row_n_steps/cli.py
 create mode 100644 src/shift_nth_row_n_steps/main.py
 create mode 100644 src/shift_nth_row_n_steps/py.typed
 create mode 100644 templates/CHANGELOG.md.j2
 create mode 100644 tests/__init__.py
 create mode 100644 tests/test_cli.py
 create mode 100644 tests/test_dunder_main.py
 create mode 100644 tests/test_main.py
 > Running task 8 of 12:  venv/bin/python -c "from pathlib import Path; import re; p = Path('.copier-answers.yml'); p.write_text(re.sub(r'((?:setup_venv|run_poetry_install|initial_commit|setup_github|setup_pre_commit|add_me_as_contributor): )true', r'\g<1>false', p.read_text()))"
 > Running task 9 of 12: git add --all && git commit -m "chore: update .copier-answers.yml to avoid running commands again"
debug statements (python)............................(no files to check)Skipped
check builtin type constructor use...................(no files to check)Skipped
check for case conflicts.............................(no files to check)Skipped
check docstring is first.............................(no files to check)Skipped
check json...........................................(no files to check)Skipped
check toml...........................................(no files to check)Skipped
check xml............................................(no files to check)Skipped
check yaml...........................................(no files to check)Skipped
detect private key...................................(no files to check)Skipped
fix end of files.....................................(no files to check)Skipped
trim trailing whitespace.............................(no files to check)Skipped
pyproject-fmt........................................(no files to check)Skipped
poetry-check.........................................(no files to check)Skipped
prettier.............................................(no files to check)Skipped
ruff.................................................(no files to check)Skipped
ruff-format..........................................(no files to check)Skipped
codespell............................................(no files to check)Skipped
mypy.................................................(no files to check)Skipped
[main 5e8ac5a] chore: update .copier-answers.yml to avoid running commands again
 1 file changed, 6 insertions(+), 6 deletions(-)
 > Running task 10 of 12: npx all-contributors-cli add 34j code,ideas,doc
 > Running task 11 of 12: bash .github/setup-github.bash 34j shift-nth-row-n-steps "Shift Nth row N steps in NumPy / PyTorch / TensorFlow / JAX"
Setting up GitHub repository 34j/shift-nth-row-n-steps, description: Shift Nth row N steps in NumPy / PyTorch / TensorFlow / JAX
✓ Created repository 34j/shift-nth-row-n-steps on GitHub
  https://github.com/34j/shift-nth-row-n-steps
✓ Added remote https://github.com/34j/shift-nth-row-n-steps.git
Enumerating objects: 68, done.
Counting objects: 100% (68/68), done.
Delta compression using up to 32 threads
Compressing objects: 100% (59/59), done.
Writing objects: 100% (68/68), 54.69 KiB | 10.94 MiB/s, done.
Total 68 (delta 6), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (6/6), done.
To https://github.com/34j/shift-nth-row-n-steps.git
 * [new branch]      HEAD -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
✓ Pushed commits to https://github.com/34j/shift-nth-row-n-steps.git
✓ Edited repository 34j/shift-nth-row-n-steps
Setting GitHub secrets (using GITHUB_TOKEN)
✓ Set Actions secret PYPACKAGE_TEMPLATE_GITHUB_TOKEN for 34j/shift-nth-row-n-steps
Setting branch protection rules for 34j/shift-nth-row-n-steps:main
{
  "url": "https://api.github.com/repos/34j/shift-nth-row-n-steps/branches/main/protection",
  "required_signatures": {
    "url": "https://api.github.com/repos/34j/shift-nth-row-n-steps/branches/main/protection/required_signatures",
    "enabled": false
  },
  "enforce_admins": {
    "url": "https://api.github.com/repos/34j/shift-nth-row-n-steps/branches/main/protection/enforce_admins",
    "enabled": false
  },
  "required_linear_history": {
    "enabled": false
  },
  "allow_force_pushes": {
    "enabled": true
  },
  "allow_deletions": {
    "enabled": true
  },
  "block_creations": {
    "enabled": false
  },
  "required_conversation_resolution": {
    "enabled": false
  },
  "lock_branch": {
    "enabled": false
  },
  "allow_fork_syncing": {
    "enabled": false
  }
}
Installing GitHub Apps xxxxxxxx,xxxxxxxx
 > Running task 12 of 12: code .

Copy link
Owner

@browniebroke browniebroke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but that's way too big of a change for me.

- uses: actions/setup-python@v5
id: setup-python
with:
python-version: "3.11"
- run: pipx install copier
- run: pipx inject copier jinja2-eval jinja2-env jinja2-time arrow
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it work if folks don't have these installed? That seems like a significant change in workflow for users

Copy link
Contributor Author

@34j 34j Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copier raises an error if not installed. There is no workaround. I suppose that if you are interested in jinja2-time, injecting is inevitable anyway. Of course, these are only necessary when using copier.

copier.yml Outdated

email:
type: str
help: "Email address"
placeholder: "[email protected]"
default: '{{ ("exec(''from subprocess import run; import json; j = json.loads(run([\"gh\",\"api\",\"user/emails\"], capture_output=True).stdout)'') or [k for k in j if k[''primary'']][0][''email'']" | eval) | env("PYPACKAGE_TEMPLATE_EMAIL") }}'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the person doesn't have gh installed? I think it's fully optional right now, but that seem to make it required.

Copy link
Contributor Author

@34j 34j Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed to work even if gh is not installed using contextlib.suppress, confirmed that it works

copier.yml Outdated
type: bool
help: "Is the project a Django package?"
default: no
default: '{{ ("exec(''from subprocess import run; import json; j = json.loads(run([\"gh\",\"api\",\"user\"], capture_output=True).stdout)'') or j[''login'']" | eval) | env("PYPACKAGE_TEMPLATE_GITHUB_USER") }}'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, adding a hard dependency to save a few keystrokes

Comment on lines +78 to +81
setup_venv:
type: bool
help: "Does the project have a CLI?"
default: no
help: "Setup a virtual environment?"
default: yes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why bother with venv creation? Thsi template uses Poetry, which manages venv automatically. Would be similar if/when it's moved to uv...

Copy link
Contributor Author

@34j 34j Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to think that for advanced users like you, this should rather be considered a temporal virtual environment just to support all operations up to pushing to GitHub, in case pre-commit and poetry are not installed globally, rather than used to develop projects. No matter which tool is used, I believe the virtual environment created would be equivalent if the setting corresponds to "poetry config virtualenvs.in-project true". Of course you can switch Python versions using poetry env etc. It is quite difficult to write cross-platform commands to access the right python using something like poetry shell. The change is extremely painful (as jinja2 forgets variables frequently), but it is certainly possible to use poetry env info -p to call python in the virtual environment without using the poetry shell. In that case, the user would need to install poetry beforehand.

Comment on lines +83 to +87
venv_version:
type: str
help: "The name of the CLI"
default: "{{ project_slug }}"
when: "{{ has_cli }}"
help: "Python version for the virtual environment"
default: "3.11"
when: "{{ setup_venv }}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a hard block, but FWIW I personally see little value in this question...

copier.yml Outdated
Comment on lines 118 to 121
open_with_vscode:
type: bool
help: "Open with VSCode?"
default: no
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't use VSCode, so no. I'm not interested in making this question specific to a given IDE/editor either, but would be interesting if there is convention in env variable to open in the user's preferred editor: https://unix.stackexchange.com/q/4859

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use $VISUAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improvements for copier.yml
2 participants