scriptmerge


Namescriptmerge JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/Amourspirit/python-scriptmerge/tree/scriptmerge
SummaryConvert Python packages into a single script
upload_time2024-02-24 21:59:59
maintainer
docs_urlNone
author:Barry-Thomas-Paul: Moss
requires_python>=3.7,<4.0
licenseBSD-2-Clause
keywords scriptmerge stickytape compile
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # scriptmerge: Convert Python packages into a single script

Scriptmerge can be used to convert a Python script and any Python modules
it depends on into a single-file Python script.
There are likely better alternatives depending on what you're trying to do.
For instance:

* If you want to create a single file that can be executed by a Python interpreter,
  use [zipapp](https://docs.python.org/3/library/zipapp.html).

* If you need to create a standalone executable from your Python script,
  I recommend using an alternative such as [PyInstaller](http://www.pyinstaller.org/).

Since scriptmerge relies on correctly analysing both your script and any dependent modules,
it may not work correctly in all circumstances.


## Installation

```sh
pip install scriptmerge
```

## Usage

You can tell scriptmerge which directories to search using the `--add-python-path` argument.
For instance:

```sh
scriptmerge scripts/blah --add-python-path . > /tmp/blah-standalone
```

Or to output directly to a file:

```sh
scriptmerge scripts/blah --add-python-path . --output-file /tmp/blah-standalone
```

You can also point scriptmerge towards a Python binary that it should use
sys.path from, for instance the Python binary inside a virtualenv:

```sh
scriptmerge scripts/blah --python-binary _virtualenv/bin/python --output-file /tmp/blah-standalone
```

Sscriptmerge cannot automatically detect dynamic imports,
but you can use `--add-python-module` to explicitly include modules:

```sh
scriptmerge scripts/blah --add-python-module blah.util
```

Scriptmerge can exclucde modules from be added to output.
This is useful in special cases where is it known that a module is not required to run the methods being used in the output.
An example might be a script that is being used as a LibreOffice macro.
You can use `--exclude-python-module` to explicitly exclude modules.

`--exclude-python-module` takes one or more regular expressions

In this example module `blah` is excluded entirly.
`blah\.*` matches modules such as `blah.__init__`, `blah.my_sub_module`.

```sh
scriptmerge scripts/blah --exclude-python-module blah\.*
```

By default, scriptmerge will ignore the shebang in the script
and use `"#!/usr/bin/env python"` in the output file.
To copy the shebang from the original script,
use `--copy-shebang`:

```sh
scriptmerge scripts/blah --copy-shebang --output-file /tmp/blah-standalone
```

Scritpmerge can strip all doc strings and comments from imported modules using the `--clean` option.

```sh
scriptmerge --clean
```

To see all scriptmerge options:

```sh
scriptmerge --help
```

As you might expect with a program that munges source files, there are a
few caveats:

* Due to the way that scriptmerge generates the output file, your script
  source file should be encoded using UTF-8. If your script doesn't declare
  its encoding in its first two lines, then it will be UTF-8 by default
  as of Python 3.

* Your script shouldn't have any ``from __future__`` imports.

* Anything that relies on the specific location of files will probably
  no longer work. In other words, ``__file__`` probably isn't all that
  useful.

* Any files that aren't imported won't be included. Static data that
  might be part of your project, such as other text files or images,
  won't be included.

# Credits

Scriptmerge is a fork of [stickytape](https://pypi.org/project/stickytape/).

Credit goes to Michael Williamson as the original author.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Amourspirit/python-scriptmerge/tree/scriptmerge",
    "name": "scriptmerge",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "scriptmerge,stickytape,compile",
    "author": ":Barry-Thomas-Paul: Moss",
    "author_email": "bigbytetech@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/2b/ad/6a154c68293118fc8ea0ed41d7baeff6d282161e5684a6e44ce3fad6ee6a/scriptmerge-1.1.0.tar.gz",
    "platform": null,
    "description": "# scriptmerge: Convert Python packages into a single script\n\nScriptmerge can be used to convert a Python script and any Python modules\nit depends on into a single-file Python script.\nThere are likely better alternatives depending on what you're trying to do.\nFor instance:\n\n* If you want to create a single file that can be executed by a Python interpreter,\n  use [zipapp](https://docs.python.org/3/library/zipapp.html).\n\n* If you need to create a standalone executable from your Python script,\n  I recommend using an alternative such as [PyInstaller](http://www.pyinstaller.org/).\n\nSince scriptmerge relies on correctly analysing both your script and any dependent modules,\nit may not work correctly in all circumstances.\n\n\n## Installation\n\n```sh\npip install scriptmerge\n```\n\n## Usage\n\nYou can tell scriptmerge which directories to search using the `--add-python-path` argument.\nFor instance:\n\n```sh\nscriptmerge scripts/blah --add-python-path . > /tmp/blah-standalone\n```\n\nOr to output directly to a file:\n\n```sh\nscriptmerge scripts/blah --add-python-path . --output-file /tmp/blah-standalone\n```\n\nYou can also point scriptmerge towards a Python binary that it should use\nsys.path from, for instance the Python binary inside a virtualenv:\n\n```sh\nscriptmerge scripts/blah --python-binary _virtualenv/bin/python --output-file /tmp/blah-standalone\n```\n\nSscriptmerge cannot automatically detect dynamic imports,\nbut you can use `--add-python-module` to explicitly include modules:\n\n```sh\nscriptmerge scripts/blah --add-python-module blah.util\n```\n\nScriptmerge can exclucde modules from be added to output.\nThis is useful in special cases where is it known that a module is not required to run the methods being used in the output.\nAn example might be a script that is being used as a LibreOffice macro.\nYou can use `--exclude-python-module` to explicitly exclude modules.\n\n`--exclude-python-module` takes one or more regular expressions\n\nIn this example module `blah` is excluded entirly.\n`blah\\.*` matches modules such as `blah.__init__`, `blah.my_sub_module`.\n\n```sh\nscriptmerge scripts/blah --exclude-python-module blah\\.*\n```\n\nBy default, scriptmerge will ignore the shebang in the script\nand use `\"#!/usr/bin/env python\"` in the output file.\nTo copy the shebang from the original script,\nuse `--copy-shebang`:\n\n```sh\nscriptmerge scripts/blah --copy-shebang --output-file /tmp/blah-standalone\n```\n\nScritpmerge can strip all doc strings and comments from imported modules using the `--clean` option.\n\n```sh\nscriptmerge --clean\n```\n\nTo see all scriptmerge options:\n\n```sh\nscriptmerge --help\n```\n\nAs you might expect with a program that munges source files, there are a\nfew caveats:\n\n* Due to the way that scriptmerge generates the output file, your script\n  source file should be encoded using UTF-8. If your script doesn't declare\n  its encoding in its first two lines, then it will be UTF-8 by default\n  as of Python 3.\n\n* Your script shouldn't have any ``from __future__`` imports.\n\n* Anything that relies on the specific location of files will probably\n  no longer work. In other words, ``__file__`` probably isn't all that\n  useful.\n\n* Any files that aren't imported won't be included. Static data that\n  might be part of your project, such as other text files or images,\n  won't be included.\n\n# Credits\n\nScriptmerge is a fork of [stickytape](https://pypi.org/project/stickytape/).\n\nCredit goes to Michael Williamson as the original author.\n",
    "bugtrack_url": null,
    "license": "BSD-2-Clause",
    "summary": "Convert Python packages into a single script",
    "version": "1.1.0",
    "project_urls": {
        "Documentation": "https://github.com/Amourspirit/python-scriptmerge/tree/scriptmerge",
        "Homepage": "https://github.com/Amourspirit/python-scriptmerge/tree/scriptmerge",
        "Repository": "https://github.com/Amourspirit/python-scriptmerge/tree/scriptmerge"
    },
    "split_keywords": [
        "scriptmerge",
        "stickytape",
        "compile"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "64b434a0914b1c551c1b83c0c2bb18cb88f476c050baf0bc302a4996cb40e5a1",
                "md5": "3c72d336d84ba3e2befd39ddbd996350",
                "sha256": "c1e08c136628d2ba3c0c3d8ed13e36d102e01da72e8c5bcfcb5ef19619cd068b"
            },
            "downloads": -1,
            "filename": "scriptmerge-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3c72d336d84ba3e2befd39ddbd996350",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 10427,
            "upload_time": "2024-02-24T21:59:57",
            "upload_time_iso_8601": "2024-02-24T21:59:57.439651Z",
            "url": "https://files.pythonhosted.org/packages/64/b4/34a0914b1c551c1b83c0c2bb18cb88f476c050baf0bc302a4996cb40e5a1/scriptmerge-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2bad6a154c68293118fc8ea0ed41d7baeff6d282161e5684a6e44ce3fad6ee6a",
                "md5": "0fcfb9452d8ff9b0c4c190331c702ee8",
                "sha256": "3c5bc476fdb0dd93563a53caf52f1be2385647c298cb8b99f83db77a6a309102"
            },
            "downloads": -1,
            "filename": "scriptmerge-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0fcfb9452d8ff9b0c4c190331c702ee8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 10584,
            "upload_time": "2024-02-24T21:59:59",
            "upload_time_iso_8601": "2024-02-24T21:59:59.036583Z",
            "url": "https://files.pythonhosted.org/packages/2b/ad/6a154c68293118fc8ea0ed41d7baeff6d282161e5684a6e44ce3fad6ee6a/scriptmerge-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-24 21:59:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Amourspirit",
    "github_project": "python-scriptmerge",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "scriptmerge"
}
        
Elapsed time: 0.20026s