You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

post_gen_project.py 582 B

123456789101112131415161718192021222324
  1. import os
  2. import shutil
  3. from pathlib import Path
  4. import tomli_w
  5. import tomllib
  6. source_dir = os.getcwd()
  7. target_dir = "{{ cookiecutter.__final_destination }}"
  8. shutil.move(source_dir, target_dir)
  9. THIS_FILE_DIR = Path(__file__).parent
  10. # Add the package to the workspace def
  11. workspace_def_path = THIS_FILE_DIR / ".." / ".." / ".." / "pyproject.toml"
  12. with workspace_def_path.open("rb") as f:
  13. config = tomllib.load(f)
  14. config["tool"]["uv"]["sources"]["{{ cookiecutter.package_name }}"] = {"workspace": True}
  15. with workspace_def_path.open("wb") as f:
  16. tomli_w.dump(config, f)