Skip to main content

Automate Python project setup and development tasks that are otherwise performed manually.

Project description


usethis

usethis PyPI Version PyPI License PyPI Supported Versions uv CodSpeed codecov GitHub Actions Status

Automate Python project setup and development tasks that are otherwise performed manually.

usethis knows about popular Python tools, workflows and frameworks, and knows how they interact. It can declaratively add and remove tools, configure them, and set up the project for you in a way that won't break your existing configuration and it will make the necessary adjustments to your project configuration files.

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.
  • 📢 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.5.29 (run uv version to check, and uv self update to upgrade).

Then, you can install usethis for the project:

# With uv
$ uv add --dev usethis

# With pip
$ pip install usethis

Alternatively, run in isolation, using uvx or pipx.

🖥️ Command Line Interface

Main commands

Configuration

Information

💡 Example Usage

To use Ruff on a fresh project, run:

$ uvx usethis tool ruff
✔ Writing 'pyproject.toml'.
✔ Adding dependency 'ruff' to the 'dev' group in 'pyproject.toml'.
✔ Adding Ruff config to 'pyproject.toml'.
✔ Enabling Ruff rules 'A', 'C4', 'E4', 'E7', 'E9', 'EM', 'F', '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'.
✔ Enabling 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.12' to default pipeline in 'bitbucket-pipelines.yml'.
✔ Adding 'Test on 3.13' to default pipeline in 'bitbucket-pipelines.yml'.
☐ Run your pipeline via the Bitbucket website.

🖥️ Command Reference

usethis tool

Add a new tool to a Python project, including:

  • declared & installed dependencies with uv add,
  • relevant pyproject.toml configuration,
  • any other relevant directories or tool-bespoke configuration files, and
  • .pre-commit-config.yaml configuration if using pre-commit.

Currently supported tools:

  • usethis tool codespell
  • usethis tool coverage
  • usethis tool deptry
  • usethis tool pre-commit
  • usethis tool pyproject-fmt
  • usethis tool pyproject.toml
  • usethis tool pytest
  • usethis tool requirements.txt
  • usethis tool ruff

Supported options:

  • --remove to remove the tool instead of adding it
  • --offline to disable network access and rely on caches
  • --frozen to leave the virtual environment and lockfile unchanged
  • --quiet to suppress output

usethis ci

Add Continuous Integration pipelines to the project.

Currently supported platforms:

  • usethis ci bitbcuket

Supported options:

  • --remove to remove the CI configuration instead of adding it
  • --offline to disable network access and rely on caches
  • --quiet to suppress output

usethis readme

Add a README.md file to the project.

Supported options:

  • --quiet to suppress output
  • --badges to also add badges to the README.md file

usethis author

Set new author information for the project.

Required options:

  • --name for the new author's name

Other supported options:

  • --email to set the author email address
  • --overwrite to overwrite all existing author information
  • --quiet to suppress output

usethis badge

Add badges to README.md.

Currently supported badges:

  • usethis badge pre-commit
  • usethis badge pypi
  • usethis badge ruff
  • usethis badge usethis
  • usethis badge uv

Supported options:

  • --remove to remove the badge instead of adding it
  • --offline to disable network access and rely on caches
  • --quiet to suppress output

usethis docstyle

Set a docstring style convention for the project, and enforce it with Ruff.

Currently supported docstring styles:

  • usethis docstyle numpy
  • usethis docstyle google
  • usethis docstyle pep257

Supported options:

  • --quiet to suppress output

usethis list

Display a table of all available tools and their current usage status.

usethis show

Show a piece of information about the project.

Currently supported subcommands:

  • usethis show name to show the name of the project.
  • usethis show sonarqube to show appropriate contents of a sonar-projects.properties file for SonarQube analysis.

usethis browse pypi <package>

Display or open the PyPI landing page associated with another project.

Example:

usethis browse pypi numpy

Supported options:

  • --browser to open the link in the browser automatically.

📚 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 which works 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.

One of usethis's strengths is that it can update existing configuration. 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.

Development

This project is at the early stages of development. If you are interested in contributing, please ensure you have a corresponding GitHub Issue open.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

usethis-0.8.1.tar.gz (218.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

usethis-0.8.1-py3-none-any.whl (105.2 kB view details)

Uploaded Python 3

File details

Details for the file usethis-0.8.1.tar.gz.

File metadata

  • Download URL: usethis-0.8.1.tar.gz
  • Upload date:
  • Size: 218.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.14

File hashes

Hashes for usethis-0.8.1.tar.gz
Algorithm Hash digest
SHA256 2c300b8fd56fe3405786883b0bfab7148c46ad853e3d56f361d7433bce6766b6
MD5 c2d4ca269322665d4ebf4cf15079873b
BLAKE2b-256 29984bec4ffb72c5c7b821bd0587dd7850e55c81fb2ac15c2d232cc4cfce5499

See more details on using hashes here.

File details

Details for the file usethis-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: usethis-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 105.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.14

File hashes

Hashes for usethis-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15c5e1393bb72b78836fe60a085c69dc17d9d432fa0cf7fdd0828969e78c7da7
MD5 ac1a0953879ff38cb95adf07db159a8e
BLAKE2b-256 9db5b895ac9a9221fd69400701fafd3efdd1cd43479de4357ff6a5e78362f7f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page