使用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第三方库


热门话题
amazon web services Java AWS s3:如何使用Md5预签名url设置和上载内容   twitter使用java从推文中排除一些单词   如何在GUI java中添加延迟时间   java程序,如何使用Outputstream发送两次消息   java为什么是javax。在将Yasson与JSONB一起使用时,Glassfish中的json需要作为依赖项吗?   如何从dist文件夹中读取文件   java如何获取与模式匹配的文件列表   java如何使用Intent从Android应用程序发送彩信?   java限制对Spring的依赖,同时又不丧失框架的功能   java是否将捕获异常报告给Firebase/Fabric等?   用jdbcjava实现mysql分页   给定URI的java注释检索   java是序列化/反序列化公共枚举的简单方法?   java如何使用jMockit模拟本机方法