Skip to content

Python template v3#26

Merged
albireox merged 41 commits into
mainfrom
python-template-v3
Mar 2, 2026
Merged

Python template v3#26
albireox merged 41 commits into
mainfrom
python-template-v3

Conversation

@albireox

@albireox albireox commented Dec 30, 2025

Copy link
Copy Markdown
Member

I have done some updating of both the template and the style guide, which were over three years old.

This new template (v3) uses copier because cookiecutter seems to have become abandonware. I have remove most of the configuration options and settled for using uv, Ruff, and furo for Sphinx theming since I think that's what we all are using these days and it simplifies the template and the documentation.

The new version of the documentation can be previewed here and the style guide here.

This probably deserves a synchronous code-review.

Closes #25

@albireox albireox requested a review from johndonor3 December 30, 2025 23:40
@albireox albireox self-assigned this Dec 30, 2025
@albireox albireox added this to the python_template v3 milestone Dec 30, 2025
@albireox albireox marked this pull request as ready for review January 7, 2026 19:09
@albireox albireox requested a review from havok2063 as a code owner January 7, 2026 19:09

@johndonor3 johndonor3 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't have any strong opinions here. It seems simpler than the previous template though so that's good!

@havok2063

Copy link
Copy Markdown
Collaborator

I'll take a look at this soon. Maybe by next week's coding time. Regarding copier, is cookiecutter deprecated? it's last commit was 5 days ago. And I know folks are using cruft now to manage project templates. I'm not familiar with copier but I'll take a look.

@albireox

albireox commented Feb 5, 2026

Copy link
Copy Markdown
Member Author

Yes, it seems people still commit to coockiecutter but there hasn't been a release in over a year. I checked the issues at the time and it seemed the main maintainers where MIA, but maybe not. I didn't know cruft but I'm not super attached to copier either. I think any of them are probably good enough for our needs ... including an old version of cookiecutter.

@havok2063

havok2063 commented Feb 13, 2026

Copy link
Copy Markdown
Collaborator

I'm testing this out. When I run uvx copier copy --trust gh:sdss/python_template /Users/brian/Work/git/sdss/test_project I get an error. I get the same thing pointing to my local checkout of the branch. This shouldn't depend on cookiecutter, right?

  File "<template>", line 1, in top-level template code
  File "/Users/brian/.local/share/uv/tools/copier/lib/python3.10/site-packages/jinja2/sandbox.py", line 319, in getattr
    value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'cookiecutter' is undefined

@albireox

Copy link
Copy Markdown
Member Author

I think that's because it's defaulting to the main branch which still has references to cookiecutter since this is not yet merged. Can you try uvx copier copy --trust --vcs-ref python-template-v3 gh:sdss/python_template /Users/brian/Work/git/sdss/test_project?

@havok2063

havok2063 commented Feb 13, 2026

Copy link
Copy Markdown
Collaborator

That worked. I'm surprised it didn't work when it was pointed to the local branch checkout.

One quick question on the uv venv setup: What determines which python version it creates the venv for? It defaults to 12, whether I created it from a different env or not. Are we able to have a question asking which python version to use?

I'll keep playing around with this.

@albireox

Copy link
Copy Markdown
Member Author

I included a question to add a Dockerfile and GitHub action. I tested it and I think it works. Can you have a look at the code and the documentation?

I like the idea of allowing to update projects generated with the template. I will probably require a bit of testing and playing around with the options.

I think an automated conversion tool from v1 and v2 may be difficult to write since those versions had some many forking paths, but maybe we can include some documentation on how to do it manually.

@havok2063

Copy link
Copy Markdown
Collaborator

This is looking good. The Docker addition seems reasonable to me, and the docs look fine. If we're coding today, we can touch base on this. I'd also like to trial and test the project update, but that can also be done outside this PR, if we want.

@albireox

Copy link
Copy Markdown
Member Author

I was travelling this week and wasn't able to call to the coding meeting. Let's discuss it next Thursdays and maybe merge. We can test the update system and confirm it works.

@albireox

Copy link
Copy Markdown
Member Author

I think I addressed the things we discussed today:

  • The questionnaire ask for a minimum Python version which is used in pyproject.toml, the Dockerfile, and to determine the test matrix.
  • The questionnaire asks whether to include framework packages. sdss-access, sdss-tree, and sdssdb are added if so.
  • Added some instructions on how to start using the rendered template to the README.md.

Please have a look and let me know how those look.

@havok2063

Copy link
Copy Markdown
Collaborator

I tested this. I found one issue with this question "🐍 The minimum Python version required to use the project (>= 3.8).
3.13". I specified to use 3.13 but the version of Python that got installed in the venv was 3.14.

Comment thread template/README.md.jinja
Comment thread template/post_copy.py Outdated

@havok2063 havok2063 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good. The min python version now works.

@albireox albireox merged commit 1354dde into main Mar 2, 2026
@albireox albireox deleted the python-template-v3 branch March 2, 2026 19:54
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.

Python Template v3 Wishlist

3 participants