{"id":13600086,"url":"https://github.com/ofek/hatch-autorun","last_synced_at":"2025-05-08T20:52:10.612Z","repository":{"id":66163303,"uuid":"529066832","full_name":"ofek/hatch-autorun","owner":"ofek","description":"Hatch build hook plugin to inject code that will automatically run","archived":false,"fork":false,"pushed_at":"2023-06-01T13:57:59.000Z","size":30,"stargazers_count":12,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-01T08:09:06.583Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ofek.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":["ofek"],"custom":["https://ofek.dev/donate/"]}},"created_at":"2022-08-26T00:57:19.000Z","updated_at":"2025-03-27T21:28:40.000Z","dependencies_parsed_at":"2024-01-16T23:26:19.407Z","dependency_job_id":"cbcd3022-74e4-44cc-94da-cbd4b1ae1423","html_url":"https://github.com/ofek/hatch-autorun","commit_stats":{"total_commits":15,"total_committers":2,"mean_commits":7.5,"dds":0.1333333333333333,"last_synced_commit":"46ee999c4bdc243896d33b768d3d5a43c05a5263"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofek%2Fhatch-autorun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofek%2Fhatch-autorun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofek%2Fhatch-autorun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofek%2Fhatch-autorun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ofek","download_url":"https://codeload.github.com/ofek/hatch-autorun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253149345,"owners_count":21861717,"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":[],"created_at":"2024-08-01T18:00:22.713Z","updated_at":"2025-05-08T20:52:10.593Z","avatar_url":"https://github.com/ofek.png","language":"Python","funding_links":["https://github.com/sponsors/ofek","https://ofek.dev/donate/"],"categories":["Plugins"],"sub_categories":[],"readme":"# hatch-autorun\n\n| | |\n| --- | --- |\n| CI/CD | [![CI - Test](https://github.com/ofek/hatch-autorun/actions/workflows/test.yml/badge.svg)](https://github.com/ofek/hatch-autorun/actions/workflows/test.yml) [![CD - Build](https://github.com/ofek/hatch-autorun/actions/workflows/build.yml/badge.svg)](https://github.com/ofek/hatch-autorun/actions/workflows/build.yml) |\n| Package | [![PyPI - Version](https://img.shields.io/pypi/v/hatch-autorun.svg?logo=pypi\u0026label=PyPI\u0026logoColor=gold)](https://pypi.org/project/hatch-autorun/) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hatch-autorun.svg?logo=python\u0026label=Python\u0026logoColor=gold)](https://pypi.org/project/hatch-autorun/) |\n| Meta | [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![code style - black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![types - Mypy](https://img.shields.io/badge/types-Mypy-blue.svg)](https://github.com/ambv/black) [![License - MIT](https://img.shields.io/badge/license-MIT-9400d3.svg)](https://spdx.org/licenses/) [![GitHub Sponsors](https://img.shields.io/github/sponsors/ofek?logo=GitHub%20Sponsors\u0026style=social)](https://github.com/sponsors/ofek) |\n\n-----\n\nThis provides a [build hook](https://hatch.pypa.io/latest/config/build/#build-hooks) plugin for [Hatch](https://github.com/pypa/hatch) that injects code into an installation that will automatically run before the first import.\n\n**Table of Contents**\n\n- [Configuration](#configuration)\n  - [File](#file)\n  - [Code](#code)\n  - [Template](#template)\n- [Conditional execution](#conditional-execution)\n- [License](#license)\n\n## Configuration\n\nThe [build hook plugin](https://hatch.pypa.io/latest/plugins/build-hook/) name is `autorun`.\n\n- ***pyproject.toml***\n\n    ```toml\n    [tool.hatch.build.targets.wheel.hooks.autorun]\n    dependencies = [\"hatch-autorun\"]\n    ```\n\n- ***hatch.toml***\n\n    ```toml\n    [build.targets.wheel.hooks.autorun]\n    dependencies = [\"hatch-autorun\"]\n    ```\n\n### File\n\nYou can select a relative path to a file containing the code with the `file` option:\n\n```toml\n[tool.hatch.build.targets.wheel.hooks.autorun]\nfile = \"resources/code.emded\"\n```\n\n### Code\n\nYou can define the code itself with the `code` option:\n\n```toml\n[tool.hatch.build.targets.wheel.hooks.autorun]\ncode = \"\"\"\nimport coverage\ncoverage.process_startup()\n\"\"\"\n```\n\n### Template\n\nThe current implementation uses a `.pth` file to execute the code. You can set the `.pth` file template with the `template` option, which will be formatted with a `code` variable representing the `code` option or the contents of the file defined by the `file` option. The following shows the default template:\n\n```toml\n[tool.hatch.build.targets.wheel.hooks.autorun]\ntemplate = \"import os, sys;exec({code!r})\"\n```\n\n## Conditional execution\n\nSometimes you'll only want builds to induce auto-run behavior when installed under certain circumstances, like for tests. In such cases, set the `enable-by-default` [option](https://hatch.pypa.io/latest/config/build/#conditional-execution) to `false`:\n\n```toml\n[tool.hatch.build.targets.wheel.hooks.autorun]\nenable-by-default = false\n```\n\nThen when the desired build conditions are met, set the `HATCH_BUILD_HOOK_ENABLE_AUTORUN` [environment variable](https://hatch.pypa.io/latest/config/build/#environment-variables) to `true` or `1`.\n\n## License\n\n`hatch-autorun` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofek%2Fhatch-autorun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fofek%2Fhatch-autorun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofek%2Fhatch-autorun/lists"}