| 1 |
# -*- coding: UTF-8 -*- |
| 2 |
""" |
| 3 |
Provides "invoke" script when invoke is not installed. |
| 4 |
Note that this approach uses the "tasks/_vendor/invoke.zip" bundle package. |
| 5 |
|
| 6 |
Usage:: |
| 7 |
|
| 8 |
# -- INSTEAD OF: invoke command |
| 9 |
# Show invoke version |
| 10 |
python -m tasks --version |
| 11 |
|
| 12 |
# List all tasks |
| 13 |
python -m tasks -l |
| 14 |
|
| 15 |
.. seealso:: |
| 16 |
|
| 17 |
* http://pyinvoke.org |
| 18 |
* https://github.com/pyinvoke/invoke |
| 19 |
|
| 20 |
|
| 21 |
Examples for Invoke Scripts using the Bundle |
| 22 |
------------------------------------------------------------------------------- |
| 23 |
|
| 24 |
For UNIX like platforms: |
| 25 |
|
| 26 |
.. code-block:: sh |
| 27 |
|
| 28 |
#!/bin/sh |
| 29 |
#!/bin/bash |
| 30 |
# RUN INVOKE: From bundled ZIP file (with Bourne shell/bash script). |
| 31 |
# FILE: invoke.sh (in directory that contains tasks/ directory) |
| 32 |
|
| 33 |
HERE=$(dirname $0) |
| 34 |
export INVOKE_TASKS_USE_VENDOR_BUNDLES="yes" |
| 35 |
|
| 36 |
python ${HERE}/tasks/_vendor/invoke.zip $* |
| 37 |
|
| 38 |
|
| 39 |
For Windows platform: |
| 40 |
|
| 41 |
.. code-block:: bat |
| 42 |
|
| 43 |
@echo off |
| 44 |
REM RUN INVOKE: From bundled ZIP file (with Windows Batchfile). |
| 45 |
REM FILE: invoke.cmd (in directory that contains tasks/ directory) |
| 46 |
|
| 47 |
setlocal |
| 48 |
set HERE=%~dp0 |
| 49 |
set INVOKE_TASKS_USE_VENDOR_BUNDLES="yes" |
| 50 |
if not defined PYTHON set PYTHON=python |
| 51 |
|
| 52 |
%PYTHON% %HERE%tasks/_vendor/invoke.zip "%*" |
| 53 |
""" |
| 54 |
|
| 55 |
from __future__ import absolute_import |
| 56 |
import os |
| 57 |
import sys |
| 58 |
|
| 59 |
# ----------------------------------------------------------------------------- |
| 60 |
# BOOTSTRAP PATH: Use provided vendor bundle if "invoke" is not installed |
| 61 |
# ----------------------------------------------------------------------------- |
| 62 |
# NOTE: tasks/__init__.py performs sys.path setup. |
| 63 |
os.environ["INVOKE_TASKS_USE_VENDOR_BUNDLES"] = "yes" |
| 64 |
|
| 65 |
# ----------------------------------------------------------------------------- |
| 66 |
# AUTO-MAIN: |
| 67 |
# ----------------------------------------------------------------------------- |
| 68 |
if __name__ == "__main__": |
| 69 |
from invoke.main import program |
| 70 |
sys.exit(program.run()) |