使用pep 517钩子构建python包的包装器

pep517的Python项目详细描述


PEP 517指定一个标准 用于构建python包的系统的api。

此包包含pep 517指定的钩子周围的包装。它 提供:

  • 调用子进程中钩子的机制,以便它们与 当前进程。
  • 可选钩子的回退,以便前端可以调用钩子 检查已定义的。
  • 将生成依赖项安装到 临时环境并使用它们构建一个wheel/sdist。

使用py.test运行测试。

高级使用,处理生成要求:

importosfrompep517.envbuildimportbuild_wheel,build_sdistsrc='path/to/source'# Folder containing 'pyproject.toml'destination='also/a/folder'whl_filename=build_wheel(src,destination)assertos.path.isfile(os.path.join(destination,whl_filename))targz_filename=build_sdist(src,destination)assertos.path.isfile(os.path.join(destination,targz_filename))

您负责确保构建需求 可用:

importosimportpytomlfrompep517.wrappersimportPep517HookCallersrc='path/to/source'# Folder containing 'pyproject.toml'withopen(os.path.join(src,'pyproject.toml'))asf:build_sys=pytoml.load(f)['build-system']print(build_sys['requires'])# List of static requirementshooks=Pep517HookCaller(src,build_backend=build_sys['build_backend'])config_options={}# Optional parameters for backend# List of dynamic requirements:print(hooks.get_requires_for_build_wheel(config_options))destination='also/a/folder'whl_filename=hooks.build_wheel(destination,config_options)assertos.path.isfile(os.path.join(destination,whl_filename))

要测试项目的生成后端,请在系统外壳中运行:

python3 -m pep517.check path/to/source  # source dir containing pyproject.toml

要将后端构建为源和/或二进制发行版,请在shell中运行:

python -m pep517.build path/to/source  # source dir containing pyproject.toml

当pypadecides on the best place for this functionality时,这个“build”模块应该被认为是实验性的。

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

推荐PyPI第三方库


热门话题
java JAXB封送字符串,具有xml值,且不转义该值   java ModelMapper转换器不工作   java像HH000412或HCANN000001这样的前缀是什么意思?   验证日期输入修复java。lang.numberformatexception错误   当表具有外键时,java Telosys代码生成失败   如何使所有派生类一起只能实例化一个实例的单例抽象基类?(爪哇)   java如何在非静态服务类中使用广播接收器   java nutch爬虫相对URL问题   使用Jboss DMR下载/保存java附件   Rest模板:无法提取响应:当我们得到xml响应时,没有找到适合响应类型的HttpMessageConverter,没有绑定到JAVA对象   java如何编写可扩展窗格/面板/卡的代码   java是在ITreeViewerListener的treeExpanded()之前调用ContentProvider的getChildren()吗?   java将JComponent添加到小程序窗格   java混淆:使用简单逻辑的Flames程序