项目的简单任务自动化。

pepython的Python项目详细描述


佩皮森

需要帮助组织项目的任务吗?打电话给佩皮森!

安装

pip install pepython

快速启动

在根目录的tasks.py文件中定义任务。请注意,依赖关系只是任务本身主体中的方法调用。这允许通过/转发和更灵活的模式,而不仅仅是前/后依赖项。

frompepython.task_defimporttask,s@taskdefclean(*args):s("rm -rf build dist *.egg-info")@taskdefbuild(*args):clean()s("pipenv run python setup.py sdist bdist_wheel")@taskdefpublish(*args):s("pipenv run twine upload dist/*",interactive=True)@taskdefbuild_and_publish(*args):build()publish()

那就叫佩皮森来!

$ 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.

如果您需要task参数,它们是自然定义的:

@taskdeftask_args(first_arg,second_arg,*rest_of_args):print("You've passed {} and {} as the 2 first parms, then passed:\n{}.".format(first_arg,second_arg,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.
主要的思想是使用Python进行任务自动化,所有的灵活性,但不会失去外壳。这就是为什么有s()(缩写为shell)。

除了上面显示的interactive参数(请参见输出中的密码提示),它还有其他一些可能性:

交互进程很容易通过管道传递给用户:

@taskdefchange_pass():s("passwd",interactive=True)
$ pepython change_pass
Changing password for nando.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Executed task 'change_pass' successfuly.

而其他非交互进程则可以由任务管理:

@taskdefprocess_python_files():ls_result=s("ls *py",fail_fast=False,verbose=True)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("These are the python files in this directory:\n{}".format(python_files))
$ pepython process_python_files
Executed shell command 'ls *py'
exit code was: 0
stdout was:
setup.py
tasks.py

stderr was:

These are the python files in this directory:
[u'setup.py', u'tasks.py']

Executed task 'shell_returned_values' successfuly.

开发

确保您有最新的pippipenv版本:

pip install --update pip pipenv

要开始开发,请通过以下方式启动环境:

pipenv shell
pipenv install -d

这个工具使用^{}进行开发,使用^{}进行打包和分发。到目前为止,还没有一个100%的社区接受的最佳实践,所以我采取了this approach。总而言之:

若要添加application依赖项,请将其添加到setup.py中,并保留宽松的版本定义。然后,只需pipenv install -e .来安装依赖项。pipenv锁定机制将按预期工作,因为pepython本身位于Pipfile[packages]部分(检查Pipfile.lock,您将在那里找到dep)。

要添加development依赖项,请通过pipenv install -d <my-dependency>将其添加到Pipfile

这样,包定义就只有一个真实的来源。无需在setup.pyPipfile*中重复deps。

许可证

这个项目是在麻省理工学院的许可下授权的-请参阅^{}文件了解详细信息。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何反射地迭代数组字段?   java NamedQuery错误“具有给定标识符的多行:1”   java无法使用单独类中的计时器更新TextView   兼容性什么时候可以很快使用新的Java功能?   java二叉树路径和   java矩形的性能   java我想从同一个子表在主表中添加两个外键   java如何获取基于特定日期的所有数据?   java javafx、OO编程规则和写入变量类型的选择   java使用带枚举的switch语句   java异步任务生成运行时异常   java为什么JLabel不显示下划线字符?   java如何解析具有可变参数号的函数?   带有按钮的java JavaFX自定义列表单元格:未调用处理程序   java Modelmapper无法映射整个模型?   传递给持久化的java分离实体,包含LatLng列表