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.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1147728fbb4b4072bfa1490e561fab9ac8e5b1fc89ed047fa4a640a409d7dc3 |
|
MD5 | 38bf1c8b7ea5b93b11a19ffd4b7684bd |
|
BLAKE2b-256 | 36345042a1bd1b29e1f3d4b275eb689f9b3581e64e6e0fb83d27d785c95751e9 |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | a990511c244801b086ce5d70b1fd448f6012416fb324e76820a24c20f8ce4174 |
|
MD5 | 6a56d672d50d25a4ae9982b508b799d9 |
|
BLAKE2b-256 | efd852ab374c68434aae5a7fd1a3b366e30758b1d9d57105371ce2ff5cd99969 |