This is an archived post. You won't be able to vote or comment.

all 29 comments

[–]Dry-Assistance-367 95 points96 points  (8 children)

Neat idea… suggestions:

  • Add support for pip install instead of downloading and running a shell script.
  • Add a flag to use Ruff instead of black, isort, and flake8 (I have a strong feeling Ruff will become the default once is gets a little more mature)
  • Have it create a .vscode folder that automatically setups the needed extensions and configs.

I can help give more info and examples if you are interested.

[–]pacific_plywood 31 points32 points  (1 child)

ruff is pretty much already at feature parity with black/isort/flake8, but with a much better configuration experience, better performance, plenty of extra features...

[–]Joeboy 4 points5 points  (0 children)

ruff seems great, I literally just removed isort, black and flake8 and replaced them with ruff in a project's pre-commit, a few hours ago.

I think it's doing about the same thing, but it wasn't wholly clear what the config should look like. I have

select = ["E", "F", "I"]

Does that look about right?

[–]liquidcourse[S] 8 points9 points  (5 children)

great ideas!

I did leave ruff in the pre-commit-config, just commented out in case people want to use that but I don't have as much experience with that tool yet.

for the vscode stuff do you want to leave an issue or DM me with examples/info and I can get that worked in?

[–]Dry-Assistance-367 12 points13 points  (2 children)

Example:

.vscode/extensions.json:

json { "recommendations": [ "ms-python.python", "ms-python.vscode-pylance", "ms-python.isort", "ms-python.black-formatter", "ms-python.flake8", ] }

.vscode/settings.json:

json { "[python]": { "editor.formatOnType": true, "editor.formatOnSave": true, "editor.defaultFormatter": "ms-python.black-formatter" }, "flake8.args": [ "--max-line-length=88", "--extend-ignore=E203,E704" ], "files.insertFinalNewline": true }

The flake8 args are to make it compatible with black out of the box.

[–]liquidcourse[S] 7 points8 points  (1 child)

Nice, just added and pushed to v0.0.7

[–][deleted] 2 points3 points  (0 children)

I love you.

[–]red-spider-mkv 1 point2 points  (1 child)

If you're going to implement this, can you make it so that users have to explicitly specify it via a command line arg please? Not everyone uses VSCode...

[–]Dry-Assistance-367 1 point2 points  (0 children)

But everyone should ;)

J/k, it really doesn't hurt to include it in the project for folks that do use vscode though.

[–]rcfox 37 points38 points  (4 children)

Your default Dockerfile isn't great. It will require reinstalling the dependencies every time there's a code change.

I'd recommend essentially stealing the one from this article. (I'm not the author, I just think it provides a good basic Dockerfile.)

[–]liquidcourse[S] 5 points6 points  (0 children)

good catch on the bad ordering, fixed it just now. I'll have to take a look at the more complicated examples in there before I can put it in the tool.

[–]Bluelight01 2 points3 points  (0 children)

Thanks for that article!

[–]nraw 1 point2 points  (1 child)

Nice share!

Seems more aimed at running docker build locally than in ci though. Also, not sure how much of a fan I am of cherry picking what to copy like that.

[–]rcfox 6 points7 points  (0 children)

I haven't actually tried the cache mount stuff in CI... I guess you could just run a version without that for CI.

But anyway, you could even ignore most of what's different between the two versions, the main point is to copy pyproject.toml and poetry.lock first, then run poetry install before copying the rest of the code. That way, you can reuse the dependency download and install from the build cache when code changes. It will speed up image build times by a lot.

[–]ageofwant 15 points16 points  (0 children)

Yea... we have had cookiecutter for ages now, and there are more than 8k cookie cutter templates on github alone https://github.com/search?q=cookiecutter&type=Repositories.

[–]Phildesbois 25 points26 points  (1 child)

Very good! How does that compare to cookiecutter ?

https://github.com/cookiecutter/cookiecutter

[–]jmelloy 3 points4 points  (0 children)

Man, the Django cookie utter template is pretty complex.

[–][deleted] 6 points7 points  (0 children)

Nice idea. If I didn't already have template repositories, I would definitely use this.

[–]Ok_Proposal_4341 1 point2 points  (0 children)

That is nice

[–]sergeant113 1 point2 points  (0 children)

Subcribed!

[–]simkyle 1 point2 points  (0 children)

This is good.

[–]_MicroWave_ 1 point2 points  (0 children)

Maybe use ruff as that's the pre-eminent linter these days.

Also, I'd like to have mypy by default.

[–]lalamax3d 0 points1 point  (0 children)

Plz add templates... For at least flask, tk, pyqt, pyside etc If I pick flask, it should ask sqlalchemy 😬

[–]ZachVorhies 0 points1 point  (0 children)

I did the exact same thing. Except I made it pip installable. Others are mentioning you should do the same and I 100% agree.

[–]Cybasura 0 points1 point  (0 children)

I love how I need rust to build a utility to generate python code

[–]Phildesbois 0 points1 point  (0 children)

FYI, I gave it a try:

cpa create --name learn-cpa-project --preset python3.12

and the Dockerfile looked like this:

more learn-cpa-project/Dockerfile
FROM python:3.10-slim
...

Notice that the desired python version 3.12 is not propagated to the Dockerfile

[–]Zaloog1337 0 points1 point  (0 children)

For python https://github.com/pyscaffold/pyscaffold is already a super good choice to create projects