pyinvoke / invoke

Pythonic task management & command execution.
http://pyinvoke.org
BSD 2-Clause "Simplified" License
4.32k stars 365 forks source link

Running Invoke outside a project's directory (but within a venv) #863

Open LaurentBergeron opened 2 years ago

LaurentBergeron commented 2 years ago

Invokes needs a "tasks" module or package definition, so it makes sense that it should only run from the project's root directory.

My goal is to be able to use Invoke from any directory on my PC. I would need to activate a virtual environment first, of course.

Is this possible?

maldag commented 2 years ago

How do you ensure using the right directory though?

LaurentBergeron commented 2 years ago

I'm not sure on the details, but would it be possible to register the tasks package in the virtual environment?

D3f0 commented 1 year ago

I have faced this issue in the past and shiv comes handy. This is a Python project that lets you package you Python requirements in an executable zipfile.

You will need to package your tasks.py as a Python package and let know the Shiv the --console-script. This works well as long as you don't have non binary modules.