使用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:在迭代器类型(接口/实现类)之间转换?   java“Click Method”不断返回“Stale Element Exceoption”?   Android应用程序/进程的java生命周期?   java在发布消息时收到“无法识别的Windowssocket错误:0:recv失败”   java如何返回第二个值   java将基本授权头添加到一些请求中   使用改型安卓的java Post请求错误   PropertyPlaceHolderConfigure位置内的java Spring占位符   java是导入com的工具。谷歌。安卓gms。gcm无法解决,Google Play服务已经安装   java如何获取JSON数据的多个可选值?   java如何使用ApachePOI从word中的形状读取文本   安卓 java。Eclipse中的lang.NoClassDefFoundError,但不适用于Ant   如何在Java中用stream()将Map<v1,Set<v2>>转换为Map<v2,Set<v1>>   循环在java中循环时,如何从数组列表中删除某些内容?