{"id":13467933,"url":"https://github.com/Akrog/pinliner","last_synced_at":"2025-03-26T03:31:18.817Z","repository":{"id":54337341,"uuid":"54786442","full_name":"Akrog/pinliner","owner":"Akrog","description":"Python Inliner merges in a single file all files from a Python package.","archived":false,"fork":false,"pushed_at":"2023-02-04T08:54:34.000Z","size":43,"stargazers_count":124,"open_issues_count":8,"forks_count":19,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-01T15:46:51.379Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Akrog.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-26T15:52:01.000Z","updated_at":"2025-02-14T08:08:17.000Z","dependencies_parsed_at":"2023-02-18T15:15:33.049Z","dependency_job_id":null,"html_url":"https://github.com/Akrog/pinliner","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akrog%2Fpinliner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akrog%2Fpinliner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akrog%2Fpinliner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akrog%2Fpinliner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Akrog","download_url":"https://codeload.github.com/Akrog/pinliner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245584748,"owners_count":20639621,"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-07-31T15:01:02.775Z","updated_at":"2025-03-26T03:31:18.067Z","avatar_url":"https://github.com/Akrog.png","language":"Python","funding_links":[],"categories":["Python","Miscellaneous"],"sub_categories":[],"readme":"===========================\npinliner - Python Inliner\n===========================\n\n.. image:: https://img.shields.io/:license-apache-blue.svg\n         :target: http://www.apache.org/licenses/LICENSE-2.0\n\n.. image:: https://img.shields.io/pypi/v/pinliner.svg\n        :target: https://pypi.python.org/pypi/pinliner\n\n\nThis tool allows you to merge all files that comprise a Python package into\na single file and be able to use this single file as if it were a package.\n\nNot only will it behave as if it were the original package, but it will also\nshow code in exceptions and debug sessions, and will display the right line\nnumber and file when logging.\n\nImports will work as usual so if you have a package structure like:\n\n::\n\n    .\n    └── [my_package]\n         ├── file_a.py\n         ├── [sub_package]\n         │    ├── file_b.py\n         │    └── __init__.py\n         ├── __init__.py\n\nAnd with pinliner installed you execute:\n\n.. code:: bash\n\n    $ mkdir inlined\n    $ pinliner my_package -o inlined/my_package.py\n    $ cd inlined\n    $ python\n\nYou'll be able to use generated `my_package.py` file as if it were the real\npackage:\n\n.. code:: python\n\n    \u003e\u003e\u003e import my_package\n    \u003e\u003e\u003e from my_package import file_a as a_file\n    \u003e\u003e\u003e from my_package.sub_package import file_b\n\nAnd `__init__.py` contents will be executed as expected when importing\n`my_package` package and you'll be able to access its contents like you would\nwith your normal package.\n\nModules will also behave as usual.\n\nIf your package is checking `__name__` for `__main__` it will also work as\nusual.  Although given the fact that we only have 1 file we will no longer be\nable to call other packages/modules directly from the command line to trigger\ncode conditioned to `__name__` having `__main__` as its value.\n\nLoader code will automatically compile packages and modules to byte code,\nbefore running it.  When a module is imported for the first time, or when the\nspecific's package/module source (not the whole inlined file) is more recent\nthan the current compiled file, a .pyc file containing the compiled code will\nbe created in the same directory as the pinlined .py file.\n\nIf the byte code is up to date then it will be used instead, thus avoiding a\nrecompilation, exactly the same as python normally does, with the only\nexception that all .pyc files will be in the same directory and the filenames\nwill include the full path to the original file.\n\nBundle\n------\n\nPinliner is now capable of acting like a bundle where multiple packages can be\ninlined into a single file.\n\nWhen including multiple files the default is not to automatically load *any* of\nthe packages from the module when loading the bundle.\n\n.. code:: bash\n\n    $ pinliner my_package another_package -o bundle.py\n    $ python\n\n.. code:: python\n\n    \u003e\u003e\u003e import bundle\n\n    \u003e\u003e\u003e import my_package\n    \u003e\u003e\u003e from my_package import file_a as a_file\n    \u003e\u003e\u003e from my_package.sub_package import file_b\n\n    \u003e\u003e\u003e import another_package\n\nWe can default to automatically load a specific package from the bundle:\n\n.. code:: bash\n\n    $ pinliner my_package another_package -d another_package -o another_package.py\n\nThis is convenient if we include multiple packages but we have a main program\nthat we want to execute automatically and the others are just libraries\nrequired by this probram.\n\nInlined file name\n-----------------\n\nFor inlined package and bundles to work as expected one must pay attention to\nthe inlined file name following these rules:\n\n- Output filename of an inlined single package must have the same name as the\n  package itself: ``$ pinliner my_package -o inlined/my_package.py``\n\n- Output filename of a bundle with no default package must not match ANY of the\n  packages included in the bundle: ``$ pinliner my_package another_package\n  -o bundle.py``\n\n- Output filename of a bundle with a default package must match the default\n  package name: ``$ pinliner my_package another_package -d another_package\n  -o another_package.py``\n\n- Output filename of a single package with an empty default must have a name\n  that doesn't match the inlined package name: ``$ pinliner my_package -d ''\n  -o inlined.py``\n\nInstallation\n------------\n\nYou can install pinliner globally in your system or use a virtual environment,\nthis is how it could be done using a virtual environment:\n\n.. code:: bash\n\n    $ virtualenv .venv\n    $ source .venv/bin/activate\n    $ pip install pinliner\n\nAfter that you can run the tool with `pinliner`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAkrog%2Fpinliner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAkrog%2Fpinliner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAkrog%2Fpinliner/lists"}