Skip to main content

Concurrent and flexible task runner

Project description

Intro

pypi bld cvg black

Rye is a python task automation tool. It is one of a long list of other projects. The question at this point should be, why not just use one of thos other tools? The answer is that I had a workflow in mind, but couldn’t quite get any of the other tools to do it.

  • Read from a simple config file

  • Maintain a set of virtualenvs for each environment

  • Update those environments when my pyproject.toml or poetry.lock files changed.

  • Run all my tasks in parallel

  • Let tasks share environments where that makes sense (lint and typing?)

  • Work with poetry

  • Allow installing dependencies and the package separately (for Dockerfile caching)

I was trying to set this up without thinking it through a ton, and kept fighting with tox’s built in defaults. No way to install packages without the source code. Using poetry involved some truly ugly hacks. No auto-update of environments, and hard to share environments between tasks. I did like that it depended on a config file with a lot of built in behaviors that you could inherit from!

I looked at stuff like Nox and Invoke- Nox required more programming then tox and still had a bunch of defaults I’d have to figure out how to override. Invoke would have just been working from scratch.

What I really wanted was a makefile- list tasks, specify dependencies for those tasks, and rebuild them when the dependencies change. The actual commands to run should be completely configurable. So Rye was born. It uses pyproject.toml as configuration. It will automatically keep your virtual environments in sync with your config files- no matter the tool you’re using. It has a good set of default behaviors you can pull in. Best of all, every step of the process is completely configurable- if you want!

# pyproject.toml
[tool.rye]
default_tasks = ["test", "lint", "format", "typing"]

[tool.rye."task.pytest"]
target_environments = ["poetry.py37", "poetry.py36"]

[tool.rye."poetry.py36"."task.pytest"]
commands = [["pytest", "tests", "--no-cov"]]

[tool.rye."task.lint"]
target_environments = ["poetry.py37"]
commands = [["pylint", "src/rye", "tests"]]

[tool.rye."task.format"]
target_environments = ["poetry.py37"]
commands = [
        ["black", ".", "--check"],
        ["isort", "-rc", "-tc", "--check-only", "src", "tests"],
]

[tool.rye."task.typing"]
target_environments = ["poetry.py37"]
commands = [
        ["mypy", "src/rye", "--ignore-missing-imports"],
]

OR, YAML

default_tasks:
  - test
  - lint
  - format
  - typing

task.pytest:
  target_environments:
    - poetry.py37
    - poetry.py36

poetry.py36:
  task.pytest:
    commands:
     - ["pytest", "tests", "--no-cov"]

task.lint:
  target_environments:
    - poetry.py37
  commands:
    - ["pylint", "src/rye", "tests"]

task.format:
  target_environments:
    - poetry.py37
  commands:
    - ["black", ".", "--check"]
    - ["isort", "-rc", "-tc", "--check-only", "src", "tests"]

task.typing:
  target_environments:
    - poetry.py37
  commands:
    - ["mypy", "src/rye", "--ignore-missing-imports"]
$ rye
Running tasks- ['poetry.py37', 'TASK poetry.py37#lint', 'TASK poetry.py37#format', 'TASK poetry.py37#typing']
ENV poetry.py37 > Preparing Env
ENV poetry.py37 > Already using interpreter /home/pbecotte/venvs/rye/bin/python3.7
ENV poetry.py37 > Using base prefix '/usr'
ENV poetry.py37 > New python executable in /home/pbecotte/PycharmProjects/rye/.rye/py37/bin/python3.7
ENV poetry.py37 > Also creating executable in /home/pbecotte/PycharmProjects/rye/.rye/py37/bin/python
ENV poetry.py37 > Installing setuptools, pip, wheel...

Read the full documentation at https://rye.readthedocs.io/en/latest/ Or check out the source at https://gitlab.com/pjbecotte/rye

Installation

You can install Rye from pypi-

pip install rye

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

rye-0.6.1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

rye-0.6.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file rye-0.6.1.tar.gz.

File metadata

  • Download URL: rye-0.6.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.5 Linux/4.19.78-coreos

File hashes

Hashes for rye-0.6.1.tar.gz
Algorithm Hash digest
SHA256 c05dfc2f8801f335c5c5db9ceab1ba4c07ce199d4ca899490459a2d57905d340
MD5 1fb2481f27fad4e6772c7be5da18967b
BLAKE2b-256 10f8b823de98e53be2eb5660af44c849bcde1e594394179d9399307fcd2ef9e2

See more details on using hashes here.

File details

Details for the file rye-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: rye-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.5 Linux/4.19.78-coreos

File hashes

Hashes for rye-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 43d27edb4ce7519534b06dd84ee1622fefb919248ed65498e439c8fef4f6ef26
MD5 ef2066736d868de7e841f1451030eb92
BLAKE2b-256 5f60a6d16ed69b2e43992153c8d1c2cbbe0bdcd18c54ee6c0d1fef3257852a06

See more details on using hashes here.

Supported by

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