Package: pepython
Current version:0.2.5Tested with Python 3.8, 3,9, 3.10 and 3.11 on latest Linux, MacOS and Windows. Code is simple. Probably works in other versions and platforms.Pypi:https://pypi.org/project/pepython/Github:https://github.com/nandilugio/pepythonPePythonNeed help organizing your project's tasks?Don't want to learn a complex tool with an unnecessarily cumbersome syntax or API?Want to specify your tasksin plain Pythonstill having easy and flexibleaccess to the shell?Just call PePython!InstallpipinstallpepythonQuick startDefine your tasks in atasks.pyfile your root directory. Tasks are justplain Pythonfunctions. Note how dependencies are just calls in the body of the tasks themselves, alowing all kinds of dependencies and parameter forwarding (see the parameters in action further down!).frompepython.task_defimporttask,s@taskdefclean():s("rm -rf build dist *.egg-info")@taskdefbuild():clean()s("pipenv run python setup.py sdist bdist_wheel")@taskdefpublish():s("pipenv run twine upload dist/*",interactive=True)@taskdefbuild_and_publish():build()# These arepublish()#  dependencies!Then just call PePython!$ pepython --help
Usage:
        pepython [--defs-path path-to-your-tasks-definitions.py] task [task params ...]

$ pepython clean
Executed task 'clean' successfuly.

$ pepython build_and_publish
Enter your username: your-name-here
Enter your password: ************
Uploading distributions to https://test.pypi.org/legacy/
Uploading pepython-0.1.0-py2-none-any.whl
100%|█████████████████████████████████████████████████████| 7.77k/7.77k [00:00<00:00, 42.6kB/s]
Uploading pepython-0.1.0.tar.gz
100%|█████████████████████████████████████████████████████| 5.65k/5.65k [00:01<00:00, 4.74kB/s]

Executed task 'build_and_publish' successfuly.Note howdependenciesarejust method callsin the body of the tasks themselves. This allows easy forwarding of params and a more flexible schema than some configured pre/post dependencies, like it's done in other tools.If you need taskarguments, they are defined naturally, again in plain Pyhton:@taskdeftask_args(first_arg,second_arg,*rest_of_args):print(f"You've passed{first_arg}and{second_arg}as "f"the 2 first parms, then passed:\n{rest_of_args}.")$ pepython task_args a b c d e
You've passed a and b as the 2 first parms, then passed:
('c', 'd', 'e').

Executed task 'task_args' successfuly.The main idea is to use the Python language for your task automation, with all of it's flexibility but without loosing the shell. This is why there'ss()(short forshell).s()is meant to to be easy to use. Above we saw how using theinteractiveoption, the password prompt washandled interactively by the user, while othernon interactive processescan be left to be managed by the task. We'll demonstrate it here, along with thefail_fastoption, that when set to false, allows the task to manage the errors:@taskdefprocess_python_files():ls_result=s("ls *py",fail_fast=False)ifnotls_result.ok:exit("No python files here")python_files_raw=ls_result.value['out'].split("\n")python_files=[f.strip()forfinpython_files_rawiff.strip()]print(f"These are the python files in this directory:\n{python_files}")$ pepython process_python_files
These are the python files in this directory:
['setup.py', 'tasks.py']

Executed task 'shell_returned_values' successfuly.s()can also receive theverboseoption so you can see the exit code, stdout and stderr printed as follows:Executed shell command 'ls *py'
exit code was: 0
stdout was:
setup.py
tasks.py

stderr was:ContributingMake sure you have the lastestpipandpipenvversions:pipinstall--upgradepippipenvTo start developing, start the environment by:pipenvshell
pipenvinstall-dThe installedpepythonwithin the pipenv environment is the editable (allapip install -e .) version of the package, so you can manually test right away.This tool uses bothpipenvfor development andsetuptoolsfor packaging and distribution. To this date there is not a 100% community-accepted best practice so I've takenthis approach. In summary:To add anapplicationdependency, add it insetup.pyand leave it with a loose version definition. Then, just dopipenv install -e .to install the dependency. Pipenv locking mecanism will work as expected, since pepython itself is in the[packages]section ofPipfile(checkPipfile.lockand you'll find the deps there).To add adevelopmentdependency, add it toPipfileviapipenv install -d <my-dependency>.This way there's a single source of truth for package definition. No need to repeat the deps insetup.pyandPipfile*.TestsTo test the project runpytestinside thepipenv. Once you have something running, runtoxto check it's compatible with all python versions supported.IMPORTANT: in order to maketoxtest with different python versions, those have to be installed.pyenvis used for that purpose and should work out of the box. Check the required versions intox.iniand related files.Dev tasks automation and publishing to PyPIThis project usespepythonitself for automation. There you'll find tasks to build and publish the package to PyPI.LicenseThis project is licensed under the MIT License - see theLICENSEfile for details.