Summary
Hi, I'm trying to scriptify uv to create a workspace automatically for a CMake tree (foolish, I know). I have something working via creating a pyproject.toml by hand, but I'd love to use uv to script this instead. Unfortunately there doesn't seem to be a great way to add existing projects to a workspace. My choices are uv add <project> which doesn't add to tool.uv.workspace (nor flag the member as workspace), or uv init which doesn't have any flag such as --exists. #5388 exists, but doesn't quite cover what I need.
The end result I want is something like this:
[project]
name = "basis_cmake"
requires-python = ">=3.12"
version = "0.0.0"
dependencies = [
"basis-unit-pybind-test",
]
[build-system]
requires = [
"setuptools",
]
build-backend = "setuptools.build_meta"
[tool.setuptools]
py-modules = []
[tool.uv.sources]
basis-unit-pybind-test = { workspace = true }
[tool.uv.workspace]
members = [
"/basis/unit/pybind_test/py",
]
[dependency-groups]
dev = [
"jinja2>=3.1.6",
"jsonschema>=4.24.0",
"pyyaml>=6.0.2",
]
This is almost scriptable, just no way to add to workspace, I have a nearly working example that looks like:
execute_process(COMMAND ${UV} init
--name ${UV_PROJECT_NAME}
--bare
--no-readme
--no-description
--lib
--author-from none
--python ${UV_PYTHON_VERSION}
--build-backend uv
COMMAND_ERROR_IS_FATAL ANY)
execute_process(COMMAND ${UV} version ${UV_PROJECT_VERSION}
COMMAND_ERROR_IS_FATAL ANY)
but I'm forced to instead manually write toml line by line.
If there's support from the uv team I'd be happy to "de-rust" my rust and contribute.
Example
Either:
uv add --workspace <path> could add a project to the workspace with the proper pathing
or:
uv init --existing --bare (or similar) could add an existing project to a workspace without touching anything else
Summary
Hi, I'm trying to scriptify
uvto create a workspace automatically for a CMake tree (foolish, I know). I have something working via creating apyproject.tomlby hand, but I'd love to useuvto script this instead. Unfortunately there doesn't seem to be a great way to add existing projects to a workspace. My choices areuv add <project>which doesn't add totool.uv.workspace(nor flag the member as workspace), oruv initwhich doesn't have any flag such as--exists. #5388 exists, but doesn't quite cover what I need.The end result I want is something like this:
This is almost scriptable, just no way to add to workspace, I have a nearly working example that looks like:
but I'm forced to instead manually write toml line by line.
If there's support from the
uvteam I'd be happy to "de-rust" my rust and contribute.Example
Either:
uv add --workspace <path>could add a project to the workspace with the proper pathingor:
uv init --existing --bare(or similar) could add an existing project to a workspace without touching anything else