Skip to main content

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

Project description


usethis

PyPI Version PyPI License PyPI Supported Versions uv Ruff CodSpeed 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 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, and pre-commit.
  • Automatically add and remove tools: declare, install, and configure in one step.
  • Powerful knowledge of how different tools interact and sensible defaults.
  • 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 are starting a new project, it is recommended to call uv init --lib to initialize the project directory.

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.

Example Usage

To use Ruff on a fresh project, run:

$ uvx usethis tool ruff
✔ Writing 'pyproject.toml'.
✔ Adding dependency 'ruff' to the 'dev' dependency group.
✔ 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 'ruff check --fix' to run the Ruff linter with autofixes.
☐ Run 'ruff format' to run the Ruff formatter.

To use pytest, run:

$ uvx usethis tool pytest
✔ Adding dependency 'pytest' to the 'test' dependency 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 '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 '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.

Interface

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 coverage
  • usethis tool deptry
  • usethis tool pre-commit
  • usethis tool pyproject-fmt
  • usethis tool pytest
  • usethis tool requirements.txt
  • usethis tool ruff

Supported arguments:

  • --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 badge

Add badges to README.md.

Currently supported badges:

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

Supported arguments:

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

usethis ci

Add Continuous Integration pipelines to the project.

Currently supported platforms:

  • usethis ci bitbcuket

Supported arguments:

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

usethis browse pypi <package>

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

Example:

usethis browse pypi numpy

Supported arguments:

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

Development

This project is at the early stages of development. If you are interested in contributing, please ensure you have a corresponsing 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.5.3.tar.gz (168.5 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.5.3-py3-none-any.whl (71.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for usethis-0.5.3.tar.gz
Algorithm Hash digest
SHA256 aa3be03025cf9870cfef853795c53f12755d0cc653c88dfb32d8ba762ad183eb
MD5 f3ae66e549503d632694cedfda519f40
BLAKE2b-256 79d7fef093cee0d46adf9a91de7c2d471cb73121e064e976546ae681303c90a6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for usethis-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3bf4343a5381d728e14a5ee19467db51cb014b3e713e3b2cff5ac44b8a8f5e05
MD5 38b2bb4c7b3dbf82e89c2058c033d0b8
BLAKE2b-256 8a1392b0886d3131c26682cbdb06c24bec6f6c36fa9a2c7b557e53c2bdd9a2a7

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