Create a new Python package using uv in the specified directory.
- directory_location: The directory path where the new package should be created
- package_name: The name of the Python package to create
- If
directory_locationis not provided, ask the user: "What directory should the package be created in?" - If
package_nameis not provided, ask the user: "What should the package be named?" - Navigate to the specified directory location (create it if it doesn't exist)
- Run
uv init --lib <package_name>in that directory - Add the new package to the project's root
pyproject.tomlfile in the[tool.uv.workspace]members list (create the section if it doesn't exist) - The entry should use the format:
"<relative_path_from_root>/<package_name>"- Convert underscores in package_name to hyphens for the directory name (e.g.,
my_new_packagebecomesmy-new-package) - The path should be relative to the workspace root (e.g., if directory_location is
tools/pythonand package_name ismy_new_package, the path would betools/python/my-new-package)
- Convert underscores in package_name to hyphens for the directory name (e.g.,
- Ensure the new package uses hatchling as the build backend:
[build-system] requires = ["hatchling"] build-backend = "hatchling.build"
- Confirm the package was created successfully and added to the root pyproject.toml
With parameters:
- directory_location:
tools/python - package_name:
my_new_package - This will create the package at
tools/python/my-new-package/and add to rootpyproject.toml:[tool.uv.workspace] members = [ "tools/python/core_github", "tools/python/gcp_gemini", "tools/python/my-new-package", ]
Without parameters:
- Prompt user for directory location
- Prompt user for package name
- Then proceed with creation
- The directory location can be absolute or relative to the workspace root
- If the directory doesn't exist, create it before running
uv init - The package name should follow Python naming conventions (lowercase, underscores allowed)
- The directory name in the workspace members list should use hyphens (e.g.,
my-new-package) - If
[tool.uv.workspace]section doesn't exist in the root pyproject.toml, create it before adding the new package