Questions tagged [pyinvoke]

Python Invoke is a Python tool and library for task execution, similar to Make or Rake.

Invoke existed originally in Fabric 1.x, and it was extracted out after realizing that it made sense as dedicated tool dedicated to task execution that can also be used as a library.

http://www.pyinvoke.org

37 questions
17
votes
2 answers

Python Invoke - Can't find any collection named 'tasks'!

I did the getting started on Python Invoke from invoke import task @task def build(): print("Building!") The expected output is $ invoke build Building! However, my output is $ invoke build Can't find any collection named 'tasks'! I have…
Asoul
  • 996
  • 1
  • 10
  • 22
10
votes
2 answers

How to use a variable number of arguments in pyinvoke

I would like to use a variable number of arguments in a task for pyinvoke. Like so: from invoke import task @task(help={'out_file:': 'Name of the output file.', 'in_files': 'List of the input files.'}) def pdf_combine(out_file,…
Killwas
  • 103
  • 7
7
votes
2 answers

How do i make pyinvoke use python3?

This question is similar to this one but not quite the same. I have python2.7 and python3.5 installed. I can run scripts using either of them from the command line. My current default "python" is python2. I have a python3 script using pyinvoke that…
Nicholas Tulach
  • 1,023
  • 3
  • 12
  • 35
6
votes
1 answer

Can I add a conditional "pre" task to a pyinvoke task?

pyinvoke supports so called "pre" tasks, that have to be executed before running a task: @task(pre=[required_precondition]) def mytask(c, param1=False): pass Is it possible to add a condition to a "pre" task (i.e. run "required_precondition"…
mrh1997
  • 922
  • 7
  • 18
4
votes
0 answers

ModuleNotFoundError with python transformers library despite it being installed in venv when running invoke task

Title. I'm currently trying to run import a module that uses transformers but it throws the following error: (tf2venv) dante@dante-Inspiron-5570:~/projects/classification$ inv process-pdf test.pdf Using TensorFlow…
4
votes
0 answers

What is the difference between using Python's Invoke vs a regular shell script?

I've been reading a bit about Python's PyInvoke, and my interest was piqued. Essentially, I want to have allow users to utilize a software without needing to go through the tedious task of installing all dependencies. I was think of making a simple…
John Lexus
  • 3,576
  • 3
  • 15
  • 33
3
votes
1 answer

PyInvoke execution task from other python script

I'm reading pyinvoke docs and I'm searching any easy way to execute invoke tasks from other python script. Tasks don't have method run so I can't import them and simply .run(). I found that there is Executor Class but how I understand I need to…
Krzysieqq
  • 921
  • 7
  • 10
3
votes
2 answers

Using multiple decorators with Pyinvoke @task decorator

I am attempting to create a decorator, and use it alongside the pyinvoke @task decorator. See: def extract_config(func): print func def func_wrapper(cfg=None): config = read_invoke_config(cfg) return func(**config) …
Alpenglow
  • 173
  • 1
  • 17
3
votes
2 answers

How to change the current working directory

Using invoke, how can I change the directory that the run call operates in? In Fabric, one would from fabric.context_managers import lcd with lcd('foo'): local('do') to run do in the foo directory, but I can't find a similar import in pyinvoke.
leech
  • 8,293
  • 7
  • 62
  • 78
2
votes
1 answer

Include pyinvoke tasks from collection definitions in multiple directroies

I have a monorepo and I want to have tasks at different levels (in the directory tree). When I run pyinvoke at a deeper level, I want to have access to the tasks in the higher levels + the tasks in the current level. They can (should) be in…
Robert J Berger
  • 890
  • 9
  • 12
2
votes
1 answer

PyInvoke: how to handle stdin of a task?

The below code is purely for illustration purposes. I want to write a task like this: >echo '11da33' | inv remove-number da How can I work with stdin inside of an invoke task? I checked the documentation but found nothing
kharandziuk
  • 12,020
  • 17
  • 63
  • 121
2
votes
1 answer

How to get the project directory in pyinvoke?

In my pyinvoke task library, I would like to know the project directory so I can derive default locations for the directories like src, test, and dist. Currently, the only way I can see to do this is from context.config._project_prefix. Is there a…
davidrmcharles
  • 1,923
  • 2
  • 20
  • 33
2
votes
1 answer

Run unittest.main() from a python invoke task

I am trying to run some unittest tests via a Python Invoke library, but my poor knowledge of Python prevents me from doing so. This is the sample code I have: my_tests.py import unittest class TestStringMethods(unittest.TestCase): def…
slo
  • 55
  • 1
  • 3
2
votes
1 answer

Save data in the context variable in Python's invoke library (pyinvoke)

Using the Invoke library for Python, I want to run a setup task first which saves some values in the context variable that all of the following tasks then can read and use. The documentation is quite short on that topic, however, it states that A…
Dirk
  • 9,381
  • 17
  • 70
  • 98
2
votes
1 answer

Why does "import ctask as task" fail in pyinvoke?

When I try to use ctask as defined in the getting started guide, it fails with the following error: >>> from invoke import ctask as task Traceback (most recent call last): File "", line 1, in ImportError: cannot import name…
Jason Martens
  • 1,305
  • 11
  • 22
1
2 3