使用cffi包装windows函数的python库
pywincffi的Python项目详细描述
使用cffi的python windows包装器
pywincffi是一些使用python的windows api函数的包装器 还有cffi图书馆。这个项目是 最初是为了帮助Twisted项目摆脱其 依赖于pywin32。对扩展pywincffi的api的贡献 然而,优惠总是受欢迎的。
本项目的核心目标和设计原则是:
- It should be easier to to use Windows API functions both in terms of implementation and distribution.
- Python 2.7 and 3.x should be supported from a single code base and not require a consumer of pywincffi to worry about how they use the library.
- Type conversion, error checking and other ‘C like’ code should be the responsibility of the library where possible.
- APIs provided by pywincffi should mirror their Windows counterparts as closely as possible so the MSDN documentation can be more easily used as reference.
- Documentation and error messages should be descriptive, consistent, complete and accessible. Examples should be provided for more complex use cases.
- For contributors, it should be possible to develop and test regardless of what platform the contributor is coming from.
开发
本节提供了开发过程的基本概述,包括 主要目标。这不全面,但应该是一个好的 提交请求前的介绍。
支持和文档
除了这个自述文件之外,还有两个地方你可以去接收一些 帮助:
- https://pywincffi.readthedocs.org/en/latest/dev/ - Goes beyond what’s in this readme.
- https://groups.google.com/forum/#!forum/pywincffi - Google group for discussions, questions, etc.
python版本支持
此项目支持Python2.7及更高版本,包括Python3.x.prs、补丁程序, 不支持2.x和3.x的测试等 合并了。其目的也是支持python的两个主要版本 相同的代码库,而不是依赖2to3、six或其他工具 大部分是图书馆。
文件
此库的文档位于 Read The Docs。 它是使用sphinx直接从这个库生成的:
virtualenv env env/bin/activate pip install -r dev_requirements.txt pip install -e . cd docs make html
构建过程还构建文档以确保 任何明显的问题(包括断开的链接)。
功能文档
Windows API函数通常以以下格式记录:
defDuplicateHandle(arg1,kwarg1=None):""" A brief message about this function. .. seealso:: <url to the MSDN API documentation for this function> :param type arg1: Brief information about this argument :keyword type kwarg1: Brief information about this keyword include it's default and how it's handled within the function. :raises SomeException: Some information on when this exception will be raised :rtype: type :return: Information about the data that's returned """
需要注意的是,文档包含一个seealso节。这是 通常用于参考MSDN文档,但也可用于 参考示例、白皮书或其他可能有助于 描述函数。
添加新功能将更详细地介绍 here
测试
连续积分
为了始终如一地确保最高质量的代码,以下服务是 用于测试或分析每个提交和拉取请求:
- AppVeyor - Runs the unittests, builds wheel files, MSIs and other output artifacts which can be published in a release.
- Travis - Runs the ^{tt4}$ and ^{tt5}$ command line tools on the code base and tests. This also builds the docs so documentation problems are easily spotted.
- Codecov - Analyses and displays code coverage results after tests have run on AppVeyor. Results are posted back to pull requests.
- ReadTheDocs. - The official location where documentation is built and posted. This is generally for merges into the master branch however.
附加测试
如上所示,除了单元测试之外,还有许多测试。运行全部 在windows上的测试,就像连续集成系统一样,您可以 运行test.bat:
> check.bat
这将:
- 检查库和测试的代码样式。
- 运行所有单元测试。
- 生成控制盘文件。
- 构建文档并将警告视为错误。
请记住,这不会为 你。所以如果你不能构建库或者缺少依赖项 以上可能会失败。
流浪者
上面的持续集成服务消除了大多数设置 你的本地工作站来处理PyWinCffi的开发,即使你没有 正在运行Windows。但在某些情况下,它可以更快或更容易地工作 在你的本地机器上。
如果你不运行windows或者你没有必要的工具 在你的机器上开发pywincffi你可以使用 Vagrant构建windows计算机并启动 发展。这里有一个关于这个过程的更深入的解释 这里:
https://pywincffi.readthedocs.org/en/latest/dev/vagrant.html