-
-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathpyproject.py
More file actions
25 lines (19 loc) · 683 Bytes
/
Copy pathpyproject.py
File metadata and controls
25 lines (19 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import json
import tomli
import tomli_w
# Read version from package.json
with open("package.json", "r") as f:
package = json.load(f)
version = package["version"]
description = package["description"]
# Load pyproject.toml
pyproject_path = "pyproject.toml"
with open(pyproject_path, "r") as f:
pyproject = tomli.loads(f.read())
# Assume your project configuration is under the [project] table
pyproject.setdefault("project", {})["version"] = version
pyproject.setdefault("project", {})["description"] = description
# Write back the updated version
with open(pyproject_path, "wb") as f:
tomli_w.dump(pyproject, f)
print(f"Updated pyproject.toml to version {version}")