hatch-pyz


Namehatch-pyz JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryHatch plugin for building python zip applications
upload_time2024-07-31 15:11:31
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords hatch plugin pyz
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Hatch PYZ Plugin

This [Hatch](https://hatch.pypa.io/latest/) plugin provides a custom builder for creating
Python [zip applications](https://docs.python.org/3/library/zipapp.html) (zipapps). This is useful for distributing
Python applications as single-file executables, simplifying deployment and distribution.

The plugin generates a zipapp with all the contents bundled into a single executable file. By default, the generated
zipapp includes all necessary dependencies and can be configured to run a specified entry point.

## Features

- **Single-file Executable**: Combines your application and dependencies into a single zip file.
- **Customizable Entry Point**: Specify the main module or script to be executed.
- **Bundled Dependencies**: Include all necessary Python dependencies within your zipapp

## Example

Here’s an example project directory:

```
.
├── pyproject.toml
├── LICENSE.txt
├── README.md
├── src
│   ├── my_module
│   │   ├── __init__.py
│   │   └── main.py
└── tests
    └── test_main.py
```

And a `pyproject.toml` file that looks like this:

```toml
[build-system]
requires = [
    "hatchling",
    "hatch-pyz",
]
build-backend = "hatchling.build"

[project]
name = "my-python-app"
version = "1.0.0"

[tool.hatch.build.targets.pyz]
interpreter = "/usr/bin/env python3"
main = "my_module.main:main"
compressed = true
```

To build the zipapp, run:

```sh
hatch build --target pyz
```

This command will create an executable zipapp named `dist/my_python_app-1.0.0.pyz`.

## Usage

You can run the generated zipapp directly:

```sh
python dist/my_python_app-1.0.0.pyz
```

## Options

| Option                | Type   | Requirement | Default                | Description                                                                                      |
|-----------------------|--------|-------------|------------------------|--------------------------------------------------------------------------------------------------|
| `main`                | `str`  | Required    |                        | Zipapp entry-point in the format "pkg.mod:func"                                                  |
| `interpreter`         | `str`  | Optional    | `/usr/bin/env python3` | Sets the python interpreter shebang for the archive                                              |
| `compressed`          | `bool` | Optional    | `true`                 | If true, files are compressed with the deflate method; otherwise, files are stored uncompressed. |
| `bundle-dependencies` | `bool` | Optional    | `true`                 | if true, pure-python dependencies are bundled in the zipapp archive                              |

## Reproducible Builds

The plugin supports reproducible builds by ensuring consistent metadata and timestamps within the zipapp. This is useful
for verifying that builds produced in different environments are identical. You can control the timestamp used for
reproducible builds via the `SOURCE_DATE_EPOCH` environment variable.

For more details, refer to Hatch’s [Build Configuration](https://hatch.pypa.io/latest/config/build/) documentation.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "hatch-pyz",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "hatch, plugin, pyz",
    "author": null,
    "author_email": "Daniel Copley <djcopley@proton.me>",
    "download_url": "https://files.pythonhosted.org/packages/99/79/ee758dd893a1c8460d1915cef44dba9d4f181cc22a9af9b746fa6b521abf/hatch_pyz-0.2.0.tar.gz",
    "platform": null,
    "description": "# Hatch PYZ Plugin\n\nThis [Hatch](https://hatch.pypa.io/latest/) plugin provides a custom builder for creating\nPython [zip applications](https://docs.python.org/3/library/zipapp.html) (zipapps). This is useful for distributing\nPython applications as single-file executables, simplifying deployment and distribution.\n\nThe plugin generates a zipapp with all the contents bundled into a single executable file. By default, the generated\nzipapp includes all necessary dependencies and can be configured to run a specified entry point.\n\n## Features\n\n- **Single-file Executable**: Combines your application and dependencies into a single zip file.\n- **Customizable Entry Point**: Specify the main module or script to be executed.\n- **Bundled Dependencies**: Include all necessary Python dependencies within your zipapp\n\n## Example\n\nHere\u2019s an example project directory:\n\n```\n.\n\u251c\u2500\u2500 pyproject.toml\n\u251c\u2500\u2500 LICENSE.txt\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 src\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 my_module\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 main.py\n\u2514\u2500\u2500 tests\n    \u2514\u2500\u2500 test_main.py\n```\n\nAnd a `pyproject.toml` file that looks like this:\n\n```toml\n[build-system]\nrequires = [\n    \"hatchling\",\n    \"hatch-pyz\",\n]\nbuild-backend = \"hatchling.build\"\n\n[project]\nname = \"my-python-app\"\nversion = \"1.0.0\"\n\n[tool.hatch.build.targets.pyz]\ninterpreter = \"/usr/bin/env python3\"\nmain = \"my_module.main:main\"\ncompressed = true\n```\n\nTo build the zipapp, run:\n\n```sh\nhatch build --target pyz\n```\n\nThis command will create an executable zipapp named `dist/my_python_app-1.0.0.pyz`.\n\n## Usage\n\nYou can run the generated zipapp directly:\n\n```sh\npython dist/my_python_app-1.0.0.pyz\n```\n\n## Options\n\n| Option                | Type   | Requirement | Default                | Description                                                                                      |\n|-----------------------|--------|-------------|------------------------|--------------------------------------------------------------------------------------------------|\n| `main`                | `str`  | Required    |                        | Zipapp entry-point in the format \"pkg.mod:func\"                                                  |\n| `interpreter`         | `str`  | Optional    | `/usr/bin/env python3` | Sets the python interpreter shebang for the archive                                              |\n| `compressed`          | `bool` | Optional    | `true`                 | If true, files are compressed with the deflate method; otherwise, files are stored uncompressed. |\n| `bundle-dependencies` | `bool` | Optional    | `true`                 | if true, pure-python dependencies are bundled in the zipapp archive                              |\n\n## Reproducible Builds\n\nThe plugin supports reproducible builds by ensuring consistent metadata and timestamps within the zipapp. This is useful\nfor verifying that builds produced in different environments are identical. You can control the timestamp used for\nreproducible builds via the `SOURCE_DATE_EPOCH` environment variable.\n\nFor more details, refer to Hatch\u2019s [Build Configuration](https://hatch.pypa.io/latest/config/build/) documentation.",
    "bugtrack_url": null,
    "license": null,
    "summary": "Hatch plugin for building python zip applications",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/djcopley/hatch-pyz",
        "Issues": "https://github.com/djcopley/hatch-pyz/issues",
        "Repository": "https://github.com/djcopley/hatch-pyz.git"
    },
    "split_keywords": [
        "hatch",
        " plugin",
        " pyz"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "64f10f495e6346a795531544182250242cbc60350918ad313ae8569cadabb3ef",
                "md5": "fd32083594160cf06abf4ae3844ec3c3",
                "sha256": "a0d96f6b1105dbd30d679e634eae097aafca02f597fa39b9278a0c6af52dcb8e"
            },
            "downloads": -1,
            "filename": "hatch_pyz-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fd32083594160cf06abf4ae3844ec3c3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 19176,
            "upload_time": "2024-07-31T15:11:30",
            "upload_time_iso_8601": "2024-07-31T15:11:30.360349Z",
            "url": "https://files.pythonhosted.org/packages/64/f1/0f495e6346a795531544182250242cbc60350918ad313ae8569cadabb3ef/hatch_pyz-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9979ee758dd893a1c8460d1915cef44dba9d4f181cc22a9af9b746fa6b521abf",
                "md5": "50de5970a89fe72efffefdd8ba72f800",
                "sha256": "a119c7967502f611188671a664918da0e76927b1fd80a77f35196db31c61c219"
            },
            "downloads": -1,
            "filename": "hatch_pyz-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "50de5970a89fe72efffefdd8ba72f800",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 19448,
            "upload_time": "2024-07-31T15:11:31",
            "upload_time_iso_8601": "2024-07-31T15:11:31.254897Z",
            "url": "https://files.pythonhosted.org/packages/99/79/ee758dd893a1c8460d1915cef44dba9d4f181cc22a9af9b746fa6b521abf/hatch_pyz-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-31 15:11:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "djcopley",
    "github_project": "hatch-pyz",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "hatch-pyz"
}
        
Elapsed time: 0.52909s