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.4

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.4
File Size Uploaded
al78tools-1.0.4.tar.gz 3.9 kB Details

Built distribution (wheel)

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

Total release size: 8.2 kB

Release files / al78tools-1.0.4.tar.gz

Download URL al78tools-1.0.4.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
40d18bf5fd5c10108532f040729da191d8a14664508ad0466b8663c50e21e795
BLAKE2b-256 checksum
How to use checksums
198d3be18be3b210646219142ac944dc7fa5bb40fe9d791a8fe6ee6cb91ca565
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.4-py3-none-any.whl

Download URL al78tools-1.0.4-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff7874064beace260e60d40c611235492d21b488e8a3fc9791da83e076dbb963
BLAKE2b-256 checksum
How to use checksums
1cf969fe3c63267eeff850deb94dda7053be286a78c714afe3a40ebd56c81e50
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

This release

1.0.4 This release

2 release files

1.0.3

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