cosmofy


Namecosmofy JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryCosmopolitan Python Bundler
upload_time2024-09-18 19:12:38
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords cosmopolitan bundler
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cosmofy: Cosmopolitan Python Bundler

<p align="center">
  <a href="https://github.com/metaist/cosmofy/actions/workflows/ci.yaml"><img alt="Build" src="https://img.shields.io/github/actions/workflow/status/metaist/cosmofy/.github/workflows/ci.yaml?branch=main&logo=github"/></a>
  <a href="https://pypi.org/project/cosmofy"><img alt="PyPI" src="https://img.shields.io/pypi/v/cosmofy.svg?color=blue" /></a>
  <a href="https://pypi.org/project/cosmofy"><img alt="Supported Python Versions" src="https://img.shields.io/pypi/pyversions/cosmofy" /></a>
</p>

[Cosmopolitan apps](https://github.com/jart/cosmopolitan) are cross-platform binary files that work natively on Linux, macOS, and Windows. `cosmofy` is a tool to bundle your python project into a portable Cosmopolitan app.

## Install

macOS / Linux:

```bash
dest=~/.local/bin/cosmofy
curl -sSz $dest -o $dest -L https://github.com/metaist/cosmofy/releases/latest/download/cosmofy
chmod +x $dest
```

Windows: (PowerShell instructions coming soon)

## Examples

```bash
# bundle a single script
cosmofy examples/single-file/file-with-main.py

# bundle a directory
cosmofy examples/pkg-nested

# add additional args, change output path
cosmofy src/cosmofy --args '-m cosmofy --cosmo' --output dist/cosmofy

# add self-updater
cosmofy src/cosmofy \
  --args '-m cosmofy --cosmo' \
  --release-url https://github.com/metaist/cosmofy/releases/latest/download/cosmofy
```

## Usage

<!--[[[cog
from cosmofy.args import USAGE
doc = USAGE.replace('COSMOFY_CACHE_DIR=/home/lev/.cache/cosmofy', 'COSMOFY_CACHE_DIR=~/.cache/cosmofy')
cog.outl(f"\n```text\n{doc}```\n")
]]]-->

```text
cosmofy: Cosmopolitan Python Bundler

USAGE

  cosmofy
    [--help] [--version] [--debug] [--dry-run] [--self-update]
    [--python-url URL] [--cache PATH] [--clone]
    [--output PATH] [--args STRING]
    <add>... [--exclude GLOB]... [--remove GLOB]...
    [--receipt PATH] [--receipt-url URL] [--release-url URL]
    [--release-version STRING]

GENERAL

  -h, --help        Show this help message and exit.
  --version         Show program version and exit.
  --debug           Show debug messages.
  -n, --dry-run     Do not make any file system changes.
  --self-update     Update `cosmofy` to the latest version.

CACHE

  --python-url URL
    URL from which to download Cosmopolitan Python.
    [default: https://cosmo.zip/pub/cosmos/bin/python]
    [env: COSMOFY_PYTHON_URL=None]

  --cache PATH
    Directory in which to cache Cosmopolitan Python downloads.
    Use `false` or `0` to disable caching.
    [default: ~/.cache/cosmofy]
    [env: COSMOFY_CACHE_DIR=None]

  --clone
    Obtain python by cloning `cosmofy` and removing itself instead of
    downloading it from `--python-url`.

OUTPUT

  -o PATH, --output PATH
    Path to output file.
    [default: `<main_module>.com`]

    `<main_module>` is the first module with a `__main__.py` or file with an
    `if __name__ == "__main__"` line.

FILES

  --args STRING
    Cosmopolitan Python arguments.
    [default: `"-m <main_module>"`]

  --add GLOB, <add>
    At least one glob-like patterns to add. Folders are recursively added.
    Files ending in `.py` will be compiled.

  -x GLOB, --exclude GLOB
    One or more glob-like patterns to exclude from being added.

    Common things to exclude are egg files and python cache:
    $ cosmofy src -x "**/*.egg-info/*" -x "**/__pycache__/*"

  --rm GLOB, --remove GLOB
    One or more glob-like patters to remove from the output.

    Common things to remove are `pip`, terminal info, and SSL certs:
    $ cosmofy src/my_module --rm 'usr/*' --rm 'Lib/site-packages/pip/*'

SELF-UPDATER

  Specifying any of the options below will add `cosmofy.updater`
  to make the resulting app capable of updating itself. You
  must supply at least `--receipt-url` or `--release-url`.

  In addition to building the app, there will be a second output
  which is a JSON file (called a receipt) that needs to be uploaded
  together with the app.

  When the app runs, the updater first checks to see if it was called with `--self-update`. If it wasn't, execution continues as normal.
  If it was, the updater checks the published receipt to see if there is a
  newer version of the app and downloads it, if appropriate.

  NOTE: The updater will alter `--args` so that it gets called first.
  It supports most Python Command Line interface options (like `-m`).
  For a full list see: https://github.com/metaist/cosmofy#supported-python-cli

  --receipt PATH
    Set the path for the JSON receipt.
    [default: `<output>.json`]

  --receipt-url URL
    URL to the published receipt.
    [default: --release-url + .json]
    [env: RECEIPT_URL=]

  --release-url URL
    URL to the file to download.
    [default: --receipt-url without .json]
    [env: RELEASE_URL=]

  --release-version STRING
    Release version.
    [default: first version-like string in `$(${output} --version)`]
```

<!--[[[end]]]-->

## Self Updater

If you provide `--receipt-url` or `--release-url`, `cosmofy` will add a self-updater
to the output bundle. This self-updater will look for the `--self-update` option on the command line and look for an updated release. When the option is absent, it will run `--args` as usual (see below for minor limitations).

## Supported Python CLI

Cosmopolitan Python apps have a special `.args` file which is read when it starts up. The contents of this file are typically set by the `--args` option. However,
when using the [self-updater](#self-updater), we need to check for the
`--self-update` option first. If it is absent we process the rest of the `--args`
as usual. However, since Python has already started running we only support the
following [Python Command Line Interface options](https://docs.python.org/3/using/cmdline.html):

- `-c <command>`: run a command
- `-m <module-name>`: run a module (this is the most common)
- `-`: read a command from `stdin` (rare, but we support it)
- `<script>`: run a script on the filesystem
- `-V, --version`: display the Python version (we also support `-VV`)
- `-h, -?, --help`: show relevant portions of the help message
- `-i`: enter python REPL after executing a script (`-c`, `-m`, `-`, or `<script>`)
- `-q`: don't display copyright and version messages in interactive mode

If no option is provided, the Python REPL will run.

## License

[MIT License](https://github.com/metaist/cosmofy/blob/main/LICENSE.md)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cosmofy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "cosmopolitan, bundler",
    "author": null,
    "author_email": "Metaist LLC <metaist@metaist.com>",
    "download_url": "https://files.pythonhosted.org/packages/cc/b7/b34c5db1c16da97dcefa093cbb2725d9a78d50a0c0dfd259d3bd294c0931/cosmofy-0.1.0.tar.gz",
    "platform": null,
    "description": "# cosmofy: Cosmopolitan Python Bundler\n\n<p align=\"center\">\n  <a href=\"https://github.com/metaist/cosmofy/actions/workflows/ci.yaml\"><img alt=\"Build\" src=\"https://img.shields.io/github/actions/workflow/status/metaist/cosmofy/.github/workflows/ci.yaml?branch=main&logo=github\"/></a>\n  <a href=\"https://pypi.org/project/cosmofy\"><img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/cosmofy.svg?color=blue\" /></a>\n  <a href=\"https://pypi.org/project/cosmofy\"><img alt=\"Supported Python Versions\" src=\"https://img.shields.io/pypi/pyversions/cosmofy\" /></a>\n</p>\n\n[Cosmopolitan apps](https://github.com/jart/cosmopolitan) are cross-platform binary files that work natively on Linux, macOS, and Windows. `cosmofy` is a tool to bundle your python project into a portable Cosmopolitan app.\n\n## Install\n\nmacOS / Linux:\n\n```bash\ndest=~/.local/bin/cosmofy\ncurl -sSz $dest -o $dest -L https://github.com/metaist/cosmofy/releases/latest/download/cosmofy\nchmod +x $dest\n```\n\nWindows: (PowerShell instructions coming soon)\n\n## Examples\n\n```bash\n# bundle a single script\ncosmofy examples/single-file/file-with-main.py\n\n# bundle a directory\ncosmofy examples/pkg-nested\n\n# add additional args, change output path\ncosmofy src/cosmofy --args '-m cosmofy --cosmo' --output dist/cosmofy\n\n# add self-updater\ncosmofy src/cosmofy \\\n  --args '-m cosmofy --cosmo' \\\n  --release-url https://github.com/metaist/cosmofy/releases/latest/download/cosmofy\n```\n\n## Usage\n\n<!--[[[cog\nfrom cosmofy.args import USAGE\ndoc = USAGE.replace('COSMOFY_CACHE_DIR=/home/lev/.cache/cosmofy', 'COSMOFY_CACHE_DIR=~/.cache/cosmofy')\ncog.outl(f\"\\n```text\\n{doc}```\\n\")\n]]]-->\n\n```text\ncosmofy: Cosmopolitan Python Bundler\n\nUSAGE\n\n  cosmofy\n    [--help] [--version] [--debug] [--dry-run] [--self-update]\n    [--python-url URL] [--cache PATH] [--clone]\n    [--output PATH] [--args STRING]\n    <add>... [--exclude GLOB]... [--remove GLOB]...\n    [--receipt PATH] [--receipt-url URL] [--release-url URL]\n    [--release-version STRING]\n\nGENERAL\n\n  -h, --help        Show this help message and exit.\n  --version         Show program version and exit.\n  --debug           Show debug messages.\n  -n, --dry-run     Do not make any file system changes.\n  --self-update     Update `cosmofy` to the latest version.\n\nCACHE\n\n  --python-url URL\n    URL from which to download Cosmopolitan Python.\n    [default: https://cosmo.zip/pub/cosmos/bin/python]\n    [env: COSMOFY_PYTHON_URL=None]\n\n  --cache PATH\n    Directory in which to cache Cosmopolitan Python downloads.\n    Use `false` or `0` to disable caching.\n    [default: ~/.cache/cosmofy]\n    [env: COSMOFY_CACHE_DIR=None]\n\n  --clone\n    Obtain python by cloning `cosmofy` and removing itself instead of\n    downloading it from `--python-url`.\n\nOUTPUT\n\n  -o PATH, --output PATH\n    Path to output file.\n    [default: `<main_module>.com`]\n\n    `<main_module>` is the first module with a `__main__.py` or file with an\n    `if __name__ == \"__main__\"` line.\n\nFILES\n\n  --args STRING\n    Cosmopolitan Python arguments.\n    [default: `\"-m <main_module>\"`]\n\n  --add GLOB, <add>\n    At least one glob-like patterns to add. Folders are recursively added.\n    Files ending in `.py` will be compiled.\n\n  -x GLOB, --exclude GLOB\n    One or more glob-like patterns to exclude from being added.\n\n    Common things to exclude are egg files and python cache:\n    $ cosmofy src -x \"**/*.egg-info/*\" -x \"**/__pycache__/*\"\n\n  --rm GLOB, --remove GLOB\n    One or more glob-like patters to remove from the output.\n\n    Common things to remove are `pip`, terminal info, and SSL certs:\n    $ cosmofy src/my_module --rm 'usr/*' --rm 'Lib/site-packages/pip/*'\n\nSELF-UPDATER\n\n  Specifying any of the options below will add `cosmofy.updater`\n  to make the resulting app capable of updating itself. You\n  must supply at least `--receipt-url` or `--release-url`.\n\n  In addition to building the app, there will be a second output\n  which is a JSON file (called a receipt) that needs to be uploaded\n  together with the app.\n\n  When the app runs, the updater first checks to see if it was called with `--self-update`. If it wasn't, execution continues as normal.\n  If it was, the updater checks the published receipt to see if there is a\n  newer version of the app and downloads it, if appropriate.\n\n  NOTE: The updater will alter `--args` so that it gets called first.\n  It supports most Python Command Line interface options (like `-m`).\n  For a full list see: https://github.com/metaist/cosmofy#supported-python-cli\n\n  --receipt PATH\n    Set the path for the JSON receipt.\n    [default: `<output>.json`]\n\n  --receipt-url URL\n    URL to the published receipt.\n    [default: --release-url + .json]\n    [env: RECEIPT_URL=]\n\n  --release-url URL\n    URL to the file to download.\n    [default: --receipt-url without .json]\n    [env: RELEASE_URL=]\n\n  --release-version STRING\n    Release version.\n    [default: first version-like string in `$(${output} --version)`]\n```\n\n<!--[[[end]]]-->\n\n## Self Updater\n\nIf you provide `--receipt-url` or `--release-url`, `cosmofy` will add a self-updater\nto the output bundle. This self-updater will look for the `--self-update` option on the command line and look for an updated release. When the option is absent, it will run `--args` as usual (see below for minor limitations).\n\n## Supported Python CLI\n\nCosmopolitan Python apps have a special `.args` file which is read when it starts up. The contents of this file are typically set by the `--args` option. However,\nwhen using the [self-updater](#self-updater), we need to check for the\n`--self-update` option first. If it is absent we process the rest of the `--args`\nas usual. However, since Python has already started running we only support the\nfollowing [Python Command Line Interface options](https://docs.python.org/3/using/cmdline.html):\n\n- `-c <command>`: run a command\n- `-m <module-name>`: run a module (this is the most common)\n- `-`: read a command from `stdin` (rare, but we support it)\n- `<script>`: run a script on the filesystem\n- `-V, --version`: display the Python version (we also support `-VV`)\n- `-h, -?, --help`: show relevant portions of the help message\n- `-i`: enter python REPL after executing a script (`-c`, `-m`, `-`, or `<script>`)\n- `-q`: don't display copyright and version messages in interactive mode\n\nIf no option is provided, the Python REPL will run.\n\n## License\n\n[MIT License](https://github.com/metaist/cosmofy/blob/main/LICENSE.md)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Cosmopolitan Python Bundler",
    "version": "0.1.0",
    "project_urls": {
        "Changelog": "https://github.com/metaist/cosmofy/blob/main/CHANGELOG.md",
        "Documentation": "https://metaist.github.io/cosmofy/",
        "Homepage": "https://github.com/metaist/cosmofy",
        "Repository": "https://github.com/metaist/cosmofy.git"
    },
    "split_keywords": [
        "cosmopolitan",
        " bundler"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "15d4f275ec20b3aea98bb6f11754094d8fd0e8055b35b0c3927ba183ce880101",
                "md5": "e07ae96bb46df8106e5b97c232bf1ce1",
                "sha256": "2b8e4900db455cf27fdc8951bbeff41f161f1905bbf7ef87c160a7510a108a40"
            },
            "downloads": -1,
            "filename": "cosmofy-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e07ae96bb46df8106e5b97c232bf1ce1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 22534,
            "upload_time": "2024-09-18T19:12:37",
            "upload_time_iso_8601": "2024-09-18T19:12:37.492360Z",
            "url": "https://files.pythonhosted.org/packages/15/d4/f275ec20b3aea98bb6f11754094d8fd0e8055b35b0c3927ba183ce880101/cosmofy-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ccb7b34c5db1c16da97dcefa093cbb2725d9a78d50a0c0dfd259d3bd294c0931",
                "md5": "bf22a913c93c804824a85e09abb49446",
                "sha256": "570835c0551765fb3e195e8b05a979b8ac42d100230a98d89257c310b36bfb2c"
            },
            "downloads": -1,
            "filename": "cosmofy-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bf22a913c93c804824a85e09abb49446",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 27861,
            "upload_time": "2024-09-18T19:12:38",
            "upload_time_iso_8601": "2024-09-18T19:12:38.792977Z",
            "url": "https://files.pythonhosted.org/packages/cc/b7/b34c5db1c16da97dcefa093cbb2725d9a78d50a0c0dfd259d3bd294c0931/cosmofy-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-18 19:12:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "metaist",
    "github_project": "cosmofy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cosmofy"
}
        
Elapsed time: 0.40170s