Skip to content

Minumum copier template for a python script to be `uv tool install`ed.

Notifications You must be signed in to change notification settings

kj-9/uv-tool-min-copier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copier

uv-tool-min-copier

Minimum copier template for a python script to be uv tool installed.

This template is meant to be used with uv.

Usage

To start, just run:

uvx copier copy gh:kj-9/uv-tool-min-copier your-tool-dir

this will prompt you to fill in some values. If you answer Yes to the question Do you want to use Click for command line interface?, copier generates a main.py script with a basic click command line interface.

After filling in the values, copier generates minimum files:

create  .gitignore
create  main.py
create  pyproject.toml

where:

  • main.py is a your python script to be installed as a tool
  • pyproject.toml is a configuration file for uv to install your main.py script as a tool
  • .gitignore is a gitignore file in case you want to manage your tool with git.

Install your tool script

You can run uv tool install specifying the local path to the tool directory:

uv tool install ./your-tool-dir -e

where -e option is for editable install.

If you initialize git repositoriy and uploaded to github, you can install by running:

uv tool install git+https://github.com/{github-username}/{repo-name}

You can even upload main.py and pyproject.toml to a gist to share your tool with others. with gh installed, you can do it like:

# create gist
cd your-tool-dir
gh gist create main.py pyproject.toml --description "your tool description"
# prints created gist url

# install the tool from gist
uv tool install git+https://gist.github.com/{github-username}/{gist-id} # paste printed gist url

you can also list gist id by gh gist list command.

Why I made this template

I was searching for some way to quickly install a single python script in a isolated environment.

uv tool install is great for installing a python script as tools, but it needs a properly set up pyproject.toml file to work.

Someone already asked for a simpler way - just running uv tool install ./script.py (check out the feature request), but it's not ready yet. So I made this template as a workaround until that happens.

About

Minumum copier template for a python script to be `uv tool install`ed.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published