{"id":16332897,"url":"https://github.com/eight04/pyxcute","last_synced_at":"2025-11-01T16:30:29.944Z","repository":{"id":57458613,"uuid":"56646166","full_name":"eight04/pyXcute","owner":"eight04","description":"A small task runner inspired by npm scripts","archived":false,"fork":false,"pushed_at":"2024-02-03T17:39:58.000Z","size":87,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-26T14:10:49.963Z","etag":null,"topics":["build-tool","cli","python","python2","python3","task-runner"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eight04.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-20T01:44:26.000Z","updated_at":"2023-10-22T13:36:02.000Z","dependencies_parsed_at":"2024-08-04T04:07:20.361Z","dependency_job_id":"165d2dba-d514-4313-b85d-cbb855d51e75","html_url":"https://github.com/eight04/pyXcute","commit_stats":{"total_commits":99,"total_committers":1,"mean_commits":99.0,"dds":0.0,"last_synced_commit":"5542592f558f967aaffde037d7e27b5f59ea56c5"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eight04%2FpyXcute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eight04%2FpyXcute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eight04%2FpyXcute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eight04%2FpyXcute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eight04","download_url":"https://codeload.github.com/eight04/pyXcute/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239302761,"owners_count":19616598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build-tool","cli","python","python2","python3","task-runner"],"created_at":"2024-10-10T23:33:35.902Z","updated_at":"2025-11-01T16:30:29.896Z","avatar_url":"https://github.com/eight04.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pyXcute\n=======\n\n.. image:: http://readthedocs.org/projects/pyxcute/badge/?version=latest\n  :target: http://pyxcute.readthedocs.io/en/latest/?badge=latest\n  :alt: Documentation Status\n\n.. image:: https://github.com/eight04/pyXcute/actions/workflows/build.yml/badge.svg\n  :target: https://github.com/eight04/pyXcute/actions/workflows/build.yml\n  :alt: .github/workflows/build.yml\n\nA small task runner inspired by npm scripts.\n\nFeatures\n--------\n\n* Use it like setuptools.\n* Chain tasks with ``_pre``, ``_err``, ``_post``, ``_fin`` suffix.\n* A builtin Bump task which can bump version with `semver \u003chttps://github.com/k-bx/python-semver\u003e`_.\n* A small set of cross-platform CLI utils.\n\nInstallation\n------------\n\nFrom `pypi \u003chttps://pypi.org/project/pyxcute/\u003e`__\n\n.. code:: bash\n\n\tpip install pyxcute\n\nUsage\n-----\n\nBasic\n~~~~~\n\nCreate a ``cute.py`` file:\n\n.. code:: python\n\n  from xcute import cute\n  \n  cute(\n    hello = 'echo hello xcute!'\n  )\n\t\nthen run:\n\n.. code:: bash\n\n  $ cute hello\n  \u003e Task: hello\n  \u003e Cmd: echo hello xcute!\n  hello xcute!\n\t\n..\n  \n  If you got a \"not a command\" error, see `How do I make Python scripts executable? \u003chttps://docs.python.org/3/faq/windows.html#how-do-i-make-python-scripts-executable\u003e`_)\n\n\"hello\" is the name of the task that should be executed. If ``cute.py`` is executed without a task name, it will run the \"default\" task.\n\t\nProvide additional arguments:\n\n.. code:: bash\n\n  $ cute hello 123\n  \u003e Task: hello\n  \u003e Cmd: echo hello xcute! 123\n  hello xcute! 123\n\nThe arguments will be passed into the executor, which is ``xcute.Cmd.__call__`` in this case.\n\nTasks\n~~~~~\n\nIt can be a str:\n\n.. code:: python\n\t\n  from xcute import cute\n\n  cute(\n    hello = 'echo hello'\n  )\n\t\nIf it match the name of another task, pyxcute will execute that task:\n\n.. code:: python\n\n  from xcute import cute\n\n  cute(\n    hello = 'world', # execute \"world\" task when \"hello\" task is executed\n    world = 'echo I am world task'\n  )\n\t\nUse a list:\n\n.. code:: python\n\n  from xcute import cute\n  \n  cute(\n    hello = ['echo task1', 'echo task2']\n  )\n  \nUsing an Exception would make the task fail:\n\n.. code:: python\n\n  from xcute import cute\n  cute(\n    hello = Exception(\"error message\")\n  )\n\t\nUse anything that is callable:\n\n.. code:: python\n\n  from xcute import cute\n\n  cute(\n    hello = lambda: print('say hello')\n  )\n  \nActually, when you assign a non-callable value as a task, pyXcute converts it into a callable according to its type.\n\nTask chain\n~~~~~~~~~~\n\t\nDefine the workflow with ``_pre``, ``_err``, ``_post``, ``_fin`` suffix:\n\n.. code:: python\n\n\tfrom xcute import cute\n\t\n\tcute(\n\t\thello_pre = 'echo _pre runs before the task',\n\t\thello = 'echo say hello',\n\t\thello_err = 'echo _err runs if there is an error in task, i.e, an uncaught exception or non-zero return code',\n\t\thello_post = 'echo _post runs after the task if task successfully returned',\n\t\thello_fin = 'echo _fin always runs after _post, _err just like finally'\n\t)\n\t\nWhen a task is executed, the task runner try to execute ``_pre`` task first, then the task itself, then the ``_post`` task. If the task raised an exception, then it goes to the ``_err`` task. ``_fin`` task would be executed whenever the task failed or not.\n\nPseudo code:\n\n.. code:: python\n\n\trun(name + \"_pre\")\n\ttry:\n\t\trun(name, args)\n\texcept Exception:\n\t\trun(name + \"_err\")\n\telse:\n\t\trun(name + \"_post\")\n\tfinally:\n\t\trun(name + \"_fin\")\n\nFormat string\n~~~~~~~~~~~~~\n\npyXcute expands the command string with ``xcute.conf`` dictionary. The expansion is happened at run-time:\n\n.. code:: python\n\n  from xcute import conf, cute\n  \n  conf[\"my_name\"] = \"world\"\n  \n  def change_my_name():\n    conf[\"my_name\"] = \"bad world\"\n\n  cute(\n    hello = [\n      \"echo hello {my_name}\",\n      change_my_name,\n      \"echo hello {my_name}\"\n    ]\n  )\n  \n.. code:: bash\n\n  $ cute hello\n  \u003e Task: hello\n  \u003e Cmd: echo hello world\n  hello world\n  \u003e Cmd: echo hello bad world\n  hello bad world\n  \nCross-platform utils\n--------------------\n\nThere are some CLI utils inspired by `npm-build-tools \u003chttps://www.npmjs.com/package/npm-build-tools\u003e`_, including:\n\n* x-clean\n* x-cat\n* x-copy\n* x-pipe\n\nRun each command with ``-h`` to see the help message.\n\nLive example\n------------\n\t\nCheckout `the cute file \u003chttps://github.com/eight04/pyXcute/blob/master/cute.py\u003e`_ of pyXcute itself.\n\nDocumentation\n-------------\n\nhttp://pyxcute.readthedocs.io/en/latest/\n  \nChangelog\n---------\n\n* 0.8.0 (Feb 4, 2024)\n\n  - Change: drop natsort, implement filename sorting by ourselves.\n\n* 0.7.0 (Oct 22, 2023)\n\n  - Change: now we only test pyxcute on Python\u003e=3.7.\n  - Add: ``cfg`` argument in ``Bump``.\n\n* 0.6.0 (Nov 1, 2019)\n\n  - Add: ``LiveReload``.\n\n* 0.5.2 (Jun 14, 2018)\n\n  - Add: support ``bumper`` argument in ``Bump``.\n  - Add: support Python 3.4. Drop ``subprocess32``.\n\n* 0.5.1 (May 12, 2018)\n\n  - Add: ``conf[\"py\"]`` variable.\n\n* 0.5.0 (May 11, 2018)\n\n  - Add: support Python 2.\n  - Add: documentation.\n  - Add: ``Skip``, ``run_task``, ``task_converter``.\n  - **Add: `Bump` task now update the version number inside `setup.cfg`.**\n  - Fix: ``Cmd`` task failed on Unix due to ``shell=True`` and passing ``args`` as a list.\n  - **Change: the command of `Cmd` is now logged. The log message is also changed.**\n  - **Drop: `noop`.**\n\n* 0.4.1 (Apr 3, 2017)\n\n  - Better description for x-clean.\n  - Fix broken pipe error in x-pipe.\n\n* 0.4.0 (Mar 28, 2017)\n\n  - Switch to setup.cfg.\n  - Add log, exc, noop, Throw, Try.\n  - **Drop Exc, Exit.**\n  - Add ``x-*`` utils.\n\n* 0.3.1 (Mar 23, 2017)\n\n  - Find version from ``{pkg_name}/__pkginfo__.py``.\n\n* 0.3.0 (Jul 21, 2016)\n\n  - Add ``pkg_name`` task.\n  - Add default tasks ``bump``, ``version``.\n\n* 0.2.0 (May 14, 2016)\n\n  - Add _fin tag, which represent ``finally`` clause.\n  - Add Exc and Exit tasks.\n\n* 0.1.2 (Apr 20, 2016)\n\n  - Move _pre out of try clause.\n\n* 0.1.1 (Apr 20, 2016)\n\n  - Bump dev status.\n\n* 0.1.0 (Apr 20, 2016)\n\n  - First release.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feight04%2Fpyxcute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feight04%2Fpyxcute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feight04%2Fpyxcute/lists"}