Skip to main content

al78 tools

Tools for Python setup file

Simple tools to complete setup.py file

Installation

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

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

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"))

Metadata

Release files for al78tools 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for al78tools 1.0.3
File Size Uploaded
al78tools-1.0.3.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for al78tools 1.0.3
File Interpreter ABI Platform
al78tools-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / al78tools-1.0.3.tar.gz

Download URL al78tools-1.0.3.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c30cdbf225e69f74e1d568682e8bb9745b24291ce1fa7641334b139c098d2238
BLAKE2b-256 checksum
How to use checksums
090207eee06bde0e359e0557c477d90e11d0e7fa63042ce3f213582c502eb3d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / al78tools-1.0.3-py3-none-any.whl

Download URL al78tools-1.0.3-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc34f4d7f4a8b35688c2a80d0456aeee2a9c49f85ce7b1e854762ab3c5393fa3
BLAKE2b-256 checksum
How to use checksums
5628ac8d4d4f3bbba9b75584aa893e93e0afbb42cdb8ae0fb7cb9fed7ea01c57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

1.0.4

2 release files

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page