astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
28.05k stars 806 forks source link

Is it possible to `uv init` a project starting from a template TOML? #9418

Open NicholasPini opened 4 days ago

NicholasPini commented 4 days ago

I am in the process of creating a bunch of projects that all require the same index settings and constraint-dependencies. I was wondering it is possible to create a project with uv init and pass some kind of option to use a file as a template. I tried --config-file passing a uv.toml with the following content:

[[index]]
name = "some_index"
url = "some_url"
explicit = true

[sources]
some_dep = { index = "some_index" }

# see https://github.com/astral-sh/uv/issues/7703
constraint-dependencies = ["kaleido!=0.2.1.post1"]

but it did nothing. Note that using a workspace is not an option for me.

zanieb commented 4 days ago

This isn't possible yet. Why isn't a workspace an option?

ultrapoci commented 3 days ago

I see. I'm not using a workspace because I need all projects to be independent from each other and with their own venv folder.

sglbl commented 2 days ago

Just an idea: (I'm not working for astral) Maybe you can create a gist and use curl to download your default pyproject.toml (or other template files) from a repo.

Example: (change the gist link with yours)

# Optionally after the 'uv init', you can copy the template with this command (or include 'uv init' inside the script)
bash <(curl -s https://gist.githubusercontent.com/sglbl/27d51879413b86a962455fb37594e2d3/raw/setup_template_for_uv.sh)