Automate Python project setup and development tasks that are otherwise performed manually.
Project description
usethis
Automate Python project setup and development tasks that are otherwise performed manually.
usethis is a command-line interface to automate the configuration of popular Python tools, workflows, and frameworks. You can use it to declaratively add, remove, and configure tools in an existing project, as well as set up a new project from scratch. It won't break your existing configuration, and ensures all tools work together smoothly.
usethis gives detailed messages about what it is doing (and what you need to do next).
- Output beginning with
✔represents a task which usethis has automated. - Output beginning with
☐represents a task which you need to perform manually. - Output beginning with
ℹgives hints and tips.
Inspired by an R package of the same name, this package brings a similar experience to the Python ecosystem as a CLI tool.
Highlights
- 🧰 First-class support for state-of-the-practice tooling: uv, Ruff, pytest, pre-commit, and many more.
- 🤖 Automatically add and remove tools: declare, install, and configure in one step.
- 🧠 Powerful knowledge of how different tools interact and sensible defaults.
- 🔄 Update existing configuration files automatically.
- 📢 Fully declarative project configuration.
- ⚡ Get started on a new Python project or a new workflow in seconds.
🧭 Installation
First, it is strongly recommended you install the uv package manager: this is a simple, documented process. If you're already using uv, make sure you're using at least
version v0.8.18 (run uv --version to check, and uv self update to upgrade).
You can install usethis directly into the project environment:
# With uv
$ uv add --dev usethis
# With pip
$ pip install usethis
Alternatively, you can also run usethis commands in isolation, using uvx or pipx. For example, to add Ruff to the project:
# With uv
$ uvx usethis tool ruff
# With pipx
$ pipx run usethis tool ruff
📜 Documentation
The usethis documentation is available at usethis.readthedocs.io.
Additionally, the command line reference documentation can be viewed with usethis --help.
🖥️ Command Line Interface
Start a New Project
usethis init— Initialize a new project with recommended defaults.
Manage Tooling
usethis doc— Add/Configure recommended documentation tools (namely, MkDocs).usethis format— Add/Configure recommended formatters (namely, Ruff and pyproject-fmt).usethis lint— Add/Configure recommended linters (namely, Ruff and deptry).usethis spellcheck— Add/Configure recommended spellcheckers (namely, codespell).usethis test— Add/Configure a recommended testing framework (namely, pytest with Coverage.py).usethis ci— Add/Configure a specified CI service.usethis tool— Add/Configure specific tools individually.usethis tool codespell- Use the codespell spellchecker: detect common spelling mistakes.usethis tool deptry- Use the deptry linter: avoid missing or superfluous dependency declarations.usethis tool import-linter- Use Import Linter: enforce a self-imposed architecture on imports.usethis tool pre-commit- Use the pre-commit framework to manage and maintain Git hooks. Note that this will also install all the hooks to Git.usethis tool pyproject-fmt- Use the pyproject-fmt formatter: opinionated formatting of 'pyproject.toml' files.usethis tool ruff- Use Ruff: an extremely fast Python linter and code formatter.usethis tool coverage.py- Use Coverage.py: a code coverage measurement tool.usethis tool pytest- Use the pytest testing framework.usethis tool mkdocs- Use MkDocs: Generate project documentation sites with Markdown.usethis tool pyproject.toml- Use a pyproject.toml file to configure the project.usethis tool requirements.txt- Use a requirements.txt file exported from the uv lockfile.
Manage Configuration
usethis author— Set new author information for the project.usethis docstyle— Set a docstring style convention for the project, and enforce it with Ruff.usethis rule— Set linter rule configuration for specific rules across the project.usethis status— Set the development status of the project (via trove classifiers).
Manage the README
usethis badge— Add badges to the README file.usethis readme— Add a new README file.
Information
usethis list— Display a table of all available tools and their current usage status.usethis version— Display the current version of usethis.usethis browse pypi— Display or open the PyPI landing page associated with another project.usethis show— Show a specific piece of information about the project.
💡 Example Usage
Starting a new project
To start a new project from scratch with a complete set of recommended tooling, simply run
the uvx usethis init command.
Configuring individual tools
You can also configure individual tools one-by-one. For example, to add Ruff on an existing project, run:
$ uvx usethis tool ruff
✔ Adding dependency 'ruff' to the 'dev' group in 'pyproject.toml'.
✔ Adding Ruff config to 'pyproject.toml'.
✔ Selecting Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'F', 'FLY', 'FURB', 'I', 'PLE', 'PLR', 'RUF', 'SIM', 'UP' in 'pyproject.toml'.
✔ Ignoring Ruff rules 'PLR2004', 'SIM108' in 'pyproject.toml'.
☐ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.
☐ Run 'uv run ruff format' to run the Ruff formatter.
For a detailed breakdown of what each line of the output means, there is a detailed explanation available.
As another example, to use pytest, run:
$ uvx usethis tool pytest
✔ Adding dependency 'pytest' to the 'test' group in 'pyproject.toml'.
✔ Adding pytest config to 'pyproject.toml'.
✔ Creating '/tests'.
✔ Writing '/tests/conftest.py'.
✔ Selecting Ruff rule 'PT' in 'pyproject.toml'.
☐ Add test files to the '/tests' directory with the format 'test_*.py'.
☐ Add test functions with the format 'test_*()'.
☐ Run 'uv run pytest' to run the tests.
There are also commands to configure aspects other than tools. For example, to configure Bitbucket Pipelines, run:
$ uvx usethis ci bitbucket
✔ Writing 'bitbucket-pipelines.yml'.
✔ Adding cache 'uv' definition to 'bitbucket-pipelines.yml'.
✔ Adding 'Run Ruff' to default pipeline in 'bitbucket-pipelines.yml'.
✔ Adding 'Test on 3.13' to default pipeline in 'bitbucket-pipelines.yml'.
✔ Adding 'Test on 3.14' to default pipeline in 'bitbucket-pipelines.yml'.
☐ Run your pipeline via the Bitbucket website.
See the CLI Reference for a full list of available commands.
📚 Similar Projects
Not sure if usethis is the exact fit for your project?
The closest match to usethis is PyScaffold. It provides a Command Line Interface to automate the creation of a project from a sensible templated structure.
You could also consider your own hard-coded template. Templating tools such as Cookiecutter and Copier allow you to create static templates with fixed configuration you can use across multiple projects. However, it's not always obvious which template you should use, and many do not use state-of-practice tooling such as pyproject.toml. Also, sometimes a template can overwhelm you with too many unfamiliar tools.
You could consider this template or this one, which work with Copier, or this template which works with Cookiecutter.
[!TIP] You can still use usethis as a part of a templates using hooks for Cookiecutter and tasks for Copier.
If you're using Cookiecutter, then you can update to a latest version of a template using a tool like cruft. Copier has inbuilt support for template updating. Another template-style option which provides updating is jaraco/skeleton, which is a specific, git-based template rather than a general templating system.
If you're not interested in templating automations, then configurator provides a list of useful tooling and configuration to consider for your Python projects. If you're adopting a specific framework like Django, FastAPI, Dagster, or Flask, this list gives options for initializing new projects via CLI.
🚀 Development
Roadmap
Major features planned are:
- Support for automated GitHub Actions workflows (#57), and
- Support for a typechecker (likely ty, #838).
Other features are tracked in the GitHub Issues page.
Contributing
See the CONTRIBUTING.md file.
Acknowledgements
Special thanks to the Posit team for creating the original usethis package for R , which inspired this project.
Additional thanks are due to the maintainers of the various tools which usethis integrates with, especially the people with Astral who created uv.
License
usethis is licensed under the MIT license (LICENSE or https://opensource.org/licenses/MIT)
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in usethis by you, as defined in the Apache License, Version 2.0, (https://www.apache.org/licenses/LICENSE-2.0), shall be licensed under the MIT license, without any additional terms or conditions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file usethis-0.18.0.tar.gz.
File metadata
- Download URL: usethis-0.18.0.tar.gz
- Upload date:
- Size: 386.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92d2980c81c1c67511988323e0e39e58925abfea8b6effb8aa2ba4f08b10c827
|
|
| MD5 |
056305d7dea912c0d000be419aae312e
|
|
| BLAKE2b-256 |
b0fc8a91ba9b4d58eeef0b834a5279f3961e37dea1d19155a0bb56dbf59e3fe5
|
File details
Details for the file usethis-0.18.0-py3-none-any.whl.
File metadata
- Download URL: usethis-0.18.0-py3-none-any.whl
- Upload date:
- Size: 170.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85e6d7f00d81ad241965beaae3ca4d0cd0d343a4bae0c6d3b81d830d4a498eb0
|
|
| MD5 |
ec2b83fc73510b5f36acb64c8a0df7ca
|
|
| BLAKE2b-256 |
570e12e82627f025c6f5db0a55257b6f91f3e3aebdebcdbf47a887eccbb8c313
|