Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ditch makefile in favour of poe tasks in pyproject.toml #261

Merged
merged 1 commit into from
Aug 21, 2020

Conversation

nat-n
Copy link
Contributor

@nat-n nat-n commented Aug 17, 2020

I've been working on a task runner that I think based on the discussion in #129 would be a good fit for this project :)

I also took a stab at #154 to keep things coherent. I'm happy to iterate if there are things we'd prefer to differently.

Poe is a task runner that works well with poetry.

Key features

  • easy, succinct, and flexible toml based config
  • all tasks are executed via poetry run unless already inside a poetry shell
  • for tasks defined as a single command, all additional arguments are passed to that command
  • executing the poe tool without args displays help including available tasks
  • supports tab completion for zsh

Summary of changes in this PR

  1. The new [tool.poe.tasks] section in the pyproject.toml functionally replicates the old make file.
  • Everything is implemented as simple cmd tasks that just basically just run the given content as a subprocess, except clean which is defined as a sequence of the two subtasks.
  • the two subtasks of clean are prefixed with _ which means they're hidden and not directly runnable, though this is not necessary if we think using them directly would be useful
  • removed install task since I believe poetry makes it redundant
  1. Update CONTRIBUTING.md for the poetry + poe based workflow
  2. I noticed tox is mentioned in CONTRIBUTING.md but not configured, so I added it as a dev dependency and added config for it in pyproject.toml
  3. the default version of pip uses pytoml which is deprecated and broken, so to be able to use fuller toml syntax in the pyproject.toml I had to modify the ci script to upgrade pip

Other Features

Note that poe also supports:

  • shell tasks which can use posix shell features such as multiple commands, pipes, boolean operators, background jobs, etc (but require a posix shell to be available so won't always work on windows)
  • script tasks which reference a python function exactly like poetry scripts

It's also possible to define new tasks using other toml syntax forms like:

  • inline tables
    run = { script = "copier.cli:CopierApp.run", help = "run the copier cli"}
  • sub-tables
    [tool.poe.tasks.check-all]
    help = "Run all checks"
    sequence = [
      "check",
      "coverage"
    ]

Try it out:

pip install poethepoet
poe test

@nat-n nat-n changed the title The new [tool.poe.tasks] section and new poetry based workflow are … Ditch makefile in favour of poe the poet Aug 17, 2020
@nat-n nat-n changed the title Ditch makefile in favour of poe the poet Ditch makefile in favour of poe tasks in pyproject.toml Aug 17, 2020
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
CONTRIBUTING.md Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
The new `[tool.poe.tasks]` section and new poetry based workflow are a complete
replacement for the makefile which has also been removed. copier-org#129

Also:
- add devtasks for python functions to be referenced as poe tasks
- update CONTRIBUTING.MD copier-org#154 to keep things coherent
  - remove reference to tox
- update ci to work with more expressive toml syntax (upgrade pip)
  - and use poe tasks in ci
@nat-n nat-n requested a review from yajo August 21, 2020 10:56
@yajo yajo merged commit d949d51 into copier-org:master Aug 21, 2020
@yajo
Copy link
Member

yajo commented Aug 21, 2020

Thanks!

@yajo yajo mentioned this pull request Aug 21, 2020
@yajo yajo added this to the v6.0.0 milestone Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants