跳至主要内容

pypict:Microsoft PICT的Python绑定

项目描述

GitHubActions PyPI

PyPICT

Microsoft PICT (成对独立组合工具) 的Python绑定库。

要求

  • Microsoft PICT 3.7.1

  • Python 3.7 / 3.8 / 3.9 / 3.10

安装

Linux (x86_64) 上有可用的wheel(二进制分发)。PICT共享库包含在wheel中。

$ pip install pypict

在其他平台上,您需要从源代码构建。PICT源树已注册为本存储库的子模块。运行 python setup.py build_pict 将在树内部运行 make 命令以构建PICT共享库。您需要手动安装共享库和命令,或将树的路径设置到适当的环境变量(PATHLD_LIBRARY_PATH 等)。

$ git clone --recursive https://github.com/kmaehashi/pypict.git pypict
$ cd pypict
$ python setup.py build_pict
$ pip install -U .
$ export PATH=${PWD}/pict:${PATH}
$ export LD_LIBRARY_PATH=${PWD}/pict:${LD_LIBRARY_PATH}

APIs

该库提供了不同层次的API。

低级API(《pypict.capi》)

低级API提供了映射到每个PICT C API函数的Python函数。

>>> import pypict.capi
>>> task = pypict.capi.createTask()
>>> print(task)
14042112
>>> pypict.capi.deleteTask(task)

CLIDLL API(《pypict.capi.execute》),接受PICT命令行参数并返回输出,也是可用的。

>>> import pypict.capi
>>> output = pypict.capi.execute(['example/example.model', '/o:2'])
>>> print(output)
Type    Size    Format method   File system     Cluster size    Compression
Mirror  100     Quick           FAT             2048            Off
...

注意,当生成警告时,CLIDLL API直接写入stderr。

您可以将 pypict 模块用作类似于PICT命令行工具的命令(例如,python -m pypict example/example.model /o:2)。

高级API(《pypict.api》)

高级API封装了低级API,以提供具有RAII API的自动内存管理。

>>> import pypict.api
>>> task = pypict.api.Task()
>>> task.model.add_parameter(2)
19976288
>>> task.model.add_parameter(3)
20013488
>>> list(task.generate())
[[1, 0], [0, 1], [1, 1], [0, 2], [1, 2], [0, 0]]

命令API(《pypict.cmd》)

命令API封装了CLIDLL API。

>>> import pypict.cmd
>>> pypict.cmd.from_model('''
... X: 1, 2
... Y: 3, 4
... ''')
(['X', 'Y'], [['2', '4'], ['2', '3'], ['1', '4'], ['1', '3']])

项目详情


下载文件

下载适合您平台的文件。如果您不确定该选择哪一个,请了解有关安装包的更多信息。

源分布

此版本中没有可用的源分布文件。请参阅有关生成分布存档的教程。

构建分布

pypict-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (657.6 kB 查看哈希值)

上传时间 CPython 3.10 manylinux: glibc 2.17+ x86-64

pypict-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (656.9 kB 查看哈希值)

上传时间 CPython 3.9 manylinux: glibc 2.17+ x86-64

pypict-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (659.8 kB 查看哈希值)

上传时间 CPython 3.8 manylinux: glibc 2.17+ x86-64

pypict-0.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (624.8 kB 查看哈希值)

上传时间 CPython 3.7m manylinux: glibc 2.17+ x86-64

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面