Skip to content

Commit 3bdf86c

Browse files
authored
Python tepmates: Update pyproject.toml to include pywrangler dev dependency (#10497)
1 parent cb22f5f commit 3bdf86c

File tree

10 files changed

+593
-17
lines changed

10 files changed

+593
-17
lines changed

.changeset/great-singers-poke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-cloudflare": patch
3+
---
4+
5+
Added workers-py to the pyproject.toml dev requirements

packages/create-cloudflare/src/templates.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,24 @@ export const downloadRemoteTemplate = async (
821821
}
822822
};
823823

824+
function updatePythonPackageName(path: string, projectName: string) {
825+
const pyprojectTomlPath = resolve(path, "pyproject.toml");
826+
const uvLockPath = resolve(path, "uv.lock");
827+
if (!existsSync(pyprojectTomlPath)) {
828+
// Not a python template
829+
return;
830+
}
831+
const s = spinner();
832+
s.start("Updating name in `pyproject.toml`");
833+
let pyprojectTomlContents = readFile(pyprojectTomlPath);
834+
pyprojectTomlContents = pyprojectTomlContents.replace('"TBD"', projectName);
835+
writeFile(pyprojectTomlPath, pyprojectTomlContents);
836+
let uvLockContents = readFile(uvLockPath);
837+
uvLockContents = uvLockContents.replace('"tbd"', projectName.toLowerCase());
838+
writeFile(uvLockPath, uvLockContents);
839+
s.stop(`${brandColor("updated")} ${dim("`pyproject.toml`")}`);
840+
}
841+
824842
export const updatePackageName = async (ctx: C3Context) => {
825843
// Update package.json with project name
826844
const placeholderNames = ["<TBD>", "TBD", ""];
@@ -838,6 +856,7 @@ export const updatePackageName = async (ctx: C3Context) => {
838856

839857
writeJSON(pkgJsonPath, pkgJson);
840858
s.stop(`${brandColor("updated")} ${dim("`package.json`")}`);
859+
updatePythonPackageName(ctx.project.path, ctx.project.name);
841860
};
842861

843862
export const updatePackageScripts = async (ctx: C3Context) => {
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
[project]
2-
name = "<TBD>"
2+
name = "TBD"
33
version = "0.1.0"
44
description = "Add your description here"
55
readme = "README.md"
66
requires-python = ">=3.12"
77
dependencies = [
88
"webtypy>=0.1.7",
99
]
10+
11+
[dependency-groups]
12+
dev = [
13+
"workers-py"
14+
]

packages/create-cloudflare/templates/hello-world-durable-object-with-assets/py/uv.lock

Lines changed: 136 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
[project]
2-
name = "<TBD>"
2+
name = "TBD"
33
version = "0.1.0"
44
description = "Add your description here"
55
readme = "README.md"
66
requires-python = ">=3.12"
77
dependencies = [
88
"webtypy>=0.1.7",
99
]
10+
11+
[dependency-groups]
12+
dev = [
13+
"workers-py"
14+
]

0 commit comments

Comments
 (0)