Skip to main content

Tools for PySetup etc.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

al78tools-1.0.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

al78tools-1.0.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file al78tools-1.0.1.tar.gz.

File metadata

  • Download URL: al78tools-1.0.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for al78tools-1.0.1.tar.gz
Algorithm Hash digest
SHA256 feb75024c20295da75615df1670e12bc32f962fed4956f4181957e7b5c1e7eec
MD5 a15592fb6589c59c2a420c0f21c2c6de
BLAKE2b-256 26fc5117c86c21287bdaab0034ff59696b76645f8569719e77433e8ca6a73f36

See more details on using hashes here.

File details

Details for the file al78tools-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: al78tools-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for al78tools-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 265e91a9d7b0618c634fd10e7708f9584ce8cb9977e9bfcda324e2983ebdfcc8
MD5 76b85cea10aff170515f402aff049672
BLAKE2b-256 a893324a02ececd94386812d6514ef61e48d9144347f845e7a69ed45e9c58892

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page