Using data_files in setuptools to install a platform specific binary using environment markers

时间:2019-05-06 11:26:20

标签: python multipartform-data setuptools setup.py

Data files in setup.cfg are supported since 40.5.0,并且根据issue尚不清楚环境标记的支持,但PEP 508处于活动状态并且描述他们。在setup.cfg中包含以下几行:

[options.data_files]
bin =
    bin/linux/mybin; platform_system=="Linux"
    bin/macos/mybin; platform_system=="Darwin"
    bin/win/mybin.exe; platform_system=="Windows"

以及以下软件包树:

.
├── mypackage
│   └── __init__.py
├── MANIFEST.in
├── README.mkd
├── setup.cfg
└── setup.py
├── bin
    ├── linux
    │   └── mybin
    ├── macos
    │   └── mybin
    └── win
        └── mybin.exe

我的目标只是在用户的路径中提供一个二进制文件,该二进制文件已经针对3个主要平台(Linux,Mac,Windows)进行了编译。不支持其他平台。

运行python setup.py install时,我得到以下最后几行:

running build_py
installing package data to build/bdist.linux-x86_64/egg
running install_data
error: can't copy 'bin/linux/mybin; platform_system=="Linux"': doesn't exist or not a regular file

我尝试使用setup.py而不是setup.cfg,出现相同的错误:

setup(
    data_files=[
        ('bin', [
            'bin/linux/mybin; platform_system=="Linux"',
            'bin/macos/mybin; platform_system=="Darwin"',
            'bin/win/mybin.exe; platform_system=="Windows"'
        ]),
    ]
)

我想念什么?

我在linux / fedora 26,Python 3.6.6,Setuptools 41.0.1。

0 个答案:

没有答案