News for hackers. Stuff that matters.
Re:I'm Switching to Python and Actually Liking It by simonw on Wednesday July 16, 2025 @02:07PM (#44585206)
> I would like to have a tool that generates the project structure for me, but I haven’t found one that fits me yet.

I recommend cookiecutter for this. I have a few templates I've built with that which I use frequently:

python-lib: https://github.com/simonw/python-lib

click-app: https://github.com/simonw/click-app

datasette-plugin: https://github.com/simonw/datasette-plugin

llm-plugin: https://github.com/simonw/llm-plugin

You can run them like this:

  uvx cookiecutter gh:simonw/python-lib
Re:I'm Switching to Python and Actually Liking It by oezi on Wednesday July 16, 2025 @03:11PM (#44585789)
My take on this (using Ruby) is https://github.com/coezbek/baker

It doesn't copy template repos, but rather creates a list of imperative steps to perform. Steps can be both manual (obtain an API key and store it here) and automatic (run 'uv init'). Markdown syntax, ruby string interpolation and bash.

It came from a deep hate for yml based configs.

Re:I'm Switching to Python and Actually Liking It by timkpaine on Wednesday July 16, 2025 @02:16PM (#44585288)
Copier is the new hotness for this

https://copier.readthedocs.io/en/stable/

Re:I'm Switching to Python and Actually Liking It by mmcnl on Wednesday July 16, 2025 @04:20PM (#44586400)
Am I the only one who actually likes setting up new projects? I don't want to automate that.
Re:I'm Switching to Python and Actually Liking It by serial_dev on Wednesday July 16, 2025 @04:51PM (#44586637)
It depends on your work, though…

If you work at an agency or as a freelancer and you build various similar apps with similar tooling and base setup, being able to scaffold and have them all setup quickly, not having to do it manually and waste hours id important. Similarly, if you work on various small open source packages, you want the tooling to be the same, READMEs look the same, etc, a script or tool to “spit out” the basic structure can be nice.

On the other hand, if you set up the app or larger open source package and you’ll work only on that project for potentially years, setting up a project individually, organically makes a lot of sense.

Re:I'm Switching to Python and Actually Liking It by bshacklett on Saturday July 19, 2025 @08:40AM (#44615029)
I’m legitimately curious about what you enjoy and why. Rewriting boiler plate code and trying to ensure that I get everything right with a process I don’t often execute is the very definition of toil to me.
Re:I'm Switching to Python and Actually Liking It by mmcnl on Sunday July 20, 2025 @05:05AM (#44623242)
It allows me to gain a basic understanding of the fundamentals of my code base.
Re:I'm Switching to Python and Actually Liking It by consumer451 on Wednesday July 16, 2025 @04:37PM (#44586560)
This type of thing seems ripe for building into agentic LLM dev workflows, doesn't it?
Re:I'm Switching to Python and Actually Liking It by didip on Wednesday July 16, 2025 @05:31PM (#44586999)
Honestly, these days, just tell AI to generate one for you.
Re:I'm Switching to Python and Actually Liking It by mrbonner on Wednesday July 16, 2025 @07:23PM (#44587936)
Hmm never heard of this. Thanks for the recommendation.
Re:I'm Switching to Python and Actually Liking It by zahlman on Wednesday July 16, 2025 @09:34PM (#44588822)
I made a small wrapper for cookiecutter, to handle some minimal Git integration (making a repo and doing the first commit) and to match my workflow better (write some initial code first, then transform it into a "project folder" in place): https://github.com/zahlman/cookiebaker

I'm not a huge fan of cookiecutter on aesthetic principles, though. I think it's chosen some needlessly heavyweight dependencies for such a simple task. PyYAML comes with a big chunk of compiled C, while performance is really not going to matter and I'd rather use TOML anyway. I've yet to see a project depending on Rich that uses more than a tiny portion of it; this is no exception. More to the point, Rich brings in the much larger Pygments (for syntax highlighting; most of the bulk is actual syntax definition rules for a variety of programming languages) and you can't disable that. And honestly I'm not a fan of the whole "download other people's templates using an integrated client" model anyway; Requests and its dependencies are pretty bulky, too.

Re:I'm Switching to Python and Actually Liking It by rahimnathwani on Thursday July 17, 2025 @03:05AM (#44590563)
I looked at the click-app repo. If you were creating that today, would you switch from uv to pip?

And to run cookiecutter do you still use pipx, or have you switched to `uv tool install`

Re:I'm Switching to Python and Actually Liking It by simonw on Thursday July 17, 2025 @06:33AM (#44591717)
I'm getting close to switching to uv for my templates.

I use "uvx cookiecutter" myself three days.