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.2.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

al78tools-1.0.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for al78tools-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a1147728fbb4b4072bfa1490e561fab9ac8e5b1fc89ed047fa4a640a409d7dc3
MD5 38bf1c8b7ea5b93b11a19ffd4b7684bd
BLAKE2b-256 36345042a1bd1b29e1f3d4b275eb689f9b3581e64e6e0fb83d27d785c95751e9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for al78tools-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a990511c244801b086ce5d70b1fd448f6012416fb324e76820a24c20f8ce4174
MD5 6a56d672d50d25a4ae9982b508b799d9
BLAKE2b-256 efd852ab374c68434aae5a7fd1a3b366e30758b1d9d57105371ce2ff5cd99969

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