Plugin service that runs your python programs anywhere without install.
Project description
Aliased Shell runner for python projects
This runs your python projects/packages from anywhere inside your shell, without the need to install the package or change directory. NOTE: Currently only pipenvs are implemented. Only tested on Windows 10. Feel free to clone and extend.
NOTE: a sample packageAlias.yml file can be found here: https://gitlab.com/larsmielke2/boakboak/-/tree/main/boakboak/apps
Install
- pipenv install boakboak
dependencies
- python 3.9 - 3.10
- pyyaml
Problem boakboak tries to solve?
I have some python based services, which I want to run occasionally from anywhere inside the shell using an aliased shell call.
Most importantly: I dont want to install all these services into my main environment.
For example:
- I want to save my files to a archive directory, for which I have a archive.py module.
- I want to convert a table to a json or yaml file for which I use a convert.py package.
I want to be able to flexibly add/remove these services from the aliased shell call.
Usage
Create and packageAlias.yml file and name it like the shell call alias you like to use. Example file:
- name like: /apps/packageAlias.yml (see example in directory below)
- save to: ... \Lib\site-packages\boakboak\apps\packageAlias.yml
- or save as boakboak.yml to: app directory of the callable app (same directory as setup.py)
Run like
boak packageAlias -my parameters
Steps
Example: Imaginary project which uses a archive.py module to archive files and folders.
- I will run my module from the shell, using "python -m archive -c 'my_archive_comment'" as I always do.
- From the sucessfully executed shell command, I copy the path, cmds and optional args to archive.yml
- I save the created .yml file in: boakboak/boakboak/apps/archive.yml
- The resulting .yml file has to look like this example: https://gitlab.com/larsmielke2/boakboak/-/tree/main/boakboak/apps
From the shell, I now call:
- boak archive -c 'my_archive_comment'
How it works
boakboak will use the parameters from apps/packageAlias.yml, to run your project/package
- It takes appPath and finds your project/package (returns the first dir with .venv in it)
- It uses .venv file/folder or project name (if Pipfile is found), to identify the executable
- It uses a subprocess call, to run your cmds using identified python.exe
Logging
- boakboak can log the runtime results in logfile
- add a logDir and name to your .yml file, a runtime log will be created
- log fileName will start with the name follwoed by a timestamp.log
Example:
logDir: \python_venvs\packages\boakboak\boakboak\test\logs
name: boakboak
this will result in ...\logs\boakboak_2022-05-29-15-38-31-405411.log
External cmds
- boakboak can take cmds from another file i.e. .gitlab-ci.yml
- in .yml file specify cmds like cmds: .gitlab-ci, path, to, cmdstring
- cmdsstring has to be a comma seperated string
Example: .yml file: cmds: .gitlab-ci, precommittest, script
.gitlab-ci.yml file: precommittest: stage: test when: manual allow_failure: true tags: - test script: - python -m unittest
resulting cmds now come from script key in .gitlab-ci.yml: cmds: ['python', '-m', 'unittest']
License
Release notes
Version 1.0.9, 05-2022
- bugfix false executable
Version 1.0.8, 05-2022
- python requirement changed to 3.9 and higher
- run result can now use logging
- use of external file cmds
Version 1.0.7, 05-2022
- python requirement changed to 3.8 and higher
- Pipenv inside package now allowed (.venv folder inside package)
Version 1.0.6, 05-2022
- Bugfix for Error verifying correct executable (second try)
- Bugfix os.sep error
Version 1.0.5, 05-2022
- Bugfix for Error verifying correct executable (file not found error)
- app.yml file can now be held within the app directory as boakboak.yml
Version 1.0.4, 05-2022
- last known executable is automatically added to apps.yml files
Version 1.0.3, 05-2022
- some technical changes, i.e. README.md
Version 1.0.0, 05-2022
- python 3.8 - 3.10
- venvs: pipenv
- os: tested on Windows 10 MIT License
Copyright (c) 2022 Lars Mielke
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.