al78tools


Nameal78tools JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://gitlab.com/alda78/al78tools
SummaryTools for PySetup etc.
upload_time2024-10-21 09:55:52
maintainerNone
docs_urlNone
authorAles Adamek
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # al78 tools

## Tools for Python setup file
Simple tools to complete setup.py file


## Installation
```bash
pip3 install al78tools
```

## Usage

### Handle App first run

There is no way to run some post install bash code after pip package installation. But you can use this simple
tool to run some bash code after first run of your app.

#### Example
`main.py` file
```python
import os
from al78tools.pysetup.first_run import first_run_decorator
from al78tools.pysetup.tools import get_file_content


APP = "my-app-name"
VERSION = get_file_content(os.path.join(os.path.dirname(__file__), "VERSION"))


@first_run_decorator(APP, VERSION)
def _handle_first_run():
    import subprocess
    result = subprocess.run([os.path.join(os.path.dirname(__file__), "postinstall.sh")])
    if result.returncode != 0:
        print("Postinstall script failed.")


def main():    
    _handle_first_run()
    # rest of your code

if __name__ == '__main__':
    main()
```
!!! Warning !!! Do not forget to add `postinstall.sh` file to your `MANIFEST.in` file.
After this, you can use `postinstall.sh` file to run some bash code after first run of your app.
There is a version string compare mechanism. If version differs from previous version, the `postinstall.sh` will be run.
If you want to run `postinstall.sh` only once during all package updates, do not fill version paremeter in `first_run_decorator` function
and it will run only for the first time of package installation.


### File content reading
`setup.py` file
```python
import os
from al78tools.pysetup.tools import get_file_content, get_file_content_as_list


pwd = os.path.dirname(__file__)

VERSION = get_file_content(os.path.join(pwd, "VERSION"))
README_MD = get_file_content(os.path.join(pwd, "README.md"))
requirements = get_file_content_as_list(os.path.join(pwd, "requirements.txt"))
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/alda78/al78tools",
    "name": "al78tools",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Ales Adamek",
    "author_email": "alda78@seznam.cz",
    "download_url": "https://files.pythonhosted.org/packages/36/34/5042a1bd1b29e1f3d4b275eb689f9b3581e64e6e0fb83d27d785c95751e9/al78tools-1.0.2.tar.gz",
    "platform": null,
    "description": "# al78 tools\n\n## Tools for Python setup file\nSimple tools to complete setup.py file\n\n\n## Installation\n```bash\npip3 install al78tools\n```\n\n## Usage\n\n### Handle App first run\n\nThere is no way to run some post install bash code after pip package installation. But you can use this simple\ntool to run some bash code after first run of your app.\n\n#### Example\n`main.py` file\n```python\nimport os\nfrom al78tools.pysetup.first_run import first_run_decorator\nfrom al78tools.pysetup.tools import get_file_content\n\n\nAPP = \"my-app-name\"\nVERSION = get_file_content(os.path.join(os.path.dirname(__file__), \"VERSION\"))\n\n\n@first_run_decorator(APP, VERSION)\ndef _handle_first_run():\n    import subprocess\n    result = subprocess.run([os.path.join(os.path.dirname(__file__), \"postinstall.sh\")])\n    if result.returncode != 0:\n        print(\"Postinstall script failed.\")\n\n\ndef main():    \n    _handle_first_run()\n    # rest of your code\n\nif __name__ == '__main__':\n    main()\n```\n!!! Warning !!! Do not forget to add `postinstall.sh` file to your `MANIFEST.in` file.\nAfter this, you can use `postinstall.sh` file to run some bash code after first run of your app.\nThere is a version string compare mechanism. If version differs from previous version, the `postinstall.sh` will be run.\nIf you want to run `postinstall.sh` only once during all package updates, do not fill version paremeter in `first_run_decorator` function\nand it will run only for the first time of package installation.\n\n\n### File content reading\n`setup.py` file\n```python\nimport os\nfrom al78tools.pysetup.tools import get_file_content, get_file_content_as_list\n\n\npwd = os.path.dirname(__file__)\n\nVERSION = get_file_content(os.path.join(pwd, \"VERSION\"))\nREADME_MD = get_file_content(os.path.join(pwd, \"README.md\"))\nrequirements = get_file_content_as_list(os.path.join(pwd, \"requirements.txt\"))\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Tools for PySetup etc.",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://gitlab.com/alda78/al78tools"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "efd852ab374c68434aae5a7fd1a3b366e30758b1d9d57105371ce2ff5cd99969",
                "md5": "6a56d672d50d25a4ae9982b508b799d9",
                "sha256": "a990511c244801b086ce5d70b1fd448f6012416fb324e76820a24c20f8ce4174"
            },
            "downloads": -1,
            "filename": "al78tools-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6a56d672d50d25a4ae9982b508b799d9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 3792,
            "upload_time": "2024-10-21T09:55:50",
            "upload_time_iso_8601": "2024-10-21T09:55:50.458904Z",
            "url": "https://files.pythonhosted.org/packages/ef/d8/52ab374c68434aae5a7fd1a3b366e30758b1d9d57105371ce2ff5cd99969/al78tools-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "36345042a1bd1b29e1f3d4b275eb689f9b3581e64e6e0fb83d27d785c95751e9",
                "md5": "38bf1c8b7ea5b93b11a19ffd4b7684bd",
                "sha256": "a1147728fbb4b4072bfa1490e561fab9ac8e5b1fc89ed047fa4a640a409d7dc3"
            },
            "downloads": -1,
            "filename": "al78tools-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "38bf1c8b7ea5b93b11a19ffd4b7684bd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 3413,
            "upload_time": "2024-10-21T09:55:52",
            "upload_time_iso_8601": "2024-10-21T09:55:52.096637Z",
            "url": "https://files.pythonhosted.org/packages/36/34/5042a1bd1b29e1f3d4b275eb689f9b3581e64e6e0fb83d27d785c95751e9/al78tools-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-21 09:55:52",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "alda78",
    "gitlab_project": "al78tools",
    "lcname": "al78tools"
}
        
Elapsed time: 0.42859s