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.
๐งญ Getting Started
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.6.8 (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
๐ฅ๏ธ 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.
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
To start a new project from scratch with a complete set of recommended tooling, run:
$ uvx usethis init
โ Writing 'pyproject.toml' and initializing project.
โ Writing 'README.md'.
โ Populate 'README.md' to help users understand the project.
โ Adding recommended documentation tools.
โ Run 'uv run mkdocs build' to build the documentation.
โ Run 'uv run mkdocs serve' to serve the documentation locally.
โ Adding recommended linters.
โ Run 'uv run ruff check --fix' to run the Ruff linter with autofixes.
โ Run 'uv run deptry src' to run deptry.
โ Adding recommended formatters.
โ Run 'uv run ruff format' to run the Ruff formatter.
โ Run 'uv run pyproject-fmt pyproject.toml' to run pyproject-fmt.
โ Adding recommended spellcheckers.
โ Run 'uv run codespell' to run the Codespell spellchecker.
โ Adding recommended test frameworks.
โ 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.
โ Run 'uv run pytest --cov' to run your tests with Coverage.py.
To use 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.
To use pytest, run:
$ uvx usethis tool pytest
โ Adding dependency 'pytest' to the 'test' group in 'pyproject.toml'.
โ Adding pytest config to 'pyproject.toml'.
โ Selecting Ruff rule 'PT' in 'pyproject.toml'.
โ Creating '/tests'.
โ Writing '/tests/conftest.py'.
โ 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.
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.
๐ 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.
๐ Development
Roadmap
Major features planned for later in 2025 are:
- Support for automated GitHub Actions workflows (#57),
- Support for a typechecker (likely Pyright, #121), and
Other features are tracked in the GitHub Issues page.
Contributing
See the CONTRIBUTING.md file.
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.16.0.tar.gz.
File metadata
- Download URL: usethis-0.16.0.tar.gz
- Upload date:
- Size: 339.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1f6dcccd0e25b869feb6dcd8e38a9b4f1aa2b0d08bc88caf96c019a27dc2843
|
|
| MD5 |
111789e29f7961fe3bbba9df2d39352a
|
|
| BLAKE2b-256 |
098d5647f5f8132c150b614e233eb6e42a44e4fc0dbdd4f639b3de1ecd470c4c
|
File details
Details for the file usethis-0.16.0-py3-none-any.whl.
File metadata
- Download URL: usethis-0.16.0-py3-none-any.whl
- Upload date:
- Size: 159.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9984f718b254e3273dd67df693b526e7e8e34e3dd789d7dbd53be96be91b95a3
|
|
| MD5 |
46d00b1faf31d73202af1a5e0b36f4f9
|
|
| BLAKE2b-256 |
b5aeccc8951b0228706592327ddf23467496818e8e5e61444731ccc7096355e0
|