Metadata-Version: 2.1
Name: monoscript
Version: 1.0.3
Summary: A Python tool that merges multi-file modules into a single, self-contained script.
Home-page: https://github.com/xaled/monoscript
Author: Khalid Grandi
Author-email: kh.grandi@gmail.com
License: MIT
Keywords: packaging python
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Requires-Python: >=3
Description-Content-Type: text/x-rst
License-File: LICENSE

Monoscript
==========

Monoscript is a Python tool designed to merge multi-file modules into a single, self-contained Python file. This output file can then be used as a portable standalone script/module or included in other projects without the hassle of adding it to the packaging system.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Features
--------

-  **Multiple ``__all__`` Strategies:**

   -  **``AUTO``:** Automatically determines ``__all__`` definitions by
      combining explicit ``__all__`` definitions and implicit internal
      imports from the module’s ``__init__.py``.
   -  **``custom``:** Allows you to set a custom ``__all__`` definition.
   -  **``INIT``:** Takes only the explicit ``__all__`` definition from
      ``__init__.py``.
   -  **``NONE``:** No ``__all__`` definition is added.

-  **Removes Internal Imports:** Internal imports within the module are
   automatically removed.

-  **Organized Imports:** Top-level imports are cleaned up and
   organized. Redundant imports are removed.

-  **Test Scripts Integration:** Merges and/or runs your test scripts.

-  .. rubric:: **Metadata Support:** Includes support for metadata such
      as ``author``, ``description``, ``version``, ``requirements``, and
      more.
      :name: metadata-support-includes-support-for-metadata-such-as-author-description-version-requirements-and-more.

   .. rubric:: Limitations
      :name: limitations

   Monoscript is intended for small modules and should not be used for
   larger projects. Merging code from multiple files into a single file
   can cause unwanted behaviors:

-  **No Namespaces:** All code is merged into a single file, which may
   result in global name conflicts. The script warns you if conflicts
   are detected.

-  **Complex Top-Level Imports:** Imports within conditional statements
   (e.g., ``if`` statements or ``try/except`` blocks) are not
   reorganized and are left as-is.

-  .. rubric:: **Complex ``__all__`` Assignments:** Only simple
      assignments or incremental updates to lists of strings are
      supported. Complex operations on ``__all__`` are ignored.
      :name: complex-__all__-assignments-only-simple-assignments-or-incremental-updates-to-lists-of-strings-are-supported.-complex-operations-on-__all__-are-ignored.

   .. rubric:: Installation
      :name: installation

   Install Monoscript using pip:

.. code:: bash

   pip install monoscript

Alternatively, download ``monoscript.py`` from releases and use it directly.
----------------------------------------------------------------------------

Usage
-----

Command Line
~~~~~~~~~~~~

Run Monoscript via the command line:

.. code:: bash

   python -m monoscript path/to/module --output-dir="dist"

Or directly:

.. code:: bash

   python monoscript.py path/to/module --output-dir="dist"

Usage:

::

   $ python3 monoscript.py --help
   usage: monoscript.py [-h] [-D OUTPUT_DIR] [--process-all {NONE,AUTO,INIT}] [--custom-all CUSTOM_ALL] [--additional-all ADDITIONAL_ALL] [--no-organize-imports] [--module-name MODULE_NAME] [--module-version MODULE_VERSION]
                        [--module-description MODULE_DESCRIPTION] [--author AUTHOR] [--license LICENSE] [--project-website PROJECT_WEBSITE] [--requirements REQUIREMENTS] [--requirements-filename REQUIREMENTS_FILENAME]
                        [--additional-headers ADDITIONAL_HEADERS] [--test-scripts-dirname TEST_SCRIPTS_DIRNAME] [--merge-test-scripts] [--no-run-test-scripts]
                        module_path
   A Python tool that merges multi-file modules into a single, self-contained script.
   positional arguments:
     module_path           Path to the module directory.
   options:
     -h, --help            show this help message and exit
     -D OUTPUT_DIR, --output_dir OUTPUT_DIR
                           Output directory for the merged script.
     --process-all {NONE,AUTO,INIT}
                           Strategy for processing __all__ variable.
     --custom-all CUSTOM_ALL
                           Custom __all__ value (comma-separated).
     --additional-all ADDITIONAL_ALL
                           Additional items to add to __all__ (comma-separated).
     --no-organize-imports
                           Disable import organization.
     --module-name MODULE_NAME
                           Name of the output module.
     --module-version MODULE_VERSION
                           Module version.
     --module-description MODULE_DESCRIPTION
                           Module description.
     --author AUTHOR       Author of the module.
     --license LICENSE     Module license.
     --project-website PROJECT_WEBSITE
                           Project website.
     --requirements REQUIREMENTS
                           Module requirements (comma-separated).
     --requirements-filename REQUIREMENTS_FILENAME
                           Module requirements file name.
     --additional-headers ADDITIONAL_HEADERS
                           Additional headers (e.g., 'Key1=Value1,Key2=Value2').
     --test-scripts-dirname TEST_SCRIPTS_DIRNAME
                           Directory name for test scripts.
     --merge-test-scripts  Merge test scripts into the output.
     --no-run-test-scripts
                           Disable running test scripts after merging.

License
-------

Monoscript is licensed under the MIT License.
---------------------------------------------


