From 4be183fabc957a17cee61594bc1b45f355c47f5c Mon Sep 17 00:00:00 2001 From: Nicolas Fripp Date: Thu, 7 Aug 2025 11:30:53 -0300 Subject: [PATCH 1/6] script added --- scripts/rename-template.py | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 scripts/rename-template.py diff --git a/scripts/rename-template.py b/scripts/rename-template.py new file mode 100644 index 0000000..4997885 --- /dev/null +++ b/scripts/rename-template.py @@ -0,0 +1,39 @@ +# in all files under src, replace the string "mi-proyecto" with the name of the project, coming from params. + +import argparse +import glob +import os + +paths_to_replace = [ + "src/**/*.py", + "tests/**/*.py", + "Dockerfile", + ".env.example", + ".devcontainer/**/*", + "uv.lock", + "pyproject.toml", + ".github/workflows/python-app.yml", + "scripts/**/*", + "scripts/**/*", + +] + +def rename_template(new_project_name: str): + # get all files, ecl + for path in paths_to_replace: + files = glob.glob(path, recursive=True) + for file in files: + if not os.path.isfile(file) or file.__contains__("rename-template.py"): + continue + with open(file, "r") as f: + content = f.read() + content = content.replace("python-template", new_project_name) + content = content.replace("python_template", new_project_name.replace("-", "_")) + with open(file, "w") as f: + f.write(content) + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("new_project_name", type=str) + args = parser.parse_args() + rename_template(args.new_project_name) From 459288aaf890fd11bd905ccc0a59e74f87da1f53 Mon Sep 17 00:00:00 2001 From: Nicolas Fripp Date: Thu, 7 Aug 2025 13:31:56 -0300 Subject: [PATCH 2/6] template fixed --- scripts/rename-template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/rename-template.py b/scripts/rename-template.py index 4997885..1598907 100644 --- a/scripts/rename-template.py +++ b/scripts/rename-template.py @@ -15,7 +15,7 @@ ".github/workflows/python-app.yml", "scripts/**/*", "scripts/**/*", - + ".env" ] def rename_template(new_project_name: str): From 9c2e183b648dd48a400d026e5d56646fe21161db Mon Sep 17 00:00:00 2001 From: Nicolas Fripp Date: Thu, 7 Aug 2025 13:34:36 -0300 Subject: [PATCH 3/6] remove comments --- scripts/rename-template.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/rename-template.py b/scripts/rename-template.py index 1598907..9e3f66f 100644 --- a/scripts/rename-template.py +++ b/scripts/rename-template.py @@ -1,4 +1,3 @@ -# in all files under src, replace the string "mi-proyecto" with the name of the project, coming from params. import argparse import glob @@ -19,7 +18,6 @@ ] def rename_template(new_project_name: str): - # get all files, ecl for path in paths_to_replace: files = glob.glob(path, recursive=True) for file in files: From 394d75aac5fcae44367d22536973adb5730a102c Mon Sep 17 00:00:00 2001 From: Nicolas Fripp Date: Thu, 7 Aug 2025 13:52:34 -0300 Subject: [PATCH 4/6] readme modified --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 66988e3..df8567d 100755 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ ## Project setup The only things you need are [Docker](https://docs.docker.com/engine/install/), [Docker Compose](https://docs.docker.com/compose/install/), and a code editor with devcontainer support like [Visual Studio Code](https://code.visualstudio.com/download). Once you open the template with VS Code, it will recommend that you install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) if you don’t have it already. Then, a pop-up will appear to reopen the template in the devcontainer, or you can use `Ctrl / Cmd + shift + P` -> `Dev Containers: Open Folder in Container…`. Remember to add the `.env` file at the root folder; you can use `.env.example` as a reference. +Then you need to run `uv run python scripts/rename-template.py ` in order to modify the name of the project. And that's it, everything is ready to use. By using the VS Code terminal with `Ctrl / Cmd + J`, you'll be inside the container to run any command or start the server with `uvicorn src.main:app --reload --host 0.0.0.0 --port 8000`. From 20cfe239588fa11eec9f9c9a8f59601e1e31473d Mon Sep 17 00:00:00 2001 From: Nicolas Fripp Date: Thu, 7 Aug 2025 13:57:33 -0300 Subject: [PATCH 5/6] more changes in readme --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index df8567d..8e524b1 100755 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ ## Project setup The only things you need are [Docker](https://docs.docker.com/engine/install/), [Docker Compose](https://docs.docker.com/compose/install/), and a code editor with devcontainer support like [Visual Studio Code](https://code.visualstudio.com/download). Once you open the template with VS Code, it will recommend that you install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) if you don’t have it already. Then, a pop-up will appear to reopen the template in the devcontainer, or you can use `Ctrl / Cmd + shift + P` -> `Dev Containers: Open Folder in Container…`. Remember to add the `.env` file at the root folder; you can use `.env.example` as a reference. -Then you need to run `uv run python scripts/rename-template.py ` in order to modify the name of the project. And that's it, everything is ready to use. By using the VS Code terminal with `Ctrl / Cmd + J`, you'll be inside the container to run any command or start the server with `uvicorn src.main:app --reload --host 0.0.0.0 --port 8000`. @@ -31,11 +30,7 @@ For making code changes, installing `pre-commit` is necessary (see section [Code ### Customization -The project's name (`python-template`) can be edited following next steps: - -1. Edit project's name in the [pyproject.toml](pyproject.toml) file -2. Set `PROJECT_NAME` env variable to be exactly the same as project's name in pyproject.toml. Ensure VSCode has this -variable loaded, otherwise the dev container might fail or not work as expected. You can open VScode with from cmd with: +The project's name (`python-template`), you need to run `uv run python scripts/rename-template.py ` ```bash PROJECT_NAME=your-awesome-project code From e0f41bc1f55b30b873f066176b939fab9a0c2e6d Mon Sep 17 00:00:00 2001 From: Nicolas Fripp Date: Thu, 7 Aug 2025 13:58:33 -0300 Subject: [PATCH 6/6] more changes in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e524b1..df8b20d 100755 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ For making code changes, installing `pre-commit` is necessary (see section [Code ### Customization -The project's name (`python-template`), you need to run `uv run python scripts/rename-template.py ` +To rename the project `python-template`, you need to run `uv run python scripts/rename-template.py ` ```bash PROJECT_NAME=your-awesome-project code