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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file al78tools-1.0.0.tar.gz
.
File metadata
- Download URL: al78tools-1.0.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 136fde5d9e0cb598268284c3d43960b641c00e5b0ead1aac8b723424dab695d3 |
|
MD5 | 693e033c71092451a5a16743696abbbd |
|
BLAKE2b-256 | 85ca7fbbcbffa9140714a6f2d1d6388a3435a6a32e0a7f2d6c227d0d8f3f85b7 |
File details
Details for the file al78tools-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: al78tools-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 311e08d04749f0eca284e6e02a45ea4fae0e046e5f6916d75bec7369937b133a |
|
MD5 | b9cced147c60b5aeeaf2cdbd4c17dff3 |
|
BLAKE2b-256 | 5871f125ee0a98f28276999d85e0fa2f21b44de5d0f6c74f41b95f3fd3bddca2 |